mirror of https://github.com/embarklabs/embark.git
enable logger to log multiple arguments
This commit is contained in:
parent
537feccb52
commit
88cc4d05c0
|
@ -11,57 +11,57 @@ class Logger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.prototype.writeToFile = function (txt) {
|
Logger.prototype.writeToFile = function () {
|
||||||
if (!this.logFile) {
|
if (!this.logFile) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.appendFileSync(this.logFile, "\n" + txt);
|
fs.appendFileSync(this.logFile, "\n" + Array.from(arguments).join(' '));
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.prototype.error = function (txt) {
|
Logger.prototype.error = function () {
|
||||||
if (!txt || !(this.shouldLog('error'))) {
|
if (!arguments.length || !(this.shouldLog('error'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.events.emit("log", "error", txt);
|
this.events.emit("log", "error", ...arguments);
|
||||||
this.logFunction(txt.red);
|
this.logFunction(...Array.from(arguments).map(t => t.red));
|
||||||
this.writeToFile("[error]: " + txt);
|
this.writeToFile("[error]: ", ...arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.prototype.warn = function (txt) {
|
Logger.prototype.warn = function () {
|
||||||
if (!txt || !(this.shouldLog('warn'))) {
|
if (!arguments.length || !(this.shouldLog('warn'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.events.emit("log", "warning", txt);
|
this.events.emit("log", "warning", ...arguments);
|
||||||
this.logFunction(txt.yellow);
|
this.logFunction(...Array.from(arguments).map(t => t.yellow));
|
||||||
this.writeToFile("[warning]: " + txt);
|
this.writeToFile("[warning]: ", ...arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.prototype.info = function (txt) {
|
Logger.prototype.info = function () {
|
||||||
if (!txt || !(this.shouldLog('info'))) {
|
if (!arguments.length || !(this.shouldLog('info'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.events.emit("log", "info", txt);
|
this.events.emit("log", "info", ...arguments);
|
||||||
this.logFunction(txt.green);
|
this.logFunction(...Array.from(arguments).map(t => t.green));
|
||||||
this.writeToFile("[info]: " + txt);
|
this.writeToFile("[info]: ", ...arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.prototype.debug = function (txt) {
|
Logger.prototype.debug = function () {
|
||||||
if (!txt || !(this.shouldLog('debug'))) {
|
if (!arguments.length || !(this.shouldLog('debug'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.events.emit("log", "debug", txt);
|
this.events.emit("log", "debug", ...arguments);
|
||||||
this.logFunction(txt);
|
this.logFunction(...arguments);
|
||||||
this.writeToFile("[debug]: " + txt);
|
this.writeToFile("[debug]: ", ...arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.prototype.trace = function (txt) {
|
Logger.prototype.trace = function () {
|
||||||
if (!txt || !(this.shouldLog('trace'))) {
|
if (!arguments.length || !(this.shouldLog('trace'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.events.emit("log", "trace", txt);
|
this.events.emit("log", "trace", ...arguments);
|
||||||
this.logFunction(txt);
|
this.logFunction(...arguments);
|
||||||
this.writeToFile("[trace]: " + txt);
|
this.writeToFile("[trace]: ", ...arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.prototype.dir = function (txt) {
|
Logger.prototype.dir = function (txt) {
|
||||||
|
|
Loading…
Reference in New Issue