Skip to content

Commit

Permalink
give people a start at rendered console.log in the browser
Browse files Browse the repository at this point in the history
  • Loading branch information
trentm committed Sep 22, 2014
1 parent b86b954 commit 9e6a199
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Expand Up @@ -1000,6 +1000,36 @@ script.
Here is what it looks like in Firefox's console: ![Bunyan + Browserify in the
Firefox console](./docs/img/bunyan.browserify.png)

For some the raw log records might not be desired, to have a rendered log line
you'll want to add your own stream, starting with something like this:

function MyRawStream() {}
MyRawStream.prototype.write = function (rec) {
var nameFromLevel = {
TRACE: 'TRACE'
DEBUG: 'DEBUG',
INFO: 'INFO',
WARN: 'WARN',
ERROR: 'ERROR',
FATAL: 'FATAL'
};
console.log('[%s] %s: %s', rec.time, nameFromLevel[rec.level], rec.msg);
}

var log = bunyan.createLogger({
name: 'foo',
streams: [
{
level: 'info',
stream: new MyRawStream(),
type: 'raw'
},
]
});

log.info('hi on info');




# Versioning
Expand Down

0 comments on commit 9e6a199

Please sign in to comment.