forked from mirrors/Scribe.js
Create basic loggers
This commit is contained in:
parent
cd4d49c6b4
commit
2854d0f072
1 changed files with 46 additions and 1 deletions
47
scribe.js
47
scribe.js
|
@ -19,6 +19,8 @@
|
||||||
* @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.
|
||||||
|
* @param {Boolean} scribeOpt.createBasic Should scribe create basic logging functions ?
|
||||||
|
* Default true
|
||||||
*
|
*
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
* @return {Function} console Get a console
|
* @return {Function} console Get a console
|
||||||
|
@ -36,6 +38,7 @@
|
||||||
|
|
||||||
scribeOpt.rootPath = scribeOpt.rootPath || 'logs';
|
scribeOpt.rootPath = scribeOpt.rootPath || 'logs';
|
||||||
scribeOpt.createDefaultConsole = scribeOpt.createDefaultConsole !== false;
|
scribeOpt.createDefaultConsole = scribeOpt.createDefaultConsole !== false;
|
||||||
|
scribeOpt.createBasic = scribeOpt.createBasic !== false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,11 +128,48 @@
|
||||||
return console;
|
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
|
* initWebPanel
|
||||||
*
|
*
|
||||||
* Retrun an express Router
|
* @return an express Router
|
||||||
*/
|
*/
|
||||||
var initWebPanel = function () {
|
var initWebPanel = function () {
|
||||||
|
|
||||||
|
@ -143,6 +183,11 @@
|
||||||
process.console = addConsole();
|
process.console = addConsole();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Create basic logging functions
|
||||||
|
if (scribeOpt.createBasic) {
|
||||||
|
createBasic(process.console);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue