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