Remove trailing whitespace

This commit is contained in:
Guillaume Wuip 2014-12-20 10:09:14 +01:00
parent 0d819ff30f
commit d7c05d3f9a
11 changed files with 109 additions and 108 deletions

View file

@ -8,13 +8,13 @@
//Create a Console2 for express //Create a Console2 for express
//with logs saved in /expressLogger //with logs saved in /expressLogger
var expressConsole = scribe.console({ var expressConsole = scribe.console({
console : { console : {
colors : 'white', colors : 'white',
timeColors : ['grey', 'underline'], timeColors : ['grey', 'underline'],
}, },
createBasic : false, createBasic : false,
logWriter : { logWriter : {
rootPath : 'expressLogger' rootPath : 'expressLogger'
} }
}); });
@ -27,7 +27,7 @@
// return false //ie. don't log this request // return false //ie. don't log this request
//else //else
//{ //{
return true; return true;
}; };

View file

@ -4,7 +4,7 @@ var moment = require('moment'),
path = require('path'); path = require('path');
var scribe = require('../scribe.js')({ var scribe = require('../scribe.js')({
createDefaultConsole : false createDefaultConsole : false
}); });
@ -21,11 +21,11 @@ var myLogWriter = new scribe.LogWriter('logsConsoleTwo');
//Create own getPath and getFilename methods to erase to default ones //Create own getPath and getFilename methods to erase to default ones
myLogWriter.getPath = function (opt) { myLogWriter.getPath = function (opt) {
return path.join( return path.join(
this.getUser(), this.getUser(),
opt.logger.name opt.logger.name
); );
}; };
@ -37,7 +37,7 @@ myLogWriter.getFilename = function (opt) {
'.' + '.' +
opt.logger.name + opt.logger.name +
'.json'; '.json';
}; };
@ -72,8 +72,8 @@ var consoleThree = scribe.console({
/** /**
* Use the consoles * Use the consoles
* *
* Then check logsConsoleOne and logsConsoleTwo folders * Then check logsConsoleOne and logsConsoleTwo folders
*/ */

View file

@ -9,7 +9,7 @@ var console = process.console; //create a local (for the module) console
//Don't worry, you can still access the original console //Don't worry, you can still access the original console
global.console.log("I'm using the original console.log()"); global.console.log("I'm using the original console.log()");
//Let's create a new logger `myLoger` ... //Let's create a new logger `myLoger` ...
console.addLogger('myLogger'); console.addLogger('myLogger');
@ -22,5 +22,5 @@ console.tag('MyTag').time().file().myLogger('Scribe.js is awesome');
//By default, submodules still use original console //By default, submodules still use original console
require('./sub-without_new_console').saySomething("Hello world !"); require('./sub-without_new_console').saySomething("Hello world !");
//But, you can use the new one ! //But, you can use the new one !
require('./sub-with_new_console').saySomething("Hello world !"); require('./sub-with_new_console').saySomething("Hello world !");

View file

@ -6,7 +6,7 @@
var console = process.console; var console = process.console;
module.exports = { module.exports = {
saySomething : function (msg) { saySomething : function (msg) {
msg = "With new console - " + msg; msg = "With new console - " + msg;
console.myLogger(msg); //I'm using my custom logger `myLogger` console.myLogger(msg); //I'm using my custom logger `myLogger`

View file

@ -4,7 +4,7 @@
//so it doesn't break dependencies logging //so it doesn't break dependencies logging
module.exports = { module.exports = {
saySomething : function (msg) { saySomething : function (msg) {
msg = "Without new console - " + msg; msg = "Without new console - " + msg;
console.log(msg); console.log(msg);

View file

@ -1,5 +1,5 @@
/* jshint -W079 */ /* jshint -W079 */
(function () { (function () {
var scribe = require('../scribe')(), var scribe = require('../scribe')(),
console = process.console, console = process.console,
express = require('express'), express = require('express'),

View file

@ -27,7 +27,7 @@
* @return {Number} line * @return {Number} line
*/ */
var getLocation = function () { var getLocation = function () {
var st = stack()[2], var st = stack()[2],
result = {}; result = {};
@ -42,9 +42,9 @@
* *
* @param {timestamp} timestamp * @param {timestamp} timestamp
* *
* @return {Object} * @return {Object}
* @return {String} msg ISO time * @return {String} msg ISO time
* @return {int} msgLength * @return {int} msgLength
*/ */
var buildTime = function (timestamp) { var buildTime = function (timestamp) {
var time = (new Date(timestamp)).toISOString(); var time = (new Date(timestamp)).toISOString();
@ -59,9 +59,9 @@
* *
* @param {timestamp} timestamp * @param {timestamp} timestamp
* *
* @return {Object} * @return {Object}
* @return {String} msg Date to string * @return {String} msg Date to string
* @return {int} msgLength * @return {int} msgLength
*/ */
var buildDate = function (timestamp) { var buildDate = function (timestamp) {
var date = (new Date(timestamp)).toDateString(); var date = (new Date(timestamp)).toDateString();
@ -76,19 +76,19 @@
* *
* @param {Array} tags Tags are string or object {msg :'', colors : []} * @param {Array} tags Tags are string or object {msg :'', colors : []}
* *
* @return {Object} * @return {Object}
* @return {String} msg Tags string with colors if given. Ex : "[tag1][tag2]" * @return {String} msg Tags string with colors if given. Ex : "[tag1][tag2]"
* @return {int} msgLength Tags string length (without colors elements) * @return {int} msgLength Tags string length (without colors elements)
*/ */
var buildTags = function (tags) { var buildTags = function (tags) {
var result = "", var result = "",
length = 0; length = 0;
tags.forEach(function (tag) { tags.forEach(function (tag) {
if (tag !== null && typeof tag === 'object') { if (tag !== null && typeof tag === 'object') {
result += applyColors('[' + tag.msg + ']', tag.colors); result += applyColors('[' + tag.msg + ']', tag.colors);
length += ("" + tag.msg).length + 2; length += ("" + tag.msg).length + 2;
} else { } else {
result += '[' + tag + ']'; result += '[' + tag + ']';
length += ("" + tag).length + 2; length += ("" + tag).length + 2;
@ -107,13 +107,13 @@
* @param {Object} infos * @param {Object} infos
* @param {String} infos.filename * @param {String} infos.filename
* @param {String} infos.line * @param {String} infos.line
* *
* @param {String|Array} fileColors Optional colors. * @param {String|Array} fileColors Optional colors.
* @param {String|Array} lineColors Optional colors. * @param {String|Array} lineColors Optional colors.
* *
* @return {Object} * @return {Object}
* @return {String} msg File infos with colors if given * @return {String} msg File infos with colors if given
* @return {int} msgLength * @return {int} msgLength
*/ */
var buildFileInfos = function (infos, fileColors, lineColors) { var buildFileInfos = function (infos, fileColors, lineColors) {
var result = '[' + var result = '[' +
@ -187,14 +187,14 @@
* @param {int} opt.contextMediumSize Medium size of the context part of a log message. * @param {int} opt.contextMediumSize Medium size of the context part of a log message.
* Used when calculating indent. Default to 45. * Used when calculating indent. Default to 45.
* @param {int} opt.spaceSize Space between context part and log part. Default to 4. * @param {int} opt.spaceSize Space between context part and log part. Default to 4.
* *
* @param {Array|String} opt.colors Default colors output for all loggers. Default ['cyan']. * @param {Array|String} opt.colors Default colors output for all loggers. Default ['cyan'].
* @param {Array|String} opt.tagsColors Default colors output for tags. Default undefined. * @param {Array|String} opt.tagsColors Default colors output for tags. Default undefined.
* @param {Array|String} opt.timeColors Default colors output for time. Default undefined. * @param {Array|String} opt.timeColors Default colors output for time. Default undefined.
* @param {Array|String} opt.dateColors Default colors output for date. Default undefined. * @param {Array|String} opt.dateColors Default colors output for date. Default undefined.
* @param {Array|String} opt.fileColors Default colors output for filename. Default undefined. * @param {Array|String} opt.fileColors Default colors output for filename. Default undefined.
* @param {Array|String} opt.lineColors Default colors output for line number. Default undefined. * @param {Array|String} opt.lineColors Default colors output for line number. Default undefined.
* *
* @param {Boolean} opt.alwaysTags Always print tags (even without tag() ). Default false. * @param {Boolean} opt.alwaysTags Always print tags (even without tag() ). Default false.
* @param {Boolean} opt.alwaysLocation Always print location (even without file() ). Default false. * @param {Boolean} opt.alwaysLocation Always print location (even without file() ). Default false.
* @param {Boolean} opt.alwaysTime Always print time (even without time() ). Default false. * @param {Boolean} opt.alwaysTime Always print time (even without time() ). Default false.
@ -235,29 +235,29 @@
* _tags * _tags
* *
* Store all tags for current log * Store all tags for current log
* *
* @type {Array} * @type {Array}
*/ */
this._tags = []; this._tags = [];
/** /**
*._time *._time
* *
* Log time (full date) ? * Log time (full date) ?
* *
* @type {Boolean} * @type {Boolean}
*/ */
this._time = false; this._time = false;
/** /**
* _date * _date
* *
* Log date ? * Log date ?
* *
* @type {Boolean} * @type {Boolean}
*/ */
this._date = false; this._date = false;
/** /**
* _location * _location
* *
@ -265,7 +265,7 @@
* *
* @type {Boolean} * @type {Boolean}
*/ */
this._location = false; this._location = false;
/** /**
* _reset * _reset
@ -277,10 +277,10 @@
this._time = false; this._time = false;
this._date = false; this._date = false;
this._location = false; this._location = false;
return this; return this;
}; };
/** /**
* loggers * loggers
* *
@ -288,7 +288,7 @@
* @type {Object} * @type {Object}
*/ */
this.loggers = {}; this.loggers = {};
}; };
@ -330,7 +330,7 @@
Console2.prototype.tag = Console2.prototype.t = function () { Console2.prototype.tag = Console2.prototype.t = function () {
var tags = Array.prototype.slice.call(arguments, 0); var tags = Array.prototype.slice.call(arguments, 0);
this._tags = this._tags.concat(tags); this._tags = this._tags.concat(tags);
return this; return this;
}; };
@ -361,27 +361,27 @@
//if all args are string or number, format args as usual //if all args are string or number, format args as usual
if (areAllStringOrNumber(args)) { if (areAllStringOrNumber(args)) {
msg = util.format.apply(this, args); msg = util.format.apply(this, args);
//if objects or array present //if objects or array present
} else { } else {
var delimiter = '\n', var delimiter = '\n',
multiLines = false; //if the log need multiples lines (ie. object, array) multiLines = false; //if the log need multiples lines (ie. object, array)
//Process arg one by one //Process arg one by one
args.forEach(function (arg) { args.forEach(function (arg) {
//if arg is an object / array //if arg is an object / array
//use multiples lines //use multiples lines
if (arg !== null && typeof arg === 'object') { if (arg !== null && typeof arg === 'object') {
msg += delimiter; msg += delimiter;
msg += JSON.stringify(arg, null, 2); msg += JSON.stringify(arg, null, 2);
multiLines = true; multiLines = true;
//for "normal" args //for "normal" args
} else { } else {
if (multiLines) { if (multiLines) {
@ -390,7 +390,7 @@
msg += arg + ""; msg += arg + "";
} }
}); });
if (multiLines) { if (multiLines) {
msg += '\n'; msg += '\n';
msg = msg.replace(/\n/gm, '\n' + new Array(this.opt.spaceSize).join(' ')); msg = msg.replace(/\n/gm, '\n' + new Array(this.opt.spaceSize).join(' '));
@ -415,7 +415,7 @@
* @param {Boolean} opt.time Print time ? Default false. * @param {Boolean} opt.time Print time ? Default false.
* @param {Boolean} opt.date Print date ? Default false. * @param {Boolean} opt.date Print date ? Default false.
* *
* @return {Object} * @return {Object}
* @return {String} result * @return {String} result
* @return {Int} length the "human readable" length of the result * @return {Int} length the "human readable" length of the result
*/ */
@ -440,13 +440,13 @@
result += applyColors(tags.msg, log.opt.tagsColors) + space; result += applyColors(tags.msg, log.opt.tagsColors) + space;
length += tags.msgLength + space.length; length += tags.msgLength + space.length;
} }
if (opt.location && log.context.location.filename && log.context.location.line) { if (opt.location && log.context.location.filename && log.context.location.line) {
var infos = buildFileInfos(log.context.location, log.opt.fileColors, log.opt.lineColors); var infos = buildFileInfos(log.context.location, log.opt.fileColors, log.opt.lineColors);
result += infos.msg + space; result += infos.msg + space;
length += infos.msgLength + space.length; length += infos.msgLength + space.length;
} }
if (opt.time && log.context.time) { if (opt.time && log.context.time) {
var time = buildTime(log.context.time); var time = buildTime(log.context.time);
result += applyColors(time.msg, log.opt.timeColors) + space; result += applyColors(time.msg, log.opt.timeColors) + space;
@ -487,7 +487,7 @@
* @param {Array|String} opt.fileColors Default colors output for filename. Default undefined. * @param {Array|String} opt.fileColors Default colors output for filename. Default undefined.
* @param {Array|String} opt.lineColors Default colors output for line number. Default undefined. * @param {Array|String} opt.lineColors Default colors output for line number. Default undefined.
* *
* @param {Boolean} opt.logInConsole Should the logger print to the console ? * @param {Boolean} opt.logInConsole Should the logger print to the console ?
* @param {Boolean} opt.alwaysTags Always print tags (even without tag() ) * @param {Boolean} opt.alwaysTags Always print tags (even without tag() )
* @param {Boolean} opt.alwaysLocation Always print location (even without file() ) * @param {Boolean} opt.alwaysLocation Always print location (even without file() )
* @param {Boolean} opt.alwaysTime Always print time (even without time() ) * @param {Boolean} opt.alwaysTime Always print time (even without time() )
@ -498,14 +498,14 @@
if (!opt) { if (!opt) {
opt = {}; opt = {};
} }
if (!name) { if (!name) {
throw new Error("No name given at addLogger"); throw new Error("No name given at addLogger");
} }
opt.name = name; opt.name = name;
opt.type = opt.type || opt.name; opt.type = opt.type || opt.name;
opt.colors = colors || this.opt.colors; opt.colors = colors || this.opt.colors;
opt.tagsColors = opt.tagsColors || this.opt.tagsColors; opt.tagsColors = opt.tagsColors || this.opt.tagsColors;
opt.timeColors = opt.timeColors || this.opt.timeColors; opt.timeColors = opt.timeColors || this.opt.timeColors;
@ -552,15 +552,15 @@
var context = this.buildContext(log, log.show); var context = this.buildContext(log, log.show);
log.contextString = context.result; log.contextString = context.result;
//Build the args string //Build the args string
log.argsString = this.buildArgs(log); log.argsString = this.buildArgs(log);
//Generate the according number of space between context and args strings //Generate the according number of space between context and args strings
if (context.length > 0) { //if there is context string if (context.length > 0) { //if there is context string
//add space according to the contextMediumSize //add space according to the contextMediumSize
var offset = this.opt.contextMediumSize - context.length; var offset = this.opt.contextMediumSize - context.length;
if (offset < 0) { //context string could be longer than medium size if (offset < 0) { //context string could be longer than medium size
offset = 0; offset = 0;
} }
@ -574,18 +574,18 @@
//Emit events //Emit events
this.emit('new', log, log.type); //'new' event this.emit('new', log, log.type); //'new' event
var msg = log.type; var msg = log.type;
/* /*
* EventEmitter.emit() will raise an Error * EventEmitter.emit() will raise an Error
* if we emit the event 'error' and their is no listeners * if we emit the event 'error' and their is no listeners
* For now, transform 'error' in 'errorEvent' * For now, transform 'error' in 'errorEvent'
*/ */
if (msg === 'error') { if (msg === 'error') {
msg += 'Event'; msg += 'Event';
} }
this.emit(msg, log); //`log.type` event this.emit(msg, log); //`log.type` event
//If the logger should print the message //If the logger should print the message
//Print it //Print it
if (opt.logInConsole) { if (opt.logInConsole) {
@ -604,7 +604,7 @@
//Keep the old console //Keep the old console
//use also `global.console` //use also `global.console`
Console2.prototype.Original = consoleOriginal; Console2.prototype.Original = consoleOriginal;
module.exports = Console2; module.exports = Console2;
}()); }());

View file

@ -7,7 +7,7 @@
/** /**
* logger * logger
* *
* @param {Console2|undefined} console * @param {Console2|undefined} console
* @param {Function|undefined} validate * @param {Function|undefined} validate
*/ */
var logger = function (console, validate) { var logger = function (console, validate) {
@ -26,7 +26,7 @@
} }
return function (req, res, next) { return function (req, res, next) {
if (!validate || validate(req, res)) { if (!validate || validate(req, res)) {
console console
@ -45,7 +45,7 @@
next(); next();
}; };
}; };
module.exports = { module.exports = {

View file

@ -22,13 +22,13 @@
* LogWriter * LogWriter
* *
* Save console logs on disk * Save console logs on disk
* *
* @constructor * @constructor
* *
* @param {String} rootPath root logs folder * @param {String} rootPath root logs folder
*/ */
var LogWriter = function (rootPath) { var LogWriter = function (rootPath) {
this.rootPath = rootPath || 'logs'; this.rootPath = rootPath || 'logs';
//Check if the folder is already in use //Check if the folder is already in use
@ -54,7 +54,7 @@
}; };
var historyPath = path.join(this.rootPath, 'history.json'); var historyPath = path.join(this.rootPath, 'history.json');
if (!fs.existsSync(historyPath)) { //create file if doesn't exist yet if (!fs.existsSync(historyPath)) { //create file if doesn't exist yet
this.writeFile( this.writeFile(
@ -111,26 +111,26 @@
* @param {Function} callback * @param {Function} callback
*/ */
LogWriter.prototype.appendFile = function (pathToFile, content, callback) { LogWriter.prototype.appendFile = function (pathToFile, content, callback) {
var self = this; var self = this;
self.createDir(path.dirname(pathToFile), function (err) { self.createDir(path.dirname(pathToFile), function (err) {
if (err) { if (err) {
callback(err); callback(err);
} else { } else {
var newFile = !fs.existsSync(pathToFile); var newFile = !fs.existsSync(pathToFile);
fs.appendFile(pathToFile, content, function (err) { fs.appendFile(pathToFile, content, function (err) {
if (err) { if (err) {
throw err; throw err;
} else if (newFile) { } else if (newFile) {
self.newFileHistory(pathToFile); self.newFileHistory(pathToFile);
callback(); callback();
} }
}); });
} }
}); });
@ -165,7 +165,7 @@
* *
* Save the new file path in history according to the date * Save the new file path in history according to the date
* *
* @param {String} pathToFile * @param {String} pathToFile
*/ */
LogWriter.prototype.newFileHistory = function (pathToFile) { LogWriter.prototype.newFileHistory = function (pathToFile) {
@ -175,11 +175,11 @@
var today = moment().startOf('day').valueOf().toString(); var today = moment().startOf('day').valueOf().toString();
//Save the path under today key //Save the path under today key
if (!self.history.dates[today]) { if (!self.history.dates[today]) {
self.history.dates[today] = []; self.history.dates[today] = [];
} }
if (self.history.dates[today].indexOf(pathToFile) === -1) { if (self.history.dates[today].indexOf(pathToFile) === -1) {
self.history.dates[today].push(pathToFile); self.history.dates[today].push(pathToFile);
@ -214,11 +214,11 @@
user = userDir.slice(userDir.lastIndexOf(platformDivider) + 1); user = userDir.slice(userDir.lastIndexOf(platformDivider) + 1);
} catch (e) { } catch (e) {
user = 'user'; //default user = 'user'; //default
} finally { } finally {
return user; return user;
} }
@ -233,7 +233,7 @@
* @return {String} The path to current folder (without rootPath) * @return {String} The path to current folder (without rootPath)
*/ */
LogWriter.prototype.getPath = function (opt) { LogWriter.prototype.getPath = function (opt) {
var now = moment(); var now = moment();
return path.join( return path.join(
@ -241,17 +241,17 @@
now.format('MMM') now.format('MMM')
); );
}; };
/** /**
* LogWriter.prototype.getFile * LogWriter.prototype.getFile
* *
* @param {Object} opt params * @param {Object} opt params
* @param {String} opt.logger logger options * @param {String} opt.logger logger options
* *
* @return {String} the filname (with extension) * @return {String} the filname (with extension)
*/ */
LogWriter.prototype.getFile = function (opt) { LogWriter.prototype.getFile = function (opt) {
var now = moment(); var now = moment();
return (now.format('DD_MMM_YY')).toLowerCase() + return (now.format('DD_MMM_YY')).toLowerCase() +
@ -287,8 +287,8 @@
* @param {String} opt.logger logger options * @param {String} opt.logger logger options
*/ */
LogWriter.prototype.save = function (log, opt) { LogWriter.prototype.save = function (log, opt) {
delete log.opt; //we save logger options in rootPath/[logger].json delete log.opt; //we save logger options in rootPath/[logger].json
var json = JSON.stringify(log); var json = JSON.stringify(log);
@ -330,7 +330,7 @@
this.saveOpt(logger); this.saveOpt(logger);
}; };
module.exports = { module.exports = {
LogWriter : LogWriter, LogWriter : LogWriter,

View file

@ -14,13 +14,13 @@
* *
* Custom map function * Custom map function
* That filter undefined and null values * That filter undefined and null values
* *
* @param {Array} arr * @param {Array} arr
* @param {Function} callback * @param {Function} callback
* @return {Array} * @return {Array}
*/ */
var map = function (arr, callback) { var map = function (arr, callback) {
var result = arr.map(callback); var result = arr.map(callback);
return result.filter(function (item) { return result.filter(function (item) {
return item !== undefined && item !== null; return item !== undefined && item !== null;
@ -47,7 +47,7 @@
webPanel.use('/', serveStatic('./static')); webPanel.use('/', serveStatic('./static'));
//API //API
/** /**
* readDir * readDir
* *
@ -76,7 +76,7 @@
}); });
} }
}; };
/** /**
@ -91,7 +91,7 @@
* @return {String} path @see params * @return {String} path @see params
*/ */
var readNode = function (itemPath) { var readNode = function (itemPath) {
var info = fs.statSync(itemPath), var info = fs.statSync(itemPath),
item = {}; item = {};
@ -109,7 +109,7 @@
*/ */
var getLogFolders = function () { var getLogFolders = function () {
return map(consoles, function (elem) { return map(consoles, function (elem) {
return elem.logWriter.rootPath || undefined; return elem.logWriter.rootPath || undefined;
}); });
}; };
@ -127,7 +127,7 @@
if (item.logWriter && item.logWriter.rootPath === logFolder) { if (item.logWriter && item.logWriter.rootPath === logFolder) {
logWriter = item.logWriter; logWriter = item.logWriter;
return true; return true;
} }
}) ? logWriter : false; }) ? logWriter : false;
}; };
@ -151,7 +151,7 @@
* Send path content info * Send path content info
*/ */
webPanel.get('/api/folderExplorer', function (req, res) { webPanel.get('/api/folderExplorer', function (req, res) {
var path = req.query.path; var path = req.query.path;
readDir(path, function (err, dir) { readDir(path, function (err, dir) {
@ -180,13 +180,13 @@
if (!logWriter) { if (!logWriter) {
res.status(400).send('No logWriter attached to ' + logFolder); res.status(400).send('No logWriter attached to ' + logFolder);
} else { } else {
//Find the good dates //Find the good dates
var nb = 0, var nb = 0,
result = [], result = [],
dates = Object.keys(logWriter.history.dates).filter(function (date) { dates = Object.keys(logWriter.history.dates).filter(function (date) {
if (date < from && nb <= length) { if (date < from && nb <= length) {
nb++; nb++;
return date; return date;
@ -195,7 +195,7 @@
} }
}); });
dates.forEach(function (date) { dates.forEach(function (date) {
result.push({ result.push({
date : date, date : date,
@ -242,7 +242,7 @@
}; };
module.exports = initWebPanel; module.exports = initWebPanel;

View file

@ -17,7 +17,7 @@
* *
* @param {Object} scribeOpt Optional options * @param {Object} scribeOpt Optional options
* @param {String} scribe.rootPath Logs folder. Default 'logs' * @param {String} scribe.rootPath Logs folder. Default 'logs'
* @param {Boolean} scribeOpt.createDefaultConsole Should scribe attach a fresh Console2 * @param {Boolean} scribeOpt.createDefaultConsole Should scribe attach a fresh Console2
* to process.console ? Default true. * to process.console ? Default true.
* *
* @return {Object} * @return {Object}
@ -25,11 +25,12 @@
* @return {Function} webPanel Get an express Router * @return {Function} webPanel Get an express Router
* @return {Constructor} Console2 Console2 constructor * @return {Constructor} Console2 Console2 constructor
* @return {Constructor} LogWriter LogWriter constructor * @return {Constructor} LogWriter LogWriter constructor
* @return {Object} express Express utils
*/ */
var scribe = function (scribeOpt) { var scribe = function (scribeOpt) {
//Scribe options //Scribe options
if (!scribeOpt) { if (!scribeOpt) {
scribeOpt = {}; scribeOpt = {};
} }
@ -61,7 +62,7 @@
//On new log, save it //On new log, save it
console2.on('new', function (log) { console2.on('new', function (log) {
logWriter.save(log, { logWriter.save(log, {
logger : log.opt logger : log.opt
}); });
@ -69,7 +70,7 @@
}); });
//On new logger, save its options //On new logger, save its options
console2.on('newLogger', function (logger, loggerOpt) { console2.on('newLogger', function (logger, loggerOpt) {
logWriter.addLogger(loggerOpt); logWriter.addLogger(loggerOpt);
@ -81,7 +82,7 @@
* createBasic * createBasic
* *
* Create basic log function of nodejs for `console` * Create basic log function of nodejs for `console`
* *
* @param {Console2} console * @param {Console2} console
*/ */
var createBasic = function (console) { var createBasic = function (console) {
@ -89,7 +90,7 @@
var loggers = [ var loggers = [
{ {
name : 'log', name : 'log',
color : 'white' color : 'white'
}, },
{ {
name : 'info', name : 'info',
@ -124,7 +125,7 @@
* @param {?Object} config.console Console2 options * @param {?Object} config.console Console2 options
* @param {?Object} config.logWriter LogWriter options. * @param {?Object} config.logWriter LogWriter options.
* If false, Scribe won't save logs on disk. * If false, Scribe won't save logs on disk.
* @param {Boolean} config.createBasic Should scribe create basic logging functions ? * @param {Boolean} config.createBasic Should scribe create basic logging functions ?
* Default true * Default true
* *
* @param {LogWriter} logWriter Optional. A custom logWriter instance * @param {LogWriter} logWriter Optional. A custom logWriter instance
@ -161,7 +162,7 @@
consoles.push({ consoles.push({
console : console, console : console,
logWriter : config.logWriter !== false ? logWriter : null logWriter : config.logWriter !== false ? logWriter : null
}); });
//Create basic logging functions //Create basic logging functions
@ -180,12 +181,12 @@
* @return an express Router * @return an express Router
*/ */
var initWebPanel = function () { var initWebPanel = function () {
return webPanel(consoles); return webPanel(consoles);
}; };
//Create a default console2 and attach it to process //Create a default console2 and attach it to process
if (scribeOpt.createDefaultConsole) { if (scribeOpt.createDefaultConsole) {
process.console = addConsole(); process.console = addConsole();
@ -231,7 +232,7 @@
*/ */
LogWriter : LogWriter LogWriter : LogWriter
}; };
}; };
module.exports = scribe; module.exports = scribe;