From 3a89b3f951fd45a9fcc0a2a7d07bc1ba17f26668 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 9 Apr 2018 15:24:01 -0400 Subject: [PATCH] intercept dir and pass it to the logger --- lib/core/logger.js | 10 ++++++++++ lib/core/plugin.js | 3 +++ 2 files changed, 13 insertions(+) diff --git a/lib/core/logger.js b/lib/core/logger.js index 3f44ce43c..9b9b1c5b5 100644 --- a/lib/core/logger.js +++ b/lib/core/logger.js @@ -64,6 +64,16 @@ Logger.prototype.trace = function (txt) { this.writeToFile("[trace]: " + txt); }; +Logger.prototype.dir = function (txt) { + if (!txt || !(this.shouldLog('info'))) { + return; + } + this.events.emit("log", "dir", txt); + this.logFunction(txt); + this.writeToFile("[dir]: "); + this.writeToFile(txt); +}; + Logger.prototype.shouldLog = function (level) { return (this.logLevels.indexOf(level) <= this.logLevels.indexOf(this.logLevel)); }; diff --git a/lib/core/plugin.js b/lib/core/plugin.js index bae7fafa5..1d830524d 100644 --- a/lib/core/plugin.js +++ b/lib/core/plugin.js @@ -77,6 +77,9 @@ Plugin.prototype.interceptLogs = function(context) { context.console.trace = function(txt) { self.logger.trace(self.name + " > " + txt); }; + context.console.dir = function(txt) { + self.logger.dir(txt); + }; }; // TODO: add deploy provider