{"id":19753218,"url":"https://github.com/philmander/browser-bunyan","last_synced_at":"2025-04-05T12:05:54.889Z","repository":{"id":36785428,"uuid":"41092189","full_name":"philmander/browser-bunyan","owner":"philmander","description":"An adaptation of, the Node logging library, Bunyan specifically for the browser.","archived":false,"fork":false,"pushed_at":"2023-04-06T21:21:02.000Z","size":3560,"stargazers_count":93,"open_issues_count":29,"forks_count":21,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T11:10:26.050Z","etag":null,"topics":["bunyan","bunyan-logger","logging"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philmander.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-20T11:28:23.000Z","updated_at":"2025-03-17T06:07:04.000Z","dependencies_parsed_at":"2024-12-29T07:13:17.605Z","dependency_job_id":"62c2b3dd-74bf-46d8-b557-a326c3e52a1c","html_url":"https://github.com/philmander/browser-bunyan","commit_stats":{"total_commits":642,"total_committers":45,"mean_commits":"14.266666666666667","dds":0.3021806853582555,"last_synced_commit":"ae93bab13832baf15b575c17f202462b11c2bfbd"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philmander%2Fbrowser-bunyan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philmander%2Fbrowser-bunyan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philmander%2Fbrowser-bunyan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philmander%2Fbrowser-bunyan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philmander","download_url":"https://codeload.github.com/philmander/browser-bunyan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332604,"owners_count":20921853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bunyan","bunyan-logger","logging"],"created_at":"2024-11-12T02:52:11.165Z","updated_at":"2025-04-05T12:05:54.857Z","avatar_url":"https://github.com/philmander.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"browser-bunyan\n===========\n\n[![Build Status](https://travis-ci.org/philmander/browser-bunyan.svg?branch=master)](https://travis-ci.org/philmander/browser-bunyan)\n[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/)\n\n\nThis package is an adaptation of, the Node logging library, [Bunyan](https://github.com/trentm/node-bunyan) but specifically for the browser.\n\nAlthough Bunyan does support being [Browserified](https://github.com/trentm/node-bunyan#browserify), it is still a bit bloated with\nfeatures which aren't relevant in a browser environment.  You can expect a Browserified and Gzipped `node-bunyan` to\nbe around **27kb** whereas `browser-bunyan` is **3.5kb**, including its built-in log streams. With ES Modules and\ntree-shaking this can be reduced further.\n\n## Current status\n\nBrowser Bunyan was originally forked from an already mature library with a rich feature set and stable API. Furthermore, the browser environment is less complex than the server (no real streams etc). Consequently, I've found it doesn't need much work. Hopefully this is a testament to the quality of the codebase. So, don't be too concerned if you don't see that much activity in this repo. Please do raise issues for bugs, feature requests and ideas.\n\n## Install\n\n```\nnpm install browser-bunyan --save\n```\n\n## Usage\n\n### Import\n\nYou can access Browser Bunyan's API using:\n\n#### ES modules:\n\n```javascript\nimport { createLogger } from 'browser-bunyan';\nconst logger = createLogger({ name: 'my-logger' });\nlogger.info('hi on info');\n```\n\n#### CommonJS\n\n```javascript\nconst { createLogger } = require('browser-bunyan');\nconst logger = createLogger({ name: 'my-logger' });\nlogger.debug('hi on debug');\n```\n\n#### Browser global\n\nTo use as a **global**, include as a standard script tag:\n\n```html\n\u003cscript src=\"https://unpkg.com/browser-bunyan@1.4.0/lib/index.umd.js\"\u003e\u003c/script\u003e\n```\n\nnow `bunyan` will be available as a global.\n\n```javascript\nconst logger = bunyan.createLogger({ name: 'my-logger' });\nlogger.warn('hi on warning');\n```\n\n### Built-in Log Streams\n\nBunyan uses \"log streams\" to customize how each log record is processed.\nYou can write your own to do whatever you want or use the built-in log streams\nwhich output log records to the console:\n\n#### Console Formatted Stream\n\nThe core library also includes a dedicated browser console stream with nice formatting:\n\n\u003cimg src=\"examples/browser-bunyan.png\"\u003e\n\nUse it like this:\n\n```javascript\nimport { createLogger, INFO, stdSerializers } from 'browser-bunyan';\nimport { ConsoleFormattedStream } from '@browser-bunyan/console-formatted-stream';\n\nconst log = createLogger({\n    name: 'myLogger',\n    streams: [\n        {\n            level: INFO, // or use the string 'info'\n            stream: new ConsoleFormattedStream()\n        }\n    ],\n    serializers: stdSerializers,\n    src: true,\n});\n\nlog.info('hi on info');\n```\n\u003ca id=logByLevel\u003e\u003c/a\u003e\n##### logByLevel\n\nBy default this stream will use `console.log` for all logging. Pass the option `logByLevel` to the\n`ConsoleFormattedStream` constructor to use the Console API's level specific logging methods ([`console.error`](https://developers.google.com/web/tools/chrome-devtools/console/console-reference#error), [`console.warn`](https://developers.google.com/web/tools/chrome-devtools/console/console-reference#warn), [`console.info`](https://developers.google.com/web/tools/chrome-devtools/console/console-reference#consoleinfoobject_object) and [`console.debug`](https://developers.google.com/web/tools/chrome-devtools/console/console-reference#consoledebugobject_object)). E.g.\n\n```javascript\nnew ConsoleFormattedStream( { logByLevel: true } );\n```\n\nPlease note that if you use this option your browser's console may also filter\nout log output based on level, in addition to the Bunyan stream's log level.\n\n##### Colors\n\nThe colors/css used by `ConsoleFormattedStream` are customizable:\n\n```javascript\nnew ConsoleFormattedStream({\n    css: {\n        levels : {\n            trace: 'color: DeepPink',\n            debug: 'color: GoldenRod',\n            info: 'color: DarkTurquoise',\n            warn: 'color: Purple',\n            error: 'color: Crimson',\n            fatal: 'color: Black',\n        },\n        def: 'color: DimGray',\n        msg : 'color: SteelBlue',\n        src : 'color: DimGray; font-style: italic; font-size: 0.9em',\n    }\n});\n```\n\nor\n\n```javascript\nconst css = ConsoleFormattedStream.getDefaultCss();\ncss.msg = 'color: cyan';\nnew ConsoleFormattedStream({ css });\n```\n\n#### Console Raw Stream\n\nThis logs the raw log record objects directly to the console.\n\n```javascript\nimport { createLogger, INFO } from 'browser-bunyan';\nimport { ConsoleRawStream } from '@browser-bunyan/console-raw-stream';\n\nconst log = createLogger({\n    name: 'myLogger',\n    stream: {\n        level: INFO,\n        stream: new ConsoleRawStream(),\n    }\n});\n```\n\n#### Console Plain Stream\n\nThis stream is similar to `ConsoleFormattedStream` but does not have colors. This\nis useful for environments where the console does not support\n [console styling with CSS (`%c`)](https://developers.google.com/web/tools/chrome-devtools/console/console-write#styling_console_output_with_css).\n\n```javascript\nimport { createLogger, INFO } from 'browser-bunyan';\nimport { ConsolePlainStream } from '@browser-bunyan/console-plain-stream';\n\nconst log = createLogger({\n    name: 'myLogger',\n    stream: {\n        level: INFO,\n        stream: new ConsolePlainStream()\n    }\n});\n```\n\n##### logByLevel\n\nThe `logByLevel` option is supported in the same way as [`ConsoleFormattedStream`](#logByLevel).\n\n### Additional log streams\n\nThese streams are not built in to the main Browser Bunyan build. You must install them\nseparately.\n\n#### Server Stream\n\nThe Server Stream sends log records to a server endpoint. You will typically want\nto set the log level for server streams to `warn`, `error` or `fatal` - log records\nthat are for exceptions.\n\n##### Install\n\n`npm install @browser-bunyan/server-stream`\n\nTo use as a global include the script tag:\n\n```html\n\u003cscript src=\"https://unpkg.com/@browser-bunyan/server-stream@1.4.0/lib/index.umd.js\"\u003e\u003c/script\u003e\n```\n\n##### Usage\n\n```javascript\nimport { createLogger, WARN } from 'browser-bunyan';\nimport { ServerStream } from '@browser-bunyan/server-stream';\n\n\nconst log = createLogger({\n    name: 'serverLogger',\n    stream: {\n        level: WARN,\n        stream: new ServerStream({\n            url: '/client-log',\n            method: 'PUT',\n        }),\n    },\n});\n```\n\n##### Notes\n\n* The browser's current url and user agent string will automatically be appended to the\nlog record.\n* Log records are sent to the server in JSON batches (an array of record objects) at a defined `throttleInterval`.\n* If, within a batch, a log message is duplicated, that log record will be deduped and a `count` field is incremented for the single log record\n* The `flushOnClose` option will flush any unsent log records if the browser window/tab is closed. Internally this requires Fetch API to be supported.\n* A `writeCondition` function determines if the latest batch of records should\nbe sent. By default, log records will not be sent if the browser is offline\n(`navigator.onLine === false`) or the current user agent is determined to be a bot/crawler. You may add your own write conditions in addition to the default conditions like so:\n\n  ```javascript\n  new ServerStream({\n     url: '/client-log',\n     method: 'POST',\n     writeCondition: record =\u003e {\n        return ServerStream.defaultWriteCondition() \u0026\u0026 record.msg !== 'GrikkleGrass';\n     },\n  })\n  ```\n\n##### Options\n\n| Option              | Default    | Description |\n| ------------------- |----------- | ------------------------------------------------- |\n| `url`               | `/log`       | Endpoint to send log record batches to (as JSON) |\n| `method`            | `PUT`        | HTTP method to send record payload with |\n| `headers`           | `{ Content-Type': 'application/json }` | Custom HTTP request headers (in addition to the default) |\n| `withCredentials`   | `false`    | `withCredentials` property of the underlying `XMLHttpRequest` object |\n| `throttleInterval`  | `3000`       | How often to send log record batches (ms) |\n| `writeCondition`    | `ServerLogStream.defaultWriteCondition` | A function which must return a boolean. `true` if the log record can be written. i.e. included in the next batch to send. |\n| `onError`           | -          | A handler function to invoke if the send request fails |\n| `flushOnClose`      | `false`    | **Experimental** Send unsent log records if the browser window is closed |\n\n\n### Custom log streams\n\nSee the Node Bunyan docs below for more information on how to create you own custom stream(s).\n\nThis [gist for a \"server-stream\"](https://gist.github.com/philmander/7788b680acb776bab4ae67df63db227a) is also good example of how to write a log stream that sends log records to the server.\n\n## Browser specific features\n\n#### Logging objects to the console\n\nAs per, Bunyan's [log API](#log-method-api), if you log an object under the\nfield `obj` as the first argument, Browser Bunyan's built-in log streams will log this object\ndirectly to the console:\n\n```\nvar myObject = { x: 1, y: 2 };\nlogger.info({ obj: myObject }, 'This is my object:');\n```\n\n#### Stream types\n\nNode Bunyan supports various [types of streams](#streams-introduction). In Browser Bunyan, streams\nare always of type 'raw'.\n\n## Features shared with Node Bunyan\n\n**The following docs are the [node-bunyan](https://github.com/trentm/node-bunyan) docs at time of forking, with necessary\nmodifications and documentation for the stripped features also removed:**\n\n### Overview of features\n\n- elegant [log method API](#log-method-api)\n- extensible [streams](#streams) system for controlling where log records\n  go (to the console, local storage, the server, etc)\n  [`src: true`](#src)\n- lightweight specialization of Logger instances with [`log.child`](#logchild)\n- custom rendering of logged objects with [\"serializers\"](#serializers)\n\n\n### Introduction\n\nLike most logging libraries you create a Logger instance and call methods\nnamed after the logging levels:\n\n```javascript\nconst { createLogger } = require('browser-bunyan');\nconst log = createLogger({name: 'myapp'});\nlog.info('hi');\nlog.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\"time\" and \"v\".\n\n```json\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## Constructor API\n\n```javascript\nconst { createLogger } = require('browser-bunyan');\nconst log = createLogger({\n    name: \u003cstring\u003e,                     // Required\n    level: \u003clevel constant or string\u003e,  // Optional, see \"Levels\" section\n    stream: \u003cLogStream\u003e,                // Optional, see \"Streams\" section\n    streams: \u003cStreamOptions[]\u003e          // Optional, see \"Streams\" section\n    serializers: \u003cserializers mapping\u003e, // Optional, see \"Serializers\" section\n    src: \u003cboolean\u003e,                     // Optional, see \"Core fields\" section\n\n    // Any other fields are added to all log records as is.\n    foo: 'bar',\n    ...\n});\n```\n\n### Log Method API\n\nThe example above shows two different ways to call `log.info(...)`. The\nfull API is:\n\n```javascript\nlog.info();     // Returns a boolean: is the \"info\" level enabled?\n                // This is equivalent to `log.isInfoEnabled()` or\n                // `log.isEnabledFor(INFO)` in log4j.\n\nlog.info('hi');                     // Log a simple string message (or number).\nlog.info('hi %s', bob, anotherVar); // Uses `util.format` for msg formatting.\n\nlog.info({foo: 'bar'}, 'hi');\n                // Adds \"foo\" field to log record. You can add any number\n                // of additional fields here.\n\nlog.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.\nlog.info(err, 'more on this: %s', more);\n                // ... or you can specify the \"msg\".\n```\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`, `log.error`, and `log.fatal`. See the [levels section](#levels)\nbelow for details and suggestions.\n\n### Streams Introduction\n\nBy default, log output is to the browser console and at the \"info\" level. Explicitly that\nlooks like:\n\n```javascript\nimport { createLogger, ConsoleRawStream } from 'browser-bunyan';\nvar log = createLogger({\n    name: 'myapp',\n    stream: new ConsoleRawStream()\n    level: 'info'\n});\n```\n\nThat is an abbreviated form for a single stream. **You can define multiple\nstreams at different levels**.\n\n```javascript\nconst log = createLogger({\n  name: 'myapp',\n  streams: [\n    {\n      level: 'info',\n      stream: new ConsoleRawStream()  // log INFO and above to console\n    },\n    {\n      level: 'error',\n      path: new PostToServerStream()  // record errors on the server\n    }\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```javascript\n    const { createLogger } = require('browser-bunyan');\n    const log = 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```\n\nRunning that looks like (raw):\n\n```json\n{\"name\":\"myapp\",\"level\":30,\"msg\":\"start\",\"time\":\"2013-01-04T07:47:25.814Z\"}\n{\"name\":\"myapp\",\"widget_type\":\"wuzzle\",\"level\":30,\"msg\":\"creating a wuzzle\",\"time\":\"2013-01-04T07:47:25.815Z\"}\n{\"name\":\"myapp\",\"widget_type\":\"wuzzle\",\"level\":40,\"msg\":\"This wuzzle is woosey.\",\"time\":\"2013-01-04T07:47:25.815Z\"}\n{\"name\":\"myapp\",\"level\":30,\"msg\":\"done\",\"time\":\"2013-01-04T07:47:25.816Z\"}\n```\n\nFor streams such as *Console Formatted Stream* and *Console Plain Stream*, adding the field `childName` will display a child\nstream's name suffixed to the parent logger name. For example:\n\n```javascript\n    const log = createLogger({name: 'myapp'});\n    const childLog = log.child({widget_type: 'wuzzle', childName: 'sub'});\n    // prints \"myapp/sub\" as the name in console output\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: \u003crequest object\u003e}, '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```javascript\nfunction reqSerializer(req) {\n    return {\n        method: req.method,\n        url: req.url,\n        headers: req.headers\n    }\n}\n\nconst log = createLogger({\n    name: 'myapp',\n    serializers: {\n        req: reqSerializer\n    }\n});\n```\n\nOr this:\n```javascript\nimport { createLogger, stdSerializers } from 'browser-bunyan';\n\nconst log = createLogger({\n    name: 'myapp',\n    serializers: {req: stdSerializers.req}\n});\n```\n\nbecause Bunyan includes a small set of standard serializers. To use all the\nstandard serializers you can use:\n\n```javascript\n    import { createLogger, stdSerializers } from 'browser-bunyan';\n    const log = createLogger({\n      ...\n      serializers: stdSerializers\n    });\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### 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```javascript\nlog.level() -\u003e INFO   // gets current level (lowest level of all streams)\n\nlog.level(INFO)       // set all streams to level INFO\nlog.level(\"info\")     // set all streams to level INFO\n\nlog.levels() -\u003e [DEBUG, INFO]   // get array of levels of all streams\nlog.levels(0) -\u003e DEBUG          // get level of stream at index 0\nlog.levels(\"foo\")               // get level of stream with name \"foo\"\n\nlog.levels(0, INFO)             // set level of stream 0 to INFO\nlog.levels(0, \"info\")           // can use \"info\" et al aliases\nlog.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```json\n{\"name\":\"myapp\",\"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```\n\nPretty-printed:\n\n```json\n{\n  \"name\": \"myapp\",\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\": \"send 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- `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.\u003canonymous\u003e ...\"\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### Streams\n\nA \"stream\" is Bunyan's name for an output for log messages (the equivalent\nto a log4j Appender). A Bunyan Logger instance has one or more streams.\nIn general streams are specified with the \"streams\" option:\n\n```javascript\nconst bunyan = require('browser-bunyan');\nconst log = createLogger({\n    name: \"foo\",\n    streams: [\n        {\n            stream: new ConsoleRawStream(),\n            level: \"debug\"\n        },\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```javascript\nconst log = createLogger({\n    name: \"foo\",\n    stream: new ConsoleRawStream(),\n    level: \"debug\"\n});\n```\n\nIf neither \"streams\" nor \"stream\" are specified, the default is a stream of\ntype `ConsoleRawStream` at the \"info\" level.\n\n### stream type: `raw`\n\nNote that in browser-bunyan streams are always `raw`\n\n\n## Inegrations\n\n### Angular 1.x integration:\n\nIntegrate with Angular's log provider:\n\n```javascript\nadminApp.config(function($provide) {\n    $provide.decorator('$log', function($delegate) {\n        $delegate = bunyan.createLogger({\n            name: 'myLogger',\n            streams: [{\n                level: 'info',\n                stream: new bunyan.ConsoleFormattedStream(),\n            }]\n        });\n        return $delegate;\n    });\n});\n```\n\n## License\n\nMIT. See LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilmander%2Fbrowser-bunyan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilmander%2Fbrowser-bunyan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilmander%2Fbrowser-bunyan/lists"}