Skip to content

Instantly share code, notes, and snippets.

@trentm
Created September 8, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trentm/ed1c8c34b53aee8a4f95 to your computer and use it in GitHub Desktop.
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.
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')
$ 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