From 2854d0f072704da683ff091e42b2d3b71bc9ac3a Mon Sep 17 00:00:00 2001 From: Guillaume Wuip Date: Thu, 18 Dec 2014 22:10:36 +0100 Subject: [PATCH] Create basic loggers --- scribe.js | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/scribe.js b/scribe.js index f0218c2..8cfe1e0 100644 --- a/scribe.js +++ b/scribe.js @@ -19,6 +19,8 @@ * @param {String} scribe.rootPath Logs folder. Default 'logs' * @param {Boolean} scribeOpt.createDefaultConsole Should scribe attach a fresh Console2 * to process.console ? Default true. + * @param {Boolean} scribeOpt.createBasic Should scribe create basic logging functions ? + * Default true * * @return {Object} * @return {Function} console Get a console @@ -36,6 +38,7 @@ scribeOpt.rootPath = scribeOpt.rootPath || 'logs'; scribeOpt.createDefaultConsole = scribeOpt.createDefaultConsole !== false; + scribeOpt.createBasic = scribeOpt.createBasic !== false; /** @@ -125,11 +128,48 @@ return console; }; + /** + * createBasic + * + * Create basic log function of nodejs for `console` + * + * @param {Console2} console + */ + var createBasic = function (console) { + + var loggers = [ + { + name : 'log', + color : 'white' + }, + { + name : 'info', + color : 'cyan' + }, + { + name : 'error', + color : 'red' + }, + { + name : 'warning', + color : 'yellow' + }, + { + name : 'dir', + color : 'white' + } + ]; + + loggers.forEach(function (logger) { + console.addLogger(logger.name, logger.color); + }); + }; + /** * initWebPanel * - * Retrun an express Router + * @return an express Router */ var initWebPanel = function () { @@ -143,6 +183,11 @@ process.console = addConsole(); } + //Create basic logging functions + if (scribeOpt.createBasic) { + createBasic(process.console); + } + return {