8000 added some documentation to the function header · rboss/log4js-node@bec0d05 · GitHub
[go: up one dir, main page]

Skip to content

Commit bec0d05

Browse files
committed
added some documentation to the function header
1 pare
10000
nt e4bf405 commit bec0d05

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/layouts.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,22 @@ function messagePassThroughLayout (loggingEvent) {
140140
* - %d date in various formats
141141
* - %% %
142142
* - %n newline
143+
* - %x{<tokenname>} add dynamic tokens to your log. Tokens are specified in the tokens parameter
143144
* You can use %[ and %] to define a colored block.
144-
* Takes a pattern string and returns a layout function.
145+
*
146+
* Tokens are specified as simple key:value objects.
147+
* The key represents the token name whereas the value can be a string or function
148+
* which is called to extract the value to put in the log message. If token is not
149+
* found, it doesn't replace the field.
150+
*
151+
* A sample token would be: { "pid" : function() { return process.pid; } }
152+
*
153+
* Takes a pattern string, array of tokens and returns a layout function.
154+
* @param {String} Log format pattern String
155+
* @param {object} map object of different tokens
156+
* @return {Function}
145157
* @author Stephan Strittmatter
158+
* @author Jan Schmidle
146159
*/
147160
function patternLayout (pattern, tokens) {
148161
var TTCC_CONVERSION_PATTERN = "%r %p %c - %m%n";

0 commit comments

Comments
 (0)
0