improve warnings (#4247)

closes #4244
This commit is contained in:
Alex Lam S.L
2020-10-27 09:39:33 +00:00
committed by GitHub
parent 607f87c5cd
commit 79e5c3f564
9 changed files with 64 additions and 63 deletions

View File

@@ -137,17 +137,17 @@ var AST_Node = DEFNODE("Node", "start end", {
}, null);
(AST_Node.log_function = function(fn, verbose) {
var printed = Object.create(null);
if (fn) {
AST_Node.info = verbose ? function(text, props) {
log("INFO: " + string_template(text, props));
} : noop;
AST_Node.warn = function(text, props) {
log("WARN: " + string_template(text, props));
};
} else {
if (!fn) {
AST_Node.info = AST_Node.warn = noop;
return;
}
var printed = Object.create(null);
AST_Node.info = verbose ? function(text, props) {
log("INFO: " + string_template(text, props));
} : noop;
AST_Node.warn = function(text, props) {
log("WARN: " + string_template(text, props));
};
function log(msg) {
if (printed[msg]) return;