Skip to content

Commit 3872dfb

Browse files
committed
Adding prettyPrint parameter as function example.
1 parent 861dbfb commit 3872dfb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/custom-pretty-print.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var winston = require('../lib/winston');
2+
3+
function myPrettyPrint(obj) {
4+
return JSON.stringify(obj)
5+
.replace(/\{/g, '< wow ')
6+
.replace(/\:/g, ' such ')
7+
.replace(/\}/g, ' >');
8+
}
9+
10+
var logger = new (winston.Logger)({
11+
transports: [
12+
new (winston.transports.Console)({ prettyPrint: myPrettyPrint }),
13+
]
14+
});
15+
16+
logger.info('Hello, this is a logging event with a custom pretty print', { 'foo': 'bar' });
17+
logger.info('Hello, this is a logging event with a custom pretty print2', { 'foo': 'bar' });
18+

0 commit comments

Comments
 (0)