Name: js-handler/node_modules/restify/node_modules/bunyan/package.json
| 1: | { |
| 2: | "name": "bunyan", |
| 3: | "version": "0.21.1", |
| 4: | "description": "a JSON Logger library for node.js services", |
| 5: | "author": { |
| 6: | "name": "Trent Mick", |
| 7: | "email": "[email protected]", |
| 8: | "url": "http://trentm.com" |
| 9: | }, |
| 10: | "main": "./lib/bunyan.js", |
| 11: | "bin": { |
| 12: | "bunyan": "./bin/bunyan" |
| 13: | }, |
| 14: | "repository": { |
| 15: | "type": "git", |
| 16: | "url": "git://github.com/trentm/node-bunyan.git" |
| 17: | }, |
| 18: | "engines": [ |
| 19: | "node >=0.6.0" |
| 20: | ], |
| 21: | "keywords": [ |
| 22: | "log", |
| 23: | "logging", |
| 24: | "log4j", |
| 25: | "json" |
| 26: | ], |
| 27: | "dependencies": { |
| 28: | "mv": "0.0.5", |
| 29: | "dtrace-provider": "0.2.8" |
| 30: | }, |
| 31: | "// comment": "'mv' required for RotatingFileStream", |
| 32: | "optionalDependencies": { |
| 33: | "mv": "0.0.5", |
| 34: | "dtrace-provider": "0.2.8" |
| 35: | }, |
| 36: | "devDependencies": { |
| 37: | "nodeunit": "0.7.4", |
| 38: | "ben": "0.0.0", |
| 39: | "verror": "1.3.3" |
| 40: | }, |
| 41: | "scripts": { |
| 42: | "test": "make test" |
| 43: | }, |
| 44: | "contributors": [ |
| 45: | { |
| 46: | "name": "Trent Mick", |
| 47: | "email": "[email protected]", |
| 48: | "url": "http://trentm.com" |
| 49: | }, |
| 50: | { |
| 51: | "name": "Mark Cavage", |
| 52: | "email": "[email protected]", |
| 53: | "url": "https://github.com/mcavage" |
| 54: | }, |
| 55: | { |
| 56: | "name": "Dave Pacheco", |
| 57: | "email": "[email protected]", |
| 58: | "url": "https://github.com/davepacheco" |
| 59: | }, |
| 60: | { |
| 61: | "name": "Michael Hart", |
| 62: | "url": "https://github.com/mhart" |
| 63: | }, |
| 64: | { |
| 65: | "name": "Isaac Schlueter", |
| 66: | "url": "https://github.com/isaacs" |
| 67: | }, |
| 68: | { |
| 69: | "name": "Rob Gulewich", |
| 70: | "url": "https://github.com/rgulewich" |
| 71: | }, |
| 72: | { |
| 73: | "name": "Bryan Cantrill", |
| 74: | "url": "https://github.com/bcantrill" |
| 75: | } |
| 76: | ], |
| 77: | "readme": "Bunyan is **a simple and fast JSON logging library** for node.js services:\n\n var bunyan = require('bunyan');\n var log = bunyan.createLogger({name: \"myapp\"});\n log.info(\"hi\");\n\nand **a `bunyan` CLI tool** for nicely viewing those logs:\n\n\n\nManifesto: Server logs should be structured. JSON's a good format. Let's do\nthat. A log record is one line of `JSON.stringify`'d output. Let's also\nspecify some common names for the requisite and common fields for a log\nrecord (see below).\n\nAlso: log4j is way more than you need.\n\n\n# Current Status\n\nSolid core functionality is there. Joyent is using this for a number of\nproduction services. Bunyan supports node 0.6 and greater. Follow\n<a href=\"https://twitter.com/intent/user?screen_name=trentmick\" target=\"_blank\">@trentmick</a>\nfor updates to Bunyan.\n\n\n# Installation\n\n npm install bunyan\n\n**Tip**: The `bunyan` CLI tool is written to be compatible (within reason) with\nall versions of Bunyan logs. Therefore you might want to `npm install -g bunyan`\nto get the bunyan CLI on your PATH, then use local bunyan installs for\nnode.js library usage of bunyan in your apps.\n\n\n# Features\n\n- elegant [log method API](#log-method-api)\n- extensible [streams](#streams) system for controlling where log records\n go (to a stream, to a file, [log file rotation](#stream-type-rotating-file),\n etc.)\n- [`bunyan` CLI](#cli-usage) for pretty-printing and filtering of Bunyan logs\n- simple include of log call source location (file, line, function) with\n [`src: true`](#src)\n- light-weight specialization of Logger instances with [`log.child`](#logchild)\n- custom rendering of logged objects with [\"serializers\"](#serializers)\n- [Dtrace support](#dtrace-support)\n\n\n# Introduction\n\nLike most logging libraries you create a Logger instance and call methods\nnamed after the logging levels:\n\n $ cat hi.js\n var bunyan = require('bunyan');\n var log = bunyan.createLogger({name: 'myapp'});\n log.info('hi');\n log.warn({lang: 'fr'}, 'au revoir');\n\nAll loggers must provide a \"name\". This is somewhat akin to the log4j logger\n\"name\", but Bunyan doesn't do hierarchical logger names.\n\n**Bunyan log records are JSON.** A few fields are added automatically:\n\"pid\", \"hostname\", \"time\" and \"v\".\n\n $ node hi.js\n {\"name\":\"myapp\",\"hostname\":\"banana.local\",\"pid\":40161,\"level\":30,\"msg\":\"hi\",\"time\":\"2013-01-04T18:46:23.851Z\",\"v\":0}\n {\"name\":\"myapp\",\"hostname\":\"banana.local\",\"pid\":40161,\"level\":40,\"lang\":\"fr\",\"msg\":\"au revoir\",\"time\":\"2013-01-04T18:46:23.853Z\",\"v\":0}\n\n\n## Log Method API\n\nThe example above shows two different ways to call `log.info(...)`. The\nfull API is:\n\n log.info(); // Returns a boolean: is the \"info\" level enabled?\n // This is equivalent to `log.isInfoEnabled()` or\n // `log.isEnabledFor(INFO)` in log4j.\n\n log.info('hi'); // Log a simple string message.\n log.info('hi %s', bob, anotherVar); // Uses `util.format` for msg formatting.\n\n log.info({foo: 'bar'}, 'hi');\n // Adds \"foo\" field to log record. You can add any number\n // of additional fields here.\n\n log.info(err); // Special case to log an `Error` instance to the record.\n // This adds an \"err\" field with exception details\n // (including the stack) and sets \"msg\" to the exception\n // message.\n log.info(err, 'more on this: %s', more);\n // ... or you can specify the \"msg\".\n\nNote that this implies **you cannot pass any object as the first argument\nto log it**. IOW, `log.info(mywidget)` may not be what you expect. Instead\nof a string representation of `mywidget` that other logging libraries may\ngive you, Bunyan will try to JSON-ify your object. It is a Bunyan best\npractice to always give a field name to included objects, e.g.:\n\n log.info({widget: mywidget}, ...)\n\nThis will dove-tail with [Bunyan serializer support](#serializers), discussed\nlater.\n\nThe same goes for all of Bunyan's log levels: `log.trace`, `log.debug`,\n`log.info`, `log.warn`, and `log.fatal`. See the [levels section](#levels)\nbelow for details and suggestions.\n\n\n## CLI Usage\n\nBunyan log output is a stream of JSON objects. This is great for processing,\nbut not for reading directly. A **`bunyan` tool** is provided **for\npretty-printing bunyan logs** and for **filtering** (e.g.\n`| bunyan -c 'this.foo == \"bar\"'`). Using our example above:\n\n $ node hi.js | ./bin/bunyan\n [2013-01-04T19:01:18.241Z] INFO: myapp/40208 on banana.local: hi\n [2013-01-04T19:01:18.242Z] WARN: myapp/40208 on banana.local: au revoir (lang=fr)\n\nSee the screenshot above for an example of the default coloring of rendered\nlog output. That example also shows the nice formatting automatically done for\nsome well-known log record fields (e.g. `req` is formatted like an HTTP request,\n`res` like an HTTP response, `err` like an error stack trace).\n\nOne interesting feature is **filtering** of log content, which can be useful\nfor digging through large log files or for analysis. We can filter only\nrecords above a certain level:\n\n $ node hi.js | bunyan -l warn\n [2013-01-04T19:08:37.182Z] WARN: myapp/40353 on banana.local: au revoir (lang=fr)\n\nOr filter on the JSON fields in the records (e.g. only showing the French\nrecords in our contrived example):\n\n $ node hi.js | bunyan -c 'this.lang == \"fr\"'\n [2013-01-04T19:08:26.411Z] WARN: myapp/40342 on banana.local: au revoir (lang=fr)\n\nSee `bunyan --help` for other facilities.\n\n\n## Streams Introduction\n\nBy default, log output is to stdout and at the \"info\" level. Explicitly that\nlooks like:\n\n var log = bunyan.createLogger({\n name: 'myapp',\n stream: process.stdout,\n level: 'info'\n });\n\nThat is an abbreviated form for a single stream. **You can define multiple\nstreams at different levels**.\n\n var log = bunyan.createLogger({\n name: 'myapp',\n streams: [\n {\n level: 'info',\n stream: process.stdout, // log INFO and above to stdout\n },\n {\n level: 'error',\n path: '/var/log/myapp-error.log' // log ERROR and above to a file\n }\n ]\n });\n\nMore on streams in the [Streams section](#streams) below.\n\n\n## log.child\n\nBunyan has a concept of a child logger to **specialize a logger for a\nsub-component of your application**, i.e. to create a new logger with\nadditional bound fields that will be included in its log records. A child\nlogger is created with `log.child(...)`.\n\nIn the following example, logging on a \"Wuzzle\" instance's `this.log` will\nbe exactly as on the parent logger with the addition of the `widget_type`\nfield:\n\n var bunyan = require('bunyan');\n var log = bunyan.createLogger({name: 'myapp'});\n\n function Wuzzle(options) {\n this.log = options.log.child({widget_type: 'wuzzle'});\n this.log.info('creating a wuzzle')\n }\n Wuzzle.prototype.woos = function () {\n this.log.warn('This wuzzle is woosey.')\n }\n\n log.info('start');\n var wuzzle = new Wuzzle({log: log});\n wuzzle.woos();\n log.info('done');\n\nRunning that looks like (raw):\n\n $ node myapp.js\n {\"name\":\"myapp\",\"hostname\":\"myhost\",\"pid\":34572,\"level\":30,\"msg\":\"start\",\"time\":\"2013-01-04T07:47:25.814Z\",\"v\":0}\n {\"name\":\"myapp\",\"hostname\":\"myhost\",\"pid\":34572,\"widget_type\":\"wuzzle\",\"level\":30,\"msg\":\"creating a wuzzle\",\"time\":\"2013-01-04T07:47:25.815Z\",\"v\":0}\n {\"name\":\"myapp\",\"hostname\":\"myhost\",\"pid\":34572,\"widget_type\":\"wuzzle\",\"level\":40,\"msg\":\"This wuzzle is woosey.\",\"time\":\"2013-01-04T07:47:25.815Z\",\"v\":0}\n {\"name\":\"myapp\",\"hostname\":\"myhost\",\"pid\":34572,\"level\":30,\"msg\":\"done\",\"time\":\"2013-01-04T07:47:25.816Z\",\"v\":0}\n\nAnd with the `bunyan` CLI (using the \"short\" output mode):\n\n $ node myapp.js | bunyan -o short\n 07:46:42.707Z INFO myapp: start\n 07:46:42.709Z INFO myapp: creating a wuzzle (widget_type=wuzzle)\n 07:46:42.709Z WARN myapp: This wuzzle is woosey. (widget_type=wuzzle)\n 07:46:42.709Z INFO myapp: done\n\n\nA more practical example is in the\n[node-restify](https://github.com/mcavage/node-restify) web framework.\nRestify uses Bunyan for its logging. One feature of its integration, is that\neach restify request handler includes a `req.log` logger that is:\n\n log.child({req_id: <unique request id>}, true)\n\nApps using restify can then use `req.log` and have all such log records\ninclude the unique request id (as \"req_id\"). Handy.\n\n\n## Serializers\n\nBunyan has a concept of **\"serializers\" to produce a JSON-able object from a\nJavaScript object**, so you can easily do the following:\n\n log.info({req: <request object>}, 'something about handling this request');\n\nSerializers is a mapping of log record field name, \"req\" in this example, to\na serializer function. That looks like this:\n\n function reqSerializer(req) {\n return {\n method: req.method,\n url: req.url,\n headers: req.headers\n }\n }\n var log = bunyan.createLogger({\n name: 'myapp',\n serializers: {\n req: reqSerializer\n }\n });\n\nOr this:\n\n var log = bunyan.createLogger({\n name: 'myapp',\n serializers: {req: bunyan.stdSerializers.req}\n });\n\nbecause Buyan includes a small set of standard serializers. To use all the\nstandard serializers you can use:\n\n var log = bunyan.createLogger({\n ...\n serializers: bunyan.stdSerializers\n });\n\n**Note**: Your own serializers should never throw, otherwise you'll get an\nugly message on stderr from Bunyan (along with the traceback) and the field\nin your log record will be replaced with a short error message.\n\n\n## src\n\nThe **source file, line and function of the log call site** can be added to\nlog records by using the `src: true` config option:\n\n var log = bunyan.createLogger({src: true, ...});\n\nThis adds the call source info with the 'src' field, like this:\n\n {\n \"name\": \"src-example\",\n \"hostname\": \"banana.local\",\n \"pid\": 123,\n \"component\": \"wuzzle\",\n \"level\": 4,\n \"msg\": \"This wuzzle is woosey.\",\n \"time\": \"2012-02-06T04:19:35.605Z\",\n \"src\": {\n \"file\": \"/Users/trentm/tm/node-bunyan/examples/src.js\",\n \"line\": 20,\n \"func\": \"Wuzzle.woos\"\n },\n \"v\": 0\n }\n\n**WARNING: Determining the call source info is slow. Never use this option\nin production.**\n\n\n# Levels\n\nThe log levels in bunyan are as follows. The level descriptions are best\npractice *opinions*.\n\n- \"fatal\" (60): The service/app is going to stop or become unusable now.\n An operator should definitely look into this soon.\n- \"error\" (50): Fatal for a particular request, but the service/app continues\n servicing other requests. An operator should look at this soon(ish).\n- \"warn\" (40): A note on something that should probably be looked at by an\n operator eventually.\n- \"info\" (30): Detail on regular operation.\n- \"debug\" (20): Anything else, i.e. too verbose to be included in \"info\" level.\n- \"trace\" (10): Logging from external libraries used by your app or *very*\n detailed application logging.\n\nSuggestions: Use \"debug\" sparingly. Information that will be useful to debug\nerrors *post mortem* should usually be included in \"info\" messages if it's\ngenerally relevant or else with the corresponding \"error\" event. Don't rely\non spewing mostly irrelevant debug messages all the time and sifting through\nthem when an error occurs.\n\nIntegers are used for the actual level values (10 for \"trace\", ..., 60 for\n\"fatal\") and constants are defined for the (bunyan.TRACE ... bunyan.DEBUG).\nThe lowercase level names are aliases supported in the API.\n\nHere is the API for changing levels in an existing logger:\n\n log.level() -> INFO // gets current level (lowest level of all streams)\n\n log.level(INFO) // set all streams to level INFO\n log.level(\"info\") // set all streams to level INFO\n\n log.levels() -> [DEBUG, INFO] // get array of levels of all streams\n log.levels(0) -> DEBUG // get level of stream at index 0\n log.levels(\"foo\") // get level of stream with name \"foo\"\n\n log.levels(0, INFO) // set level of stream 0 to INFO\n log.levels(0, \"info\") // can use \"info\" et al aliases\n log.levels(\"foo\", WARN) // set stream named \"foo\" to WARN\n\n\n\n# Log Record Fields\n\nThis section will describe *rules* for the Bunyan log format: field names,\nfield meanings, required fields, etc. However, a Bunyan library doesn't\nstrictly enforce all these rules while records are being emitted. For example,\nBunyan will add a `time` field with the correct format to your log records,\nbut you can specify your own. It is the caller's responsibility to specify\nthe appropriate format.\n\nThe reason for the above leniency is because IMO logging a message should\nnever break your app. This leads to this rule of logging: **a thrown\nexception from `log.info(...)` or equivalent (other than for calling with the\nincorrect signature) is always a bug in Bunyan.**\n\n\nA typical Bunyan log record looks like this:\n\n {\"name\":\"myserver\",\"hostname\":\"banana.local\",\"pid\":123,\"req\":{\"method\":\"GET\",\"url\":\"/path?q=1#anchor\",\"headers\":{\"x-hi\":\"Mom\",\"connection\":\"close\"}},\"level\":3,\"msg\":\"start request\",\"time\":\"2012-02-03T19:02:46.178Z\",\"v\":0}\n\nPretty-printed:\n\n {\n \"name\": \"myserver\",\n \"hostname\": \"banana.local\",\n \"pid\": 123,\n \"req\": {\n \"method\": \"GET\",\n \"url\": \"/path?q=1#anchor\",\n \"headers\": {\n \"x-hi\": \"Mom\",\n \"connection\": \"close\"\n },\n \"remoteAddress\": \"120.0.0.1\",\n \"remotePort\": 51244\n },\n \"level\": 3,\n \"msg\": \"start request\",\n \"time\": \"2012-02-03T19:02:57.534Z\",\n \"v\": 0\n }\n\n\nCore fields:\n\n- `v`: Required. Integer. Added by Bunyan. Cannot be overriden.\n This is the Bunyan log format version (`require('bunyan').LOG_VERSION`).\n The log version is a single integer. `0` is until I release a version\n \"1.0.0\" of node-bunyan. Thereafter, starting with `1`, this will be\n incremented if there is any backward incompatible change to the log record\n format. Details will be in \"CHANGES.md\" (the change log).\n- `level`: Required. Integer. Added by Bunyan. Cannot be overriden.\n See the \"Levels\" section.\n- `name`: Required. String. Provided at Logger creation.\n You must specify a name for your logger when creating it. Typically this\n is the name of the service/app using Bunyan for logging.\n- `hostname`: Required. String. Provided or determined at Logger creation.\n You can specify your hostname at Logger creation or it will be retrieved\n vi `os.hostname()`.\n- `pid`: Required. Integer. Filled in automatically at Logger creation.\n- `time`: Required. String. Added by Bunyan. Can be overriden.\n The date and time of the event in [ISO 8601\n Extended Format](http://en.wikipedia.org/wiki/ISO_8601) format and in UTC,\n as from\n [`Date.toISOString()`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/toISOString).\n- `msg`: Required. String.\n Every `log.debug(...)` et al call must provide a log message.\n- `src`: Optional. Object giving log call source info. This is added\n automatically by Bunyan if the \"src: true\" config option is given to the\n Logger. Never use in production as this is really slow.\n\n\nGo ahead and add more fields, and nested ones are fine (and recommended) as\nwell. This is why we're using JSON. Some suggestions and best practices\nfollow (feedback from actual users welcome).\n\n\nRecommended/Best Practice Fields:\n\n- `err`: Object. A caught JS exception. Log that thing with `log.info(err)`\n to get:\n\n ...\n \"err\": {\n \"message\": \"boom\",\n \"name\": \"TypeError\",\n \"stack\": \"TypeError: boom\\n at Object.<anonymous> ...\"\n },\n \"msg\": \"boom\",\n ...\n\n Or use the `bunyan.stdSerializers.err` serializer in your Logger and\n do this `log.error({err: err}, \"oops\")`. See \"examples/err.js\".\n\n- `req_id`: String. A request identifier. Including this field in all logging\n tied to handling a particular request to your server is strongly suggested.\n This allows post analysis of logs to easily collate all related logging\n for a request. This really shines when you have a SOA with multiple services\n and you carry a single request ID from the top API down through all APIs\n (as [node-restify](https://github.com/mcavage/node-restify) facilitates\n with its 'X-Request-Id' header).\n\n- `req`: An HTTP server request. Bunyan provides `bunyan.stdSerializers.req`\n to serialize a request with a suggested set of keys. Example:\n\n {\n \"method\": \"GET\",\n \"url\": \"/path?q=1#anchor\",\n \"headers\": {\n \"x-hi\": \"Mom\",\n \"connection\": \"close\"\n },\n \"remoteAddress\": \"120.0.0.1\",\n \"remotePort\": 51244\n }\n\n- `res`: An HTTP server response. Bunyan provides `bunyan.stdSerializers.res`\n to serialize a response with a suggested set of keys. Example:\n\n {\n \"statusCode\": 200,\n \"header\": \"HTTP/1.1 200 OK\\r\\nContent-Type: text/plain\\r\\nConnection: keep-alive\\r\\nTransfer-Encoding: chunked\\r\\n\\r\\n\"\n }\n\n\nOther fields to consider:\n\n- `req.username`: Authenticated user (or for a 401, the user attempting to\n auth).\n- Some mechanism to calculate response latency. \"restify\" users will have\n a \"X-Response-Time\" header. A `latency` custom field would be fine.\n- `req.body`: If you know that request bodies are small (common in APIs,\n for example), then logging the request body is good.\n\n\n# Streams\n\nA \"stream\" is Bunyan's name for an output for log messages (the equivalent\nto a log4j Appender). Ultimately Bunyan uses a\n[Writable Stream](http://nodejs.org/docs/latest/api/all.html#writable_Stream)\ninterface, but there are some additional attributes used to create and\nmanage the stream. A Bunyan Logger instance has one or more streams.\nIn general streams are specified with the \"streams\" option:\n\n var bunyan = require('bunyan');\n var log = bunyan.createLogger({\n name: \"foo\",\n streams: [\n {\n stream: process.stderr,\n level: \"debug\"\n },\n ...\n ]\n });\n\nFor convenience, if there is only one stream, it can specified with the\n\"stream\" and \"level\" options (internally converted to a `Logger.streams`).\n\n var log = bunyan.createLogger({\n name: \"foo\",\n stream: process.stderr,\n level: \"debug\"\n });\n\nNote that \"file\" streams do not support this shortcut (partly for historical\nreasons and partly to not make it difficult to add a literal \"path\" field\non log records).\n\nIf neither \"streams\" nor \"stream\" are specified, the default is a stream of\ntype \"stream\" emitting to `process.stdout` at the \"info\" level.\n\n\n## stream errors\n\nBunyan re-emits error events from the created `WriteStream`. So you can\ndo this:\n\n var log = bunyan.createLogger({name: 'mylog', streams: [{path: LOG_PATH}]});\n log.on('error', function (err, stream) {\n // Handle stream write or create error here.\n });\n\n\n## stream type: `stream`\n\nA `type === 'stream'` is a plain ol' node.js [Writable\nStream](http://nodejs.org/docs/latest/api/all.html#writable_Stream). A\n\"stream\" (the writeable stream) field is required. E.g.: `process.stdout`,\n`process.stderr`.\n\n var log = bunyan.createLogger({\n name: 'foo',\n streams: [{\n stream: process.stderr\n // `type: 'stream'` is implied\n }]\n });\n\n<table>\n<tr>\n<th>Field</th>\n<th>Required?</th>\n<th>Default</th>\n<th>Description</th>\n</tr>\n<tr>\n<td>stream</td>\n<td>Yes</td>\n<td>-</td>\n<td>A \"Writable Stream\", e.g. a std handle or an open file write stream.</td>\n</tr>\n<tr>\n<td>type</td>\n<td>No</td>\n<td>n/a</td>\n<td>`type == 'stream'` is implied if the `stream` field is given.</td>\n</tr>\n<tr>\n<td>level</td>\n<td>No</td>\n<td>info</td>\n<td>The level at which logging to this stream is enabled. If not\nspecified it defaults to \"info\". If specified this can be one of the\nlevel strings (\"trace\", \"debug\", ...) or constants (`bunyan.TRACE`,\n`bunyan.DEBUG`, ...).</td>\n</tr>\n<tr>\n<td>name</td>\n<td>No</td>\n<td>-</td>\n<td>A name for this stream. This may be useful for usage of `log.level(NAME,\nLEVEL)`. See the [Levels section](#levels) for details. A stream \"name\" isn't\nused for anything else.</td>\n</tr>\n</table>\n\n\n## stream type: `file`\n\nA `type === 'file'` stream requires a \"path\" field. Bunyan will open this\nfile for appending. E.g.:\n\n var log = bunyan.createLogger({\n name: 'foo',\n streams: [{\n path: '/var/log/foo.log',\n // `type: 'file'` is implied\n }]\n });\n\n<table>\n<tr>\n<th>Field</th>\n<th>Required?</th>\n<th>Default</th>\n<th>Description</th>\n</tr>\n<tr>\n<td>path</td>\n<td>Yes</td>\n<td>-</td>\n<td>A file path to which to log.</td>\n</tr>\n<tr>\n<td>type</td>\n<td>No</td>\n<td>n/a</td>\n<td>`type == 'file'` is implied if the `path` field is given.</td>\n</tr>\n<tr>\n<td>level</td>\n<td>No</td>\n<td>info</td>\n<td>The level at which logging to this stream is enabled. If not\nspecified it defaults to \"info\". If specified this can be one of the\nlevel strings (\"trace\", \"debug\", ...) or constants (`bunyan.TRACE`,\n`bunyan.DEBUG`, ...).</td>\n</tr>\n<tr>\n<td>name</td>\n<td>No</td>\n<td>-</td>\n<td>A name for this stream. This may be useful for usage of `log.level(NAME,\nLEVEL)`. See the [Levels section](#levels) for details. A stream \"name\" isn't\nused for anything else.</td>\n</tr>\n</table>\n\n\n## stream type: `rotating-file`\n\nA `type === 'rotating-file'` is a file stream that handles file automatic\nrotation.\n\n var log = bunyan.createLogger({\n name: 'foo',\n streams: [{\n type: 'rotating-file',\n path: '/var/log/foo.log',\n period: '1d', // daily rotation\n count: 3 // keep 3 back copies\n }]\n });\n\nThis will rotate '/var/log/foo.log' every day (at midnight) to:\n\n /var/log/foo.log.0 # yesterday\n /var/log/foo.log.1 # 1 day ago\n /var/log/foo.log.2 # 2 days ago\n\n*Currently*, there is no support for providing a template for the rotated\nfiles, or for rotating when the log reaches a threshold size.\n\n<table>\n<tr>\n<th>Field</th>\n<th>Required?</th>\n<th>Default</th>\n<th>Description</th>\n</tr>\n<tr>\n<td>type</td>\n<td>Yes</td>\n<td>-</td>\n<td>\"rotating-file\"</td>\n</tr>\n<tr>\n<td>path</td>\n<td>Yes</td>\n<td>-</td>\n<td>A file path to which to log. Rotated files will be \"$path.0\",\n\"$path.1\", ...</td>\n</tr>\n<tr>\n<td>period</td>\n<td>No</td>\n<td>1d</td>\n<td>The period at which to rotate. This is a string of the format\n\"$number$scope\" where \"$scope\" is one of \"h\" (hours), \"d\" (days), \"w\" (weeks),\n\"m\" (months), \"y\" (years). Or one of the following names can be used\n\"hourly\" (means 1h), \"daily\" (1d), \"weekly\" (1w), \"monthly\" (1m),\n\"yearly\" (1y). Rotation is done at the start of the scope: top of the hour (h),\nmidnight (d), start of Sunday (w), start of the 1st of the month (m),\nstart of Jan 1st (y).</td>\n</tr>\n<tr>\n<td>count</td>\n<td>No</td>\n<td>10</td>\n<td>The number of rotated files to keep.</td>\n</tr>\n<tr>\n<td>level</td>\n<td>No</td>\n<td>info</td>\n<td>The level at which logging to this stream is enabled. If not\nspecified it defaults to \"info\". If specified this can be one of the\nlevel strings (\"trace\", \"debug\", ...) or constants (`bunyan.TRACE`,\n`bunyan.DEBUG`, ...).</td>\n</tr>\n<tr>\n<td>name</td>\n<td>No</td>\n<td>-</td>\n<td>A name for this stream. This may be useful for usage of `log.level(NAME,\nLEVEL)`. See the [Levels section](#levels) for details. A stream \"name\" isn't\nused for anything else.</td>\n</tr>\n</table>\n\n\n\n## stream type: `raw`\n\n- `raw`: Similar to a \"stream\" writeable stream, except that the write method\n is given raw log record *Object*s instead of a JSON-stringified string.\n This can be useful for hooking on further processing to all Bunyan logging:\n pushing to an external service, a RingBuffer (see below), etc.\n\n\n\n## `raw` + RingBuffer Stream\n\nBunyan comes with a special stream called a RingBuffer which keeps the last N\nrecords in memory and does *not* write the data anywhere else. One common\nstrategy is to log 'info' and higher to a normal log file but log all records\n(including 'trace') to a ringbuffer that you can access via a debugger, or your\nown HTTP interface, or a post-mortem facility like MDB or node-panic.\n\nTo use a RingBuffer:\n\n /* Create a ring buffer that stores the last 100 records. */\n var bunyan = require('bunyan');\n var ringbuffer = new bunyan.RingBuffer({ limit: 100 });\n var log = bunyan.createLogger({\n name: 'foo',\n streams: [\n {\n level: 'info',\n stream: process.stdout\n },\n {\n level: 'trace',\n type: 'raw', // use 'raw' to get raw log record objects\n stream: ringbuffer\n }\n ]\n });\n\n log.info('hello world');\n console.log(ringbuffer.records);\n\nThis example emits:\n\n [ { name: 'foo',\n hostname: '912d2b29',\n pid: 50346,\n level: 30,\n msg: 'hello world',\n time: '2012-06-19T21:34:19.906Z',\n v: 0 } ]\n\n\n## third-party streams\n\n- syslog:\n [mcavage/node-bunyan-syslog](https://github.com/mcavage/node-bunyan-syslog)\n provides support for directing bunyan logging to a syslog server.\n\n- TODO: eventually https://github.com/trentm/node-bunyan-winston\n\n\n\n# DTrace support\n\nOn systems that support DTrace (e.g., MacOS, FreeBSD, illumos derivatives\nlike SmartOS and OmniOS), Bunyan will create a DTrace provider (`bunyan`)\nthat makes available the following probes:\n\n log-trace\n log-debug\n log-info\n log-warn\n log-error\n log-fatal\n\nEach of these probes has a single argument: the string that would be\nwritten to the log. Note that when a probe is enabled, it will\nfire whenever the corresponding function is called, even if the level of\nthe log message is less than that of any stream.\n\n\n## DTrace examples\n\nTrace all log messages coming from any Bunyan module on the system.\n(The `-x strsize=4k` is to raise dtrace's default 256 byte buffer size\nbecause log messages are longer than typical dtrace probes.)\n\n dtrace -x strsize=4k -qn 'bunyan*:::log-*{printf(\"%d: %s: %s\", pid, probefunc, copyinstr(arg0))}'\n\nTrace all log messages coming from the \"wuzzle\" component:\n\n dtrace -x strsize=4k -qn 'bunyan*:::log-*/strstr(this->str = copyinstr(arg0), \"\\\"component\\\":\\\"wuzzle\\\"\") != NULL/{printf(\"%s\", this->str)}'\n\nAggregate debug messages from process 1234, by message:\n\n dtrace -x strsize=4k -n 'bunyan1234:::log-debug{@[copyinstr(arg0)] = count()}'\n\nHave the bunyan CLI pretty-print the traced logs:\n\n dtrace -x strsize=4k -qn 'bunyan1234:::log-*{printf(\"%s\", copyinstr(arg0))}' | bunyan\n\nA convenience handle has been made for this:\n\n bunyan -p 1234\n\n\nOn systems that support the\n[`jstack`](http://dtrace.org/blogs/dap/2012/04/25/profiling-node-js/) action\nvia a node.js helper, get a stack backtrace for any debug message that\nincludes the string \"danger!\":\n\n dtrace -x strsize=4k -qn 'log-debug/strstr(copyinstr(arg0), \"danger!\") != NULL/{printf(\"\\n%s\", copyinstr(arg0)); jstack()}'\n\nOutput of the above might be:\n\n {\"name\":\"foo\",\"hostname\":\"763bf293-d65c-42d5-872b-4abe25d5c4c7.local\",\"pid\":12747,\"level\":20,\"msg\":\"danger!\",\"time\":\"2012-10-30T18:28:57.115Z\",\"v\":0}\n\n node`0x87e2010\n DTraceProviderBindings.node`usdt_fire_probe+0x32\n DTraceProviderBindings.node`_ZN4node11DTraceProbe5_fireEN2v85LocalINS1_5ValueEEE+0x32d\n DTraceProviderBindings.node`_ZN4node11DTraceProbe4FireERKN2v89ArgumentsE+0x77\n << internal code >>\n (anon) as (anon) at /root/node-bunyan/lib/bunyan.js position 40484\n << adaptor >>\n (anon) as doit at /root/my-prog.js position 360\n (anon) as list.ontimeout at timers.js position 4960\n << adaptor >>\n << internal >>\n << entry >>\n node`_ZN2v88internalL6InvokeEbNS0_6HandleINS0_10JSFunctionEEENS1_INS0_6ObjectEEEiPS5_Pb+0x101\n node`_ZN2v88internal9Execution4CallENS0_6HandleINS0_6ObjectEEES4_iPS4_Pbb+0xcb\n node`_ZN2v88Function4CallENS_6HandleINS_6ObjectEEEiPNS1_INS_5ValueEEE+0xf0\n node`_ZN4node12MakeCallbackEN2v86HandleINS0_6ObjectEEENS1_INS0_8FunctionEEEiPNS1_INS0_5ValueEEE+0x11f\n node`_ZN4node12MakeCallbackEN2v86HandleINS0_6ObjectEEENS1_INS0_6StringEEEiPNS1_INS0_5ValueEEE+0x66\n node`_ZN4node9TimerWrap9OnTimeoutEP10uv_timer_si+0x63\n node`uv__run_timers+0x66\n node`uv__run+0x1b\n node`uv_run+0x17\n node`_ZN4node5StartEiPPc+0x1d0\n node`main+0x1b\n node`_start+0x83\n\n node`0x87e2010\n DTraceProviderBindings.node`usdt_fire_probe+0x32\n DTraceProviderBindings.node`_ZN4node11DTraceProbe5_fireEN2v85LocalINS1_5ValueEEE+0x32d\n DTraceProviderBindings.node`_ZN4node11DTraceProbe4FireERKN2v89ArgumentsE+0x77\n << internal code >>\n (anon) as (anon) at /root/node-bunyan/lib/bunyan.js position 40484\n << adaptor >>\n (anon) as doit at /root/my-prog.js position 360\n (anon) as list.ontimeout at timers.js position 4960\n << adaptor >>\n << internal >>\n << entry >>\n node`_ZN2v88internalL6InvokeEbNS0_6HandleINS0_10JSFunctionEEENS1_INS0_6ObjectEEEiPS5_Pb+0x101\n node`_ZN2v88internal9Execution4CallENS0_6HandleINS0_6ObjectEEES4_iPS4_Pbb+0xcb\n node`_ZN2v88Function4CallENS_6HandleINS_6ObjectEEEiPNS1_INS_5ValueEEE+0xf0\n node`_ZN4node12MakeCallbackEN2v86HandleINS0_6ObjectEEENS1_INS0_8FunctionEEEiPNS1_INS0_5ValueEEE+0x11f\n node`_ZN4node12MakeCallbackEN2v86HandleINS0_6ObjectEEENS1_INS0_6StringEEEiPNS1_INS0_5ValueEEE+0x66\n node`_ZN4node9TimerWrap9OnTimeoutEP10uv_timer_si+0x63\n node`uv__run_timers+0x66\n node`uv__run+0x1b\n node`uv_run+0x17\n node`_ZN4node5StartEiPPc+0x1d0\n node`main+0x1b\n node`_start+0x83\n\n\n# Versioning\n\nThe scheme I follow is most succintly described by the bootstrap guys\n[here](https://github.com/twitter/bootstrap#versioning).\n\ntl;dr: All versions are `<major>.<minor>.<patch>` which will be incremented for\nbreaking backward compat and major reworks, new features without breaking\nchange, and bug fixes, respectively.\n\n\n# License\n\nMIT. See \"LICENSE.txt\".\n\n\n# See Also\n\n- Bunyan syslog support: <https://github.com/mcavage/node-bunyan-syslog>.\n- Bunyan + Graylog2: <https://github.com/mhart/gelf-stream>.\n- An example of a Bunyan shim to the Winston logging system:\n <https://github.com/trentm/node-bunyan-winston>.\n- [Bunyan for Bash](https://github.com/trevoro/bash-bunyan).\n- TODO: `RequestCaptureStream` example from restify.\n", |
| 78: | "readmeFilename": "README.md", |
| 79: | "bugs": { |
| 80: | "url": "https://github.com/trentm/node-bunyan/issues" |
| 81: | }, |
| 82: | "_id": "[email protected]", |
| 83: | "dist": { |
| 84: | "shasum": "672553b9b63e02f5201ef8556aaac6b81a020392" |
| 85: | }, |
| 86: | "_from": "[email protected]", |
| 87: | "_resolved": "https://registry.npmjs.org/bunyan/-/bunyan-0.21.1.tgz" |
| 88: | } |
