commit
70a9444f4d
@ -125,6 +125,7 @@ function messagePassThroughLayout (loggingEvent) {
|
|||||||
* - %d date in various formats
|
* - %d date in various formats
|
||||||
* - %% %
|
* - %% %
|
||||||
* - %n newline
|
* - %n newline
|
||||||
|
* - %z pid
|
||||||
* - %x{<tokenname>} add dynamic tokens to your log. Tokens are specified in the tokens parameter
|
* - %x{<tokenname>} add dynamic tokens to your log. Tokens are specified in the tokens parameter
|
||||||
* You can use %[ and %] to define a colored block.
|
* You can use %[ and %] to define a colored block.
|
||||||
*
|
*
|
||||||
@ -144,7 +145,7 @@ function messagePassThroughLayout (loggingEvent) {
|
|||||||
*/
|
*/
|
||||||
function patternLayout (pattern, tokens) {
|
function patternLayout (pattern, tokens) {
|
||||||
var TTCC_CONVERSION_PATTERN = "%r %p %c - %m%n";
|
var TTCC_CONVERSION_PATTERN = "%r %p %c - %m%n";
|
||||||
var regex = /%(-?[0-9]+)?(\.?[0-9]+)?([\[\]cdhmnprx%])(\{([^\}]+)\})?|([^%]+)/;
|
var regex = /%(-?[0-9]+)?(\.?[0-9]+)?([\[\]cdhmnprzx%])(\{([^\}]+)\})?|([^%]+)/;
|
||||||
|
|
||||||
pattern = pattern || TTCC_CONVERSION_PATTERN;
|
pattern = pattern || TTCC_CONVERSION_PATTERN;
|
||||||
|
|
||||||
@ -211,6 +212,10 @@ function patternLayout (pattern, tokens) {
|
|||||||
return '%';
|
return '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pid() {
|
||||||
|
return process.pid;
|
||||||
|
}
|
||||||
|
|
||||||
function userDefined(loggingEvent, specifier) {
|
function userDefined(loggingEvent, specifier) {
|
||||||
if (typeof(tokens[specifier]) !== 'undefined') {
|
if (typeof(tokens[specifier]) !== 'undefined') {
|
||||||
if (typeof(tokens[specifier]) === 'function') {
|
if (typeof(tokens[specifier]) === 'function') {
|
||||||
@ -232,6 +237,7 @@ function patternLayout (pattern, tokens) {
|
|||||||
'r': startTime,
|
'r': startTime,
|
||||||
'[': startColour,
|
'[': startColour,
|
||||||
']': endColour,
|
']': endColour,
|
||||||
|
'z': pid,
|
||||||
'%': percent,
|
'%': percent,
|
||||||
'x': userDefined
|
'x': userDefined
|
||||||
};
|
};
|
||||||
|
@ -217,6 +217,9 @@ vows.describe('log4js layouts').addBatch({
|
|||||||
'%h should output hostname' : function(args) {
|
'%h should output hostname' : function(args) {
|
||||||
test(args, '%h', os.hostname().toString());
|
test(args, '%h', os.hostname().toString());
|
||||||
},
|
},
|
||||||
|
'%z should output pid' : function(args) {
|
||||||
|
test(args, '%z', process.pid);
|
||||||
|
},
|
||||||
'%c should handle category names like java-style package names': function(args) {
|
'%c should handle category names like java-style package names': function(args) {
|
||||||
test(args, '%c{1}', 'tests');
|
test(args, '%c{1}', 'tests');
|
||||||
test(args, '%c{2}', 'of.tests');
|
test(args, '%c{2}', 'of.tests');
|
||||||
|
Loading…
Reference in New Issue
Block a user