modernize examples to bunyan.createLogger preference

This commit is contained in:
Trent Mick 2014-07-24 23:36:50 -07:00
parent e8a4387070
commit 12eda6036f
9 changed files with 24 additions and 24 deletions

View file

@ -1,13 +1,13 @@
// Example logging an error:
var http = require('http');
var Logger = require('../lib/bunyan');
var bunyan = require('../lib/bunyan');
var util = require('util');
var log = new Logger({
var log = bunyan.createLogger({
name: 'myserver',
serializers: {
err: Logger.stdSerializers.err, // <--- use this
err: bunyan.stdSerializers.err, // <--- use this
}
});

View file

@ -3,7 +3,7 @@
var fs = require('fs');
var path = require('path');
var Logger = require('../lib/bunyan');
var bunyan = require('../lib/bunyan');
var FILENAME = 'handle-fs-error.log';
var S_IWUSR = 00200; // mask for owner write permission in stat mode
@ -19,7 +19,7 @@ if (fs.statSync(FILENAME).mode & S_IWUSR) {
}
console.warn('- Create logger.')
var log = new Logger({name: 'handle-fs-error', streams: [{path: FILENAME}]});
var log = bunyan.createLogger({name: 'handle-fs-error', streams: [{path: FILENAME}]});
log.on('error', function (err) {
console.warn('- The logger emitted an error:', err);

View file

@ -1,7 +1,7 @@
var Logger = require('../lib/bunyan');
var bunyan = require('../lib/bunyan');
// Basic usage.
var log = new Logger({name: 'myapp', level: 'info', src: true});
var log = bunyan.createLogger({name: 'myapp', level: 'info', src: true});
// isInfoEnabled replacement
console.log('log.info() is:', log.info())

View file

@ -2,14 +2,14 @@
//
// TODO: put this in a damn test suite
var Logger = require('../lib/bunyan'),
DEBUG = Logger.DEBUG,
INFO = Logger.INFO,
WARN = Logger.WARN;
var bunyan = require('../lib/bunyan'),
DEBUG = bunyan.DEBUG,
INFO = bunyan.INFO,
WARN = bunyan.WARN;
var assert = require('assert');
// Basic usage.
var log = new Logger({
var log = bunyan.createLogger({
name: 'example-level',
streams: [
{

View file

@ -1,5 +1,5 @@
var Logger = require('../lib/bunyan');
log = new Logger({
var bunyan = require('../lib/bunyan');
log = bunyan.createLogger({
name: 'amon',
streams: [
{

View file

@ -2,7 +2,7 @@
// which log record *objects* are written instead of the JSON-serialized
// string.
var Logger = require('../lib/bunyan');
var bunyan = require('../lib/bunyan');
/**
@ -21,7 +21,7 @@ MyRawStream.prototype.write = function (rec) {
// A Logger using the raw stream.
var log = new Logger({
var log = bunyan.createLogger({
name: 'raw-example',
streams: [
{

View file

@ -1,13 +1,13 @@
// Example logging HTTP server request and response objects.
var http = require('http');
var Logger = require('../lib/bunyan');
var bunyan = require('../lib/bunyan');
var log = new Logger({
var log = bunyan.createLogger({
name: 'myserver',
serializers: {
req: Logger.stdSerializers.req,
res: Logger.stdSerializers.res
req: bunyan.stdSerializers.req,
res: bunyan.stdSerializers.res
}
});

View file

@ -1,9 +1,9 @@
// Show the usage of `src: true` config option to get log call source info in
// log records (the `src` field).
var Logger = require('../lib/bunyan');
var bunyan = require('../lib/bunyan');
var log = new Logger({name: 'src-example', src: true});
var log = bunyan.createLogger({name: 'src-example', src: true});
log.info('one');
log.info('two');

View file

@ -1,7 +1,7 @@
// See how bunyan behaves with an un-stringify-able object.
var Logger = require('../lib/bunyan');
var bunyan = require('../lib/bunyan');
var log = new Logger({src: true, name: 'foo'});
var log = bunyan.createLogger({src: true, name: 'foo'});
// Make a circular object (cannot be JSON-ified).
var myobj = {