Created
September 8, 2015 04:09
-
-
Save trentm/ed1c8c34b53aee8a4f95 to your computer and use it in GitHub Desktop.
Show a Bunyan raw stream that hacks 'rec.time' to a custom format, if desired.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bunyan = require('./'); | |
function HackTimeStream(stream) { | |
this.stream = stream || process.stderr; | |
} | |
HackTimeStream.prototype.write = function write(rec) { | |
rec.time += 'wallawalla'; | |
this.stream.write(JSON.stringify(rec) + '\n'); | |
}; | |
var log = bunyan.createLogger({ | |
name: 'hacktime', | |
streams: [ | |
{ | |
type: 'raw', | |
stream: new HackTimeStream() | |
} | |
] | |
}); | |
log.info('hi') | |
log.info('bye') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ node hacktime.js | bunyan | |
{"name":"hacktime","hostname":"danger0.local","pid":9295,"level":30,"msg":"hi","time":"Mon Sep 07 2015 21:09:25 GMT-0700 (PDT)wallawalla","v":0} | |
{"name":"hacktime","hostname":"danger0.local","pid":9295,"level":30,"msg":"bye","time":"Mon Sep 07 2015 21:09:25 GMT-0700 (PDT)wallawalla","v":0} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment