|
|
|
@ -56,14 +56,14 @@ module.exports = function (fileSystem, standardOutput, configPaths) {
|
|
|
|
|
loggers = {},
|
|
|
|
|
appenders = {},
|
|
|
|
|
levels = {
|
|
|
|
|
ALL: new Level(Number.MIN_VALUE, "ALL"),
|
|
|
|
|
TRACE: new Level(5000, "TRACE"),
|
|
|
|
|
DEBUG: new Level(10000, "DEBUG"),
|
|
|
|
|
INFO: new Level(20000, "INFO"),
|
|
|
|
|
WARN: new Level(30000, "WARN"),
|
|
|
|
|
ERROR: new Level(40000, "ERROR"),
|
|
|
|
|
FATAL: new Level(50000, "FATAL"),
|
|
|
|
|
OFF: new Level(Number.MAX_VALUE, "OFF")
|
|
|
|
|
ALL: new Level(Number.MIN_VALUE, "ALL", "grey"),
|
|
|
|
|
TRACE: new Level(5000, "TRACE", "blue"),
|
|
|
|
|
DEBUG: new Level(10000, "DEBUG", "cyan"),
|
|
|
|
|
INFO: new Level(20000, "INFO", "green"),
|
|
|
|
|
WARN: new Level(30000, "WARN", "yellow"),
|
|
|
|
|
ERROR: new Level(40000, "ERROR", "red"),
|
|
|
|
|
FATAL: new Level(50000, "FATAL", "magenta"),
|
|
|
|
|
OFF: new Level(Number.MAX_VALUE, "OFF", "grey")
|
|
|
|
|
},
|
|
|
|
|
appenderMakers = {
|
|
|
|
|
"file": function(config) {
|
|
|
|
@ -226,9 +226,10 @@ module.exports = function (fileSystem, standardOutput, configPaths) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Level(level, levelStr) {
|
|
|
|
|
function Level(level, levelStr, colour) {
|
|
|
|
|
this.level = level;
|
|
|
|
|
this.levelStr = levelStr;
|
|
|
|
|
this.colour = colour;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -334,7 +335,7 @@ module.exports = function (fileSystem, standardOutput, configPaths) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function consoleAppender (layout) {
|
|
|
|
|
layout = layout || basicLayout;
|
|
|
|
|
layout = layout || colouredLayout;
|
|
|
|
|
return function(loggingEvent) {
|
|
|
|
|
standardOutput(layout(loggingEvent));
|
|
|
|
|
};
|
|
|
|
@ -394,6 +395,57 @@ module.exports = function (fileSystem, standardOutput, configPaths) {
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Taken from masylum's fork (https://github.com/masylum/log4js-node)
|
|
|
|
|
*/
|
|
|
|
|
function colorize (str, style) {
|
|
|
|
|
var styles = {
|
|
|
|
|
//styles
|
|
|
|
|
'bold' : [1, 22],
|
|
|
|
|
'italic' : [3, 23],
|
|
|
|
|
'underline' : [4, 24],
|
|
|
|
|
'inverse' : [7, 27],
|
|
|
|
|
//grayscale
|
|
|
|
|
'white' : [37, 39],
|
|
|
|
|
'grey' : [90, 39],
|
|
|
|
|
'black' : [90, 39],
|
|
|
|
|
//colors
|
|
|
|
|
'blue' : [34, 39],
|
|
|
|
|
'cyan' : [36, 39],
|
|
|
|
|
'green' : [32, 39],
|
|
|
|
|
'magenta' : [35, 39],
|
|
|
|
|
'red' : [31, 39],
|
|
|
|
|
'yellow' : [33, 39]
|
|
|
|
|
};
|
|
|
|
|
return '\033[' + styles[style][0] + 'm' + str +
|
|
|
|
|
'\033[' + styles[style][1] + 'm';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* colouredLayout - taken from masylum's fork.
|
|
|
|
|
* same as basicLayout, but with colours.
|
|
|
|
|
*/
|
|
|
|
|
function colouredLayout (loggingEvent) {
|
|
|
|
|
var timestampLevelAndCategory = colorize('[' + loggingEvent.startTime.toFormattedString() + '] ', 'grey');
|
|
|
|
|
timestampLevelAndCategory += colorize(
|
|
|
|
|
'[' + loggingEvent.level.toString() + '] ', loggingEvent.level.colour
|
|
|
|
|
);
|
|
|
|
|
timestampLevelAndCategory += colorize(loggingEvent.categoryName + ' - ', 'grey');
|
|
|
|
|
|
|
|
|
|
var output = timestampLevelAndCategory + loggingEvent.message;
|
|
|
|
|
|
|
|
|
|
if (loggingEvent.exception) {
|
|
|
|
|
output += '\n'
|
|
|
|
|
output += timestampLevelAndCategory;
|
|
|
|
|
if (loggingEvent.exception.stack) {
|
|
|
|
|
output += loggingEvent.exception.stack;
|
|
|
|
|
} else {
|
|
|
|
|
output += loggingEvent.exception.name + ': '+loggingEvent.exception.message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function messagePassThroughLayout (loggingEvent) {
|
|
|
|
|
return loggingEvent.message;
|
|
|
|
|
}
|
|
|
|
@ -533,7 +585,9 @@ module.exports = function (fileSystem, standardOutput, configPaths) {
|
|
|
|
|
|
|
|
|
|
basicLayout: basicLayout,
|
|
|
|
|
messagePassThroughLayout: messagePassThroughLayout,
|
|
|
|
|
patternLayout: patternLayout
|
|
|
|
|
patternLayout: patternLayout,
|
|
|
|
|
colouredLayout: colouredLayout,
|
|
|
|
|
coloredLayout: colouredLayout
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|