0.2.1 • Published 10 years ago

bunyan-format v0.2.1

Weekly downloads
58,889
License
MIT
Repository
github
Last release
10 years ago

bunyan-format build status

Writable stream that formats bunyan records that are piped into it

var bunyan = require('bunyan')
  , bformat = require('bunyan-format')  
  , formatOut = bformat({ outputMode: 'short' })
  ;

var log = bunyan.createLogger({ name: 'app', stream: formatOut, level: 'debug' } );

log.info('starting up');
log.debug('things are heating up', { temperature: 80, status: { started: 'yes', overheated: 'no' } });
log.warn('getting a bit hot', { temperature: 120 });
log.error('OOOOHHH it burns!', new Error('temperature: 200'));
log.fatal('I died! Do you know what that means???');
  • Printing the level in String representation for Json objects
var bunyan = require('bunyan')
  , bformat = require('../')
  , formatOut = bformat({ outputMode: 'bunyan', levelInString: true })
  ;

The output would use the string levels:

$ node example/json-string-level.js 
{"name":"app","hostname":"ubuntu","pid":28081,"level":"INFO","msg":"starting up","time":"2014-12-01T19:41:29.136Z","v":0}
{"name":"app","hostname":"ubuntu","pid":28081,"level":"DEBUG","msg":"things are heating up { temperature: 80,\n  status: { started: 'yes', overheated: 'no' } }","time":"2014-12-01T19:41:29.142Z","v":0}
{"name":"app","hostname":"ubuntu","pid":28081,"level":"WARN","msg":"getting a bit hot { temperature: 120 }","time":"2014-12-01T19:41:29.143Z","v":0}
{"name":"app","hostname":"ubuntu","pid":28081,"level":"ERROR","msg":"OOOOHHH it burns! [Error: temperature: 200]","time":"2014-12-01T19:41:29.144Z","v":0}
{"name":"app","hostname":"ubuntu","pid":28081,"level":"FATAL","msg":"I died! Do you know what that means???","time":"2014-12-01T19:41:29.144Z","v":0}

demo

Installation

npm install bunyan-format

API

/**
 * Creates a writable stream that formats bunyan records written to it.
 * 
 * @name BunyanFormatWritable
 * @function
 * @param opts {Options} passed to bunyan format function
 *  - outputMode: short|long|simple|json|bunyan
 *  - color (true): toggles colors in output
 *  - colorFromLevel: allows overriding log level colors
 * @param out {Stream} (process.stdout) writable stream to write 
 * @return {WritableStream} that you can pipe bunyan output into
 */

License

MIT

chatbotceps5-availabilitysolidoc-logger2solidoc-logger-tooltask-service-containertm-kafka-avrovms-recording-server-node@monoca/logger@lupu60/nest-toolbox-bunyan-logger@lupu60/nestjs-toolbox@everything-registry/sub-chunk-1276bloghub-commontaboo-cmst-loggersvg-rasterizerwis-demowis-loggerwe-js-loggersuperpanelthingspace-sdk@coast/logger@colmena/logger@dabjs/http-server@camoflage/grpc@camoflage/helpers@camoflage/httpjira-todoirrigationirrigation-lets-encryptjoolajs-utils-funcjavascript-funckafka-avrokafka-avro-keyrulerkafka-avro-nodejskafka-avro-sbslaunchdarkly-nodeutilskth-node-logsro-common-utilsstagelightsrv-logsolidoc-loggertransaction-clienttrigger-repository-dispatchtopsoil@ask-utils/game@automaid/cast-service@automaid/firebase-service@automaid/gpio-service@automaid/hdmi-cec-service@automaid/philips-hue-service@automaid/rss-service@automaid/scenes-service@automaid/yamaha-avr-service@binarymuse/probot@bugslifesolutions/logger@certicraft/logging@0xc/maverick@jupiterone/integration-sdk@jupiterone/integration-sdk-runtime@codate/commons@deliverybot/coreyet-another-loggeryoutransferuniversal-bunyanuniversal-bunyan-logger@hiotlabs/hiot-api-interface@hygorcerticraft/logging@idigi/logger@kth/log@labs_jramirez/integration-sdk-runtime@ncwade01/makr-backend-shared@nepomukos/logger@nest-toolbox/bunyan-logger@elastic.io/component-commons-library@elastic.io/component-logger@ministryofjustice/hmpps-audit-client@ministryofjustice/hmpps-digital-prison-reporting-frontend@jshimko/logger@randy.tarampi/lambda-logger@reactioncommerce/logger@panosoft/slate-init-db@panosoft/slate-replicator@remie/acdeploy@release-notes/hubmwservicemiracle.core.modulesmikropmerge-convert-csv-to-jsonminecraft-managernatural-selection-modeloxlogon-my-plateoceanai-seaweedfs-clientoceanai_seaweedfsnrscnth-git-toolsnth-logpagasa-archiverscrambler-aws
0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

12 years ago

0.1.0

12 years ago