Skip to content

Instantly share code, notes, and snippets.

@trentm trentm/hacktime.js
Created Sep 8, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.