mirror of
https://github.com/mathew-kurian/Scribe.js
synced 2025-04-24 14:25:00 +00:00
Remove trailing whitespace
This commit is contained in:
parent
0d819ff30f
commit
d7c05d3f9a
11 changed files with 109 additions and 108 deletions
|
@ -8,13 +8,13 @@
|
|||
//Create a Console2 for express
|
||||
//with logs saved in /expressLogger
|
||||
var expressConsole = scribe.console({
|
||||
console : {
|
||||
console : {
|
||||
colors : 'white',
|
||||
timeColors : ['grey', 'underline'],
|
||||
},
|
||||
createBasic : false,
|
||||
logWriter : {
|
||||
rootPath : 'expressLogger'
|
||||
rootPath : 'expressLogger'
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
|||
// return false //ie. don't log this request
|
||||
//else
|
||||
//{
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ var moment = require('moment'),
|
|||
path = require('path');
|
||||
|
||||
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
|
||||
|
||||
myLogWriter.getPath = function (opt) {
|
||||
|
||||
|
||||
return path.join(
|
||||
this.getUser(),
|
||||
opt.logger.name
|
||||
);
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ myLogWriter.getFilename = function (opt) {
|
|||
'.' +
|
||||
opt.logger.name +
|
||||
'.json';
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -72,8 +72,8 @@ var consoleThree = scribe.console({
|
|||
|
||||
|
||||
/**
|
||||
* Use the consoles
|
||||
*
|
||||
* Use the consoles
|
||||
*
|
||||
* Then check logsConsoleOne and logsConsoleTwo folders
|
||||
*/
|
||||
|
||||
|
|
|
@ -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
|
||||
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` ...
|
||||
console.addLogger('myLogger');
|
||||
|
@ -22,5 +22,5 @@ console.tag('MyTag').time().file().myLogger('Scribe.js is awesome');
|
|||
|
||||
//By default, submodules still use original console
|
||||
require('./sub-without_new_console').saySomething("Hello world !");
|
||||
//But, you can use the new one !
|
||||
require('./sub-with_new_console').saySomething("Hello world !");
|
||||
//But, you can use the new one !
|
||||
require('./sub-with_new_console').saySomething("Hello world !");
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
var console = process.console;
|
||||
|
||||
module.exports = {
|
||||
|
||||
|
||||
saySomething : function (msg) {
|
||||
msg = "With new console - " + msg;
|
||||
console.myLogger(msg); //I'm using my custom logger `myLogger`
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//so it doesn't break dependencies logging
|
||||
|
||||
module.exports = {
|
||||
|
||||
|
||||
saySomething : function (msg) {
|
||||
msg = "Without new console - " + msg;
|
||||
console.log(msg);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* jshint -W079 */
|
||||
(function () {
|
||||
(function () {
|
||||
var scribe = require('../scribe')(),
|
||||
console = process.console,
|
||||
express = require('express'),
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* @return {Number} line
|
||||
*/
|
||||
var getLocation = function () {
|
||||
|
||||
|
||||
var st = stack()[2],
|
||||
result = {};
|
||||
|
||||
|
@ -42,9 +42,9 @@
|
|||
*
|
||||
* @param {timestamp} timestamp
|
||||
*
|
||||
* @return {Object}
|
||||
* @return {Object}
|
||||
* @return {String} msg ISO time
|
||||
* @return {int} msgLength
|
||||
* @return {int} msgLength
|
||||
*/
|
||||
var buildTime = function (timestamp) {
|
||||
var time = (new Date(timestamp)).toISOString();
|
||||
|
@ -59,9 +59,9 @@
|
|||
*
|
||||
* @param {timestamp} timestamp
|
||||
*
|
||||
* @return {Object}
|
||||
* @return {Object}
|
||||
* @return {String} msg Date to string
|
||||
* @return {int} msgLength
|
||||
* @return {int} msgLength
|
||||
*/
|
||||
var buildDate = function (timestamp) {
|
||||
var date = (new Date(timestamp)).toDateString();
|
||||
|
@ -76,19 +76,19 @@
|
|||
*
|
||||
* @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 {int} msgLength Tags string length (without colors elements)
|
||||
*/
|
||||
var buildTags = function (tags) {
|
||||
|
||||
|
||||
var result = "",
|
||||
length = 0;
|
||||
|
||||
tags.forEach(function (tag) {
|
||||
if (tag !== null && typeof tag === 'object') {
|
||||
result += applyColors('[' + tag.msg + ']', tag.colors);
|
||||
length += ("" + tag.msg).length + 2;
|
||||
length += ("" + tag.msg).length + 2;
|
||||
} else {
|
||||
result += '[' + tag + ']';
|
||||
length += ("" + tag).length + 2;
|
||||
|
@ -107,13 +107,13 @@
|
|||
* @param {Object} infos
|
||||
* @param {String} infos.filename
|
||||
* @param {String} infos.line
|
||||
*
|
||||
*
|
||||
* @param {String|Array} fileColors Optional colors.
|
||||
* @param {String|Array} lineColors Optional colors.
|
||||
*
|
||||
* @return {Object}
|
||||
* @return {Object}
|
||||
* @return {String} msg File infos with colors if given
|
||||
* @return {int} msgLength
|
||||
* @return {int} msgLength
|
||||
*/
|
||||
var buildFileInfos = function (infos, fileColors, lineColors) {
|
||||
var result = '[' +
|
||||
|
@ -187,14 +187,14 @@
|
|||
* @param {int} opt.contextMediumSize Medium size of the context part of a log message.
|
||||
* Used when calculating indent. Default to 45.
|
||||
* @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.tagsColors Default colors output for tags. 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.fileColors Default colors output for filename. 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.alwaysLocation Always print location (even without file() ). Default false.
|
||||
* @param {Boolean} opt.alwaysTime Always print time (even without time() ). Default false.
|
||||
|
@ -235,29 +235,29 @@
|
|||
* _tags
|
||||
*
|
||||
* Store all tags for current log
|
||||
*
|
||||
*
|
||||
* @type {Array}
|
||||
*/
|
||||
this._tags = [];
|
||||
|
||||
|
||||
/**
|
||||
*._time
|
||||
*
|
||||
* Log time (full date) ?
|
||||
*
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this._time = false;
|
||||
|
||||
|
||||
/**
|
||||
* _date
|
||||
*
|
||||
* Log date ?
|
||||
*
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this._date = false;
|
||||
|
||||
|
||||
/**
|
||||
* _location
|
||||
*
|
||||
|
@ -265,7 +265,7 @@
|
|||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this._location = false;
|
||||
this._location = false;
|
||||
|
||||
/**
|
||||
* _reset
|
||||
|
@ -277,10 +277,10 @@
|
|||
this._time = false;
|
||||
this._date = false;
|
||||
this._location = false;
|
||||
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* loggers
|
||||
*
|
||||
|
@ -288,7 +288,7 @@
|
|||
* @type {Object}
|
||||
*/
|
||||
this.loggers = {};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -330,7 +330,7 @@
|
|||
Console2.prototype.tag = Console2.prototype.t = function () {
|
||||
var tags = Array.prototype.slice.call(arguments, 0);
|
||||
this._tags = this._tags.concat(tags);
|
||||
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
@ -361,27 +361,27 @@
|
|||
|
||||
//if all args are string or number, format args as usual
|
||||
if (areAllStringOrNumber(args)) {
|
||||
msg = util.format.apply(this, args);
|
||||
msg = util.format.apply(this, args);
|
||||
|
||||
//if objects or array present
|
||||
} else {
|
||||
|
||||
} else {
|
||||
|
||||
var delimiter = '\n',
|
||||
multiLines = false; //if the log need multiples lines (ie. object, array)
|
||||
|
||||
//Process arg one by one
|
||||
args.forEach(function (arg) {
|
||||
|
||||
|
||||
//if arg is an object / array
|
||||
//use multiples lines
|
||||
if (arg !== null && typeof arg === 'object') {
|
||||
|
||||
|
||||
msg += delimiter;
|
||||
|
||||
|
||||
msg += JSON.stringify(arg, null, 2);
|
||||
|
||||
|
||||
multiLines = true;
|
||||
|
||||
|
||||
//for "normal" args
|
||||
} else {
|
||||
if (multiLines) {
|
||||
|
@ -390,7 +390,7 @@
|
|||
msg += arg + "";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (multiLines) {
|
||||
msg += '\n';
|
||||
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.date Print date ? Default false.
|
||||
*
|
||||
* @return {Object}
|
||||
* @return {Object}
|
||||
* @return {String} result
|
||||
* @return {Int} length the "human readable" length of the result
|
||||
*/
|
||||
|
@ -440,13 +440,13 @@
|
|||
result += applyColors(tags.msg, log.opt.tagsColors) + space;
|
||||
length += tags.msgLength + space.length;
|
||||
}
|
||||
|
||||
|
||||
if (opt.location && log.context.location.filename && log.context.location.line) {
|
||||
var infos = buildFileInfos(log.context.location, log.opt.fileColors, log.opt.lineColors);
|
||||
result += infos.msg + space;
|
||||
length += infos.msgLength + space.length;
|
||||
}
|
||||
|
||||
|
||||
if (opt.time && log.context.time) {
|
||||
var time = buildTime(log.context.time);
|
||||
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.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.alwaysLocation Always print location (even without file() )
|
||||
* @param {Boolean} opt.alwaysTime Always print time (even without time() )
|
||||
|
@ -498,14 +498,14 @@
|
|||
if (!opt) {
|
||||
opt = {};
|
||||
}
|
||||
|
||||
|
||||
if (!name) {
|
||||
throw new Error("No name given at addLogger");
|
||||
}
|
||||
|
||||
opt.name = name;
|
||||
opt.type = opt.type || opt.name;
|
||||
|
||||
|
||||
opt.colors = colors || this.opt.colors;
|
||||
opt.tagsColors = opt.tagsColors || this.opt.tagsColors;
|
||||
opt.timeColors = opt.timeColors || this.opt.timeColors;
|
||||
|
@ -552,15 +552,15 @@
|
|||
var context = this.buildContext(log, log.show);
|
||||
|
||||
log.contextString = context.result;
|
||||
|
||||
|
||||
//Build the args string
|
||||
log.argsString = this.buildArgs(log);
|
||||
|
||||
//Generate the according number of space between context and args strings
|
||||
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;
|
||||
|
||||
|
||||
if (offset < 0) { //context string could be longer than medium size
|
||||
offset = 0;
|
||||
}
|
||||
|
@ -574,18 +574,18 @@
|
|||
//Emit events
|
||||
this.emit('new', log, log.type); //'new' event
|
||||
|
||||
var msg = log.type;
|
||||
var msg = log.type;
|
||||
|
||||
/*
|
||||
/*
|
||||
* EventEmitter.emit() will raise an Error
|
||||
* if we emit the event 'error' and their is no listeners
|
||||
* For now, transform 'error' in 'errorEvent'
|
||||
*/
|
||||
if (msg === 'error') {
|
||||
msg += 'Event';
|
||||
msg += 'Event';
|
||||
}
|
||||
this.emit(msg, log); //`log.type` event
|
||||
|
||||
|
||||
//If the logger should print the message
|
||||
//Print it
|
||||
if (opt.logInConsole) {
|
||||
|
@ -604,7 +604,7 @@
|
|||
//Keep the old console
|
||||
//use also `global.console`
|
||||
Console2.prototype.Original = consoleOriginal;
|
||||
|
||||
|
||||
module.exports = Console2;
|
||||
|
||||
}());
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
/**
|
||||
* logger
|
||||
*
|
||||
* @param {Console2|undefined} console
|
||||
* @param {Console2|undefined} console
|
||||
* @param {Function|undefined} validate
|
||||
*/
|
||||
var logger = function (console, validate) {
|
||||
|
@ -26,7 +26,7 @@
|
|||
}
|
||||
|
||||
return function (req, res, next) {
|
||||
|
||||
|
||||
if (!validate || validate(req, res)) {
|
||||
|
||||
console
|
||||
|
@ -45,7 +45,7 @@
|
|||
|
||||
next();
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
* LogWriter
|
||||
*
|
||||
* Save console logs on disk
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} rootPath root logs folder
|
||||
*/
|
||||
var LogWriter = function (rootPath) {
|
||||
|
||||
|
||||
this.rootPath = rootPath || 'logs';
|
||||
|
||||
//Check if the folder is already in use
|
||||
|
@ -54,7 +54,7 @@
|
|||
};
|
||||
|
||||
var historyPath = path.join(this.rootPath, 'history.json');
|
||||
|
||||
|
||||
if (!fs.existsSync(historyPath)) { //create file if doesn't exist yet
|
||||
|
||||
this.writeFile(
|
||||
|
@ -111,26 +111,26 @@
|
|||
* @param {Function} callback
|
||||
*/
|
||||
LogWriter.prototype.appendFile = function (pathToFile, content, callback) {
|
||||
|
||||
|
||||
var self = this;
|
||||
|
||||
|
||||
self.createDir(path.dirname(pathToFile), function (err) {
|
||||
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
|
||||
|
||||
var newFile = !fs.existsSync(pathToFile);
|
||||
|
||||
fs.appendFile(pathToFile, content, function (err) {
|
||||
|
||||
|
||||
if (err) {
|
||||
throw err;
|
||||
} else if (newFile) {
|
||||
self.newFileHistory(pathToFile);
|
||||
callback();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -165,7 +165,7 @@
|
|||
*
|
||||
* Save the new file path in history according to the date
|
||||
*
|
||||
* @param {String} pathToFile
|
||||
* @param {String} pathToFile
|
||||
*/
|
||||
LogWriter.prototype.newFileHistory = function (pathToFile) {
|
||||
|
||||
|
@ -175,11 +175,11 @@
|
|||
var today = moment().startOf('day').valueOf().toString();
|
||||
|
||||
//Save the path under today key
|
||||
|
||||
|
||||
if (!self.history.dates[today]) {
|
||||
self.history.dates[today] = [];
|
||||
}
|
||||
|
||||
|
||||
if (self.history.dates[today].indexOf(pathToFile) === -1) {
|
||||
|
||||
self.history.dates[today].push(pathToFile);
|
||||
|
@ -214,11 +214,11 @@
|
|||
user = userDir.slice(userDir.lastIndexOf(platformDivider) + 1);
|
||||
|
||||
} catch (e) {
|
||||
|
||||
|
||||
user = 'user'; //default
|
||||
|
||||
} finally {
|
||||
|
||||
|
||||
return user;
|
||||
|
||||
}
|
||||
|
@ -233,7 +233,7 @@
|
|||
* @return {String} The path to current folder (without rootPath)
|
||||
*/
|
||||
LogWriter.prototype.getPath = function (opt) {
|
||||
|
||||
|
||||
var now = moment();
|
||||
|
||||
return path.join(
|
||||
|
@ -241,17 +241,17 @@
|
|||
now.format('MMM')
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* LogWriter.prototype.getFile
|
||||
*
|
||||
*
|
||||
* @param {Object} opt params
|
||||
* @param {String} opt.logger logger options
|
||||
*
|
||||
* @return {String} the filname (with extension)
|
||||
*/
|
||||
LogWriter.prototype.getFile = function (opt) {
|
||||
|
||||
|
||||
var now = moment();
|
||||
|
||||
return (now.format('DD_MMM_YY')).toLowerCase() +
|
||||
|
@ -287,8 +287,8 @@
|
|||
* @param {String} opt.logger logger options
|
||||
*/
|
||||
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);
|
||||
|
||||
|
@ -330,7 +330,7 @@
|
|||
|
||||
this.saveOpt(logger);
|
||||
};
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
LogWriter : LogWriter,
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
*
|
||||
* Custom map function
|
||||
* That filter undefined and null values
|
||||
*
|
||||
*
|
||||
* @param {Array} arr
|
||||
* @param {Function} callback
|
||||
* @return {Array}
|
||||
*/
|
||||
var map = function (arr, callback) {
|
||||
|
||||
|
||||
var result = arr.map(callback);
|
||||
return result.filter(function (item) {
|
||||
return item !== undefined && item !== null;
|
||||
|
@ -47,7 +47,7 @@
|
|||
webPanel.use('/', serveStatic('./static'));
|
||||
|
||||
//API
|
||||
|
||||
|
||||
/**
|
||||
* readDir
|
||||
*
|
||||
|
@ -76,7 +76,7 @@
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -91,7 +91,7 @@
|
|||
* @return {String} path @see params
|
||||
*/
|
||||
var readNode = function (itemPath) {
|
||||
|
||||
|
||||
var info = fs.statSync(itemPath),
|
||||
item = {};
|
||||
|
||||
|
@ -109,7 +109,7 @@
|
|||
*/
|
||||
var getLogFolders = function () {
|
||||
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) {
|
||||
logWriter = item.logWriter;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}) ? logWriter : false;
|
||||
|
||||
};
|
||||
|
@ -151,7 +151,7 @@
|
|||
* Send path content info
|
||||
*/
|
||||
webPanel.get('/api/folderExplorer', function (req, res) {
|
||||
|
||||
|
||||
var path = req.query.path;
|
||||
|
||||
readDir(path, function (err, dir) {
|
||||
|
@ -180,13 +180,13 @@
|
|||
if (!logWriter) {
|
||||
res.status(400).send('No logWriter attached to ' + logFolder);
|
||||
} else {
|
||||
|
||||
|
||||
//Find the good dates
|
||||
|
||||
var nb = 0,
|
||||
result = [],
|
||||
dates = Object.keys(logWriter.history.dates).filter(function (date) {
|
||||
|
||||
|
||||
if (date < from && nb <= length) {
|
||||
nb++;
|
||||
return date;
|
||||
|
@ -195,7 +195,7 @@
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
dates.forEach(function (date) {
|
||||
result.push({
|
||||
date : date,
|
||||
|
@ -242,7 +242,7 @@
|
|||
|
||||
};
|
||||
|
||||
|
||||
|
||||
module.exports = initWebPanel;
|
||||
|
||||
|
||||
|
|
23
scribe.js
23
scribe.js
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* @param {Object} scribeOpt Optional options
|
||||
* @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.
|
||||
*
|
||||
* @return {Object}
|
||||
|
@ -25,11 +25,12 @@
|
|||
* @return {Function} webPanel Get an express Router
|
||||
* @return {Constructor} Console2 Console2 constructor
|
||||
* @return {Constructor} LogWriter LogWriter constructor
|
||||
* @return {Object} express Express utils
|
||||
*/
|
||||
var scribe = function (scribeOpt) {
|
||||
|
||||
//Scribe options
|
||||
|
||||
|
||||
if (!scribeOpt) {
|
||||
scribeOpt = {};
|
||||
}
|
||||
|
@ -61,7 +62,7 @@
|
|||
|
||||
//On new log, save it
|
||||
console2.on('new', function (log) {
|
||||
|
||||
|
||||
logWriter.save(log, {
|
||||
logger : log.opt
|
||||
});
|
||||
|
@ -69,7 +70,7 @@
|
|||
});
|
||||
|
||||
//On new logger, save its options
|
||||
console2.on('newLogger', function (logger, loggerOpt) {
|
||||
console2.on('newLogger', function (logger, loggerOpt) {
|
||||
|
||||
logWriter.addLogger(loggerOpt);
|
||||
|
||||
|
@ -81,7 +82,7 @@
|
|||
* createBasic
|
||||
*
|
||||
* Create basic log function of nodejs for `console`
|
||||
*
|
||||
*
|
||||
* @param {Console2} console
|
||||
*/
|
||||
var createBasic = function (console) {
|
||||
|
@ -89,7 +90,7 @@
|
|||
var loggers = [
|
||||
{
|
||||
name : 'log',
|
||||
color : 'white'
|
||||
color : 'white'
|
||||
},
|
||||
{
|
||||
name : 'info',
|
||||
|
@ -124,7 +125,7 @@
|
|||
* @param {?Object} config.console Console2 options
|
||||
* @param {?Object} config.logWriter LogWriter options.
|
||||
* 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
|
||||
*
|
||||
* @param {LogWriter} logWriter Optional. A custom logWriter instance
|
||||
|
@ -161,7 +162,7 @@
|
|||
|
||||
consoles.push({
|
||||
console : console,
|
||||
logWriter : config.logWriter !== false ? logWriter : null
|
||||
logWriter : config.logWriter !== false ? logWriter : null
|
||||
});
|
||||
|
||||
//Create basic logging functions
|
||||
|
@ -180,12 +181,12 @@
|
|||
* @return an express Router
|
||||
*/
|
||||
var initWebPanel = function () {
|
||||
|
||||
|
||||
return webPanel(consoles);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
//Create a default console2 and attach it to process
|
||||
if (scribeOpt.createDefaultConsole) {
|
||||
process.console = addConsole();
|
||||
|
@ -231,7 +232,7 @@
|
|||
*/
|
||||
LogWriter : LogWriter
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = scribe;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue