{"_id":"evented-logger","_rev":"941505","name":"evented-logger","description":"An evented console logger","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"augustl","email":"august@augustl.com"},{"name":"dominykas","email":"hello@dominykas.com"},{"name":"dwittner","email":"d.wittner@gmx.de"}],"time":{"modified":"2021-09-23T02:07:51.000Z","created":"2013-09-16T22:33:42.198Z","1.0.1":"2015-11-14T22:20:44.359Z","1.0.0":"2013-09-16T22:33:42.198Z"},"users":{},"author":{"name":"Christian Johansen"},"repository":{"type":"git","url":"git+https://github.com/busterjs/evented-logger.git"},"versions":{"1.0.1":{"name":"evented-logger","version":"1.0.1","description":"An evented console logger","homepage":"http://busterjs.org/docs/evented-logger","author":{"name":"Christian Johansen"},"contributors":[{"name":"Christian Johansen","email":"christian@cjohansen.no","url":"http://cjohansen.no"},{"name":"August Lilleaas","email":"august.lilleaas@gmail.com","url":"http://augustl.com"},{"name":"Stein Magnus Jodal","email":"stein.magnus@jodal.no"}],"license":"BSD-3-Clause","main":"./lib/evented-logger","repository":{"type":"git","url":"git+https://github.com/busterjs/evented-logger.git"},"scripts":{"test":"grunt test"},"dependencies":{"lodash":"3.x","bane":"1.x"},"devDependencies":{"grunt":"0.4.x","grunt-buster":"0.4.x","grunt-cli":"0.1.x","buster":"0.7.x","phantomjs":"1.9.x"},"gitHead":"1a606f83ab3ced4a0a88c1985d5bcc795b4e8d44","bugs":{"url":"https://github.com/busterjs/evented-logger/issues"},"_id":"evented-logger@1.0.1","_shasum":"9fed59c5cecc87316ecefdb95fbe910f03e636a7","_from":".","_npmVersion":"3.3.12","_nodeVersion":"4.2.2","_npmUser":{"name":"dominykas","email":"hello@dominykas.com"},"dist":{"shasum":"9fed59c5cecc87316ecefdb95fbe910f03e636a7","size":6081,"noattachment":false,"key":"/evented-logger/-/evented-logger-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/evented-logger/download/evented-logger-1.0.1.tgz"},"maintainers":[{"name":"augustl","email":"august@augustl.com"},{"name":"dominykas","email":"hello@dominykas.com"},{"name":"dwittner","email":"d.wittner@gmx.de"}],"directories":{},"publish_time":1447539644359,"_cnpm_publish_time":1447539644359,"_hasShrinkwrap":false,"deprecated":"No longer maintained"},"1.0.0":{"name":"evented-logger","version":"1.0.0","description":"An evented console logger","homepage":"http://busterjs.org/docs/evented-logger","author":{"name":"Christian Johansen"},"contributors":[{"name":"Christian Johansen","email":"christian@cjohansen.no","url":"http://cjohansen.no"},{"name":"August Lilleaas","email":"august.lilleaas@gmail.com","url":"http://augustl.com"},{"name":"Stein Magnus Jodal","email":"stein.magnus@jodal.no"}],"main":"./lib/evented-logger","repository":{"type":"git","url":"https://github.com/busterjs/evented-logger.git"},"scripts":{"test":"./node_modules/buster/bin/buster-test --node"},"dependencies":{"lodash":"~1.0","bane":"~1.0"},"devDependencies":{"buster":"0.6.11"},"_id":"evented-logger@1.0.0","dist":{"shasum":"26f6a702c5b9b5e07abac65f5aeb37ae5c2b9029","size":5807,"noattachment":false,"key":"/evented-logger/-/evented-logger-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/evented-logger/download/evented-logger-1.0.0.tgz"},"maintainers":[{"name":"augustl","email":"august@augustl.com"},{"name":"dominykas","email":"hello@dominykas.com"},{"name":"dwittner","email":"d.wittner@gmx.de"}],"directories":{},"publish_time":1379370822198,"_hasShrinkwrap":false,"deprecated":"No longer maintained","_cnpm_publish_time":1379370822198}},"readme":"# evented-logger\n\n[![Build status](https://secure.travis-ci.org/busterjs/evented-logger.png?branch=master)](http://travis-ci.org/busterjs/evented-logger)\n\n> Event emitting logger with custom log events\n\n`evented-logger` is an event emitting logger utility. It does not print\nanything to the stdout or anywhere else, it only emits events. You can create\nlogger objects with arbitrary levels, set the current level and subscribe to\nevents to print them somewhere visible. Logged messages are formatted by a\npluggable formatter (e.g. something like [formatio](http://search.npmjs.org/#/formatio)).\n\n`evented-logger` works in browsers (including old and rowdy ones, like IE6)\nand Node. It will define itself as an AMD module if you want it to (i.e. if\nthere's a `define` function available).\n\n\n## Developers - Running tests\n\n```\nnpm install\n./node_modules/.bin/buster-test --node\n./node_modules/.bin/buster-server\n./node_modules/.bin/buster-test --browser\n```\n\n## Events\n\n### Event: `\"log\", function (envelope) {}`\n\nEmitted every time data is logged and is allowed by the current log level. Any\nmessages logged to the current level or a higher priority level will be emitted.\n\n\n## Methods\n\nParts of the logger API is dynamically assembled by the `create` method. The\nAPI documentation also describes the methods dynamically generated by this\nmethod in the default setup.\n\n### `eventedLogger.create([options])`\n\nCreates a new logger. The default behavior is to create a logger with the\nlevels/methods `error`, `warn`, `log` and `debug`. `\"debug\"` is\nthe default log level, meaning that all messages are emitted.\n\nThe `options` argument can be used to control what logging methods the\nlogger should have, default logging level and formatting method.\n\n\n**Typical usage**\n\n```javascript\nvar logger = eventedLogger.create();\n\nlogger.on(\"log\", function (msg) {\n    console.log(\"[\" + msg.level.toUpperCase() + \"] \" + msg.message);\n});\n\nlogger.warn(\"Watch it!\");\nlogger.log([], 42, {});\n\n// Prints the following to stdout:\n// [WARN] Watch it!\n// [LOG] [] 42 {}\n```\n\n\n**Setting the default level**\n\n```javascript\nvar logger = eventedLogger.create({ level: \"warn\" });\n\nlogger.on(\"log\", function (msg) {\n    console.log(\"[\" + msg.level.toUpperCase() + \"] \" + msg.message);\n});\n\nlogger.warn(\"Watch it!\");\nlogger.log([], 42, {});\n\n// Will not print the log message, so stdout looks like:\n// [WARN] Watch it!\n```\n\n\n**Creating custom loggers**\n\nCustom levels should be passed ordered from highest to lowest severity. The\ngenerated methods will pass through messages if the current log level is set\nto either the same level as the message or one in the lower indexes of the\nlevels array.\n\nWhen you create a logger with customized levels, the default log level will\nbe set to the most permissive one, i.e. the last level in the array.\n\n```javascript\nvar logger = eventedLogger.create({\n    levels: [\"nuclear\", \"eerie\", \"info\", \"debug\"]\n});\n\nlogger.level == \"debug\"; //=&gt; true\ntypeof logger.error == \"undefined\";\n\nlogger.nuclear(\"This is NOT good\");\n```\n\nIf you want the logger to have some other default log level than the most\npermissive one, include `level`:\n\n```javascript\nvar logger = eventedLogger.create({\n    levels: [\"nuclear\", \"eerie\", \"info\", \"debug\"],\n    level: \"eerie\"\n});\n\nlogger.info(\"This is NOT good\"); // Won't be emitted\n```\n\n\n### `eventedLogger.format(object)`\n\nFormats a logged object. This function is called once for each argument\npassed to a logger method. The default implementation serializes objects\nthrough `JSON.stringify <https://developer.mozilla.org/en/json>`_. Functions\nand primitives are converted to strings by way of their `toString`\nmethods.\n\nThe method can be overridden to provide more powerful formatting of objects\nsuch as functions and problematic host objects.\n\n`buster-test <http://busterjs.org/docs/test/>`_ provides more readable\nformatting through the `formatio <http://busterjs.org/docs/format>`_ module.\nThere is basically three ways to achieve this:\n\n\n**Override the original method**\n\n```javascript\neventedLogger.format = buster.format.ascii;\n```\n\n\n**Override the method on an instance**\n\n```javascript\nvar logger = eventedLogger.create();\nlogger.format = buster.format.ascii;\n```\n\n\n**Pass the formatter to `create`**\n\n```javascript\nvar logger = eventedLogger.create({\n    logger: buster.format.ascii\n});\n```\n\n\n### `eventedLogger.error(message1[, message2, ...])`\n\nLogs messages with the `\"error\"` level. Messages will always be emitted\nfrom the logger unless the log level has been set to a non-existent level.\n\n```javascript\nvar logger = eventedLogger.create();\n// ...\n\nlogger.error(\"Something went wrong\", myObjToDebug);\n```\n\n> If you have created a logger with custom levels, the `error` method\nwill not exist unless you explicitly included it.\n\n\n### `eventedLogger.warn(message1[, message2, ...])`\n\nLogs messages with the `\"warn\"` level. This message will be emitted from\nthe logger unless its level is set to `\"error\"` or a non-existent level.\n\n```javascript\nvar logger = eventedLogger.create();\n// ...\n\nlogger.warn(\"Something fishy?\", myObjToDebug);\n```\n\n> If you have created a logger with custom levels, the `warn` method\nwill not exist unless you explicitly included it.\n\n\n### `eventedLogger.log(message1[, message2, ...])`\n\nLogs messages with the `\"log\"` level. This message will be emitted from\nthe logger if its level is set to `\"log\"` or `\"debug\"` (default).\n\n```javascript\nvar logger = eventedLogger.create();\n// ...\n\nlogger.log(\"Here's an object\", myObjToDebug);\n```\n\n> If you have created a logger with custom levels, the `log` method\nwill not exist unless you explicitly included it.\n\n\n### `eventedLogger.debug(message1[, message2, ...])`\n\nLogs messages with the `\"debug\"` level. This message will only be emitted\nfrom the logger if its level is set to `\"debug\"` (default).\n\n```javascript\nvar logger = eventedLogger.create();\n// ...\n\nlogger.debug(\"What's going on??\", myObjToDebug);\n```\n\n> If you have created a logger with custom levels, the `debug`\nmethod will not exist unless you explicitly included it.\n\n\n## Properties\n\n## `eventedLogger.level`\n\nDefault: `\"debug\"`\n\nSet the level of the logger, silence all messages for less severe levels.\nThe default level is the most permissive one - `\"debug\"` when not using\ncustom levels.\n\n\n## Supporting objects\n\n### `eventedLoggerEnvelope`\n\nAn object representing a logged message. Contains two properties:\n\n* `level`:\n    The log level as a lower case string, e.g. `\"debug\"`\n\n* `message`:\n    A formatted log message, containing all arguments passed to the log\n    method joined by a single blank space.\n\n\n### `eventedLoggerOptions`\n\nOptions passed to [`eventedLogger.create`](#eventedloggercreateoptions).\n\n* `level`:\n    The default log level, i.e. the minimum required level the logger will\n    emit events for. Default value is `\"debug\"`, i.e. all messages.\n\n* `levels`:\n    An array of levels the logger supports. Default is `[\"error\", \"warn\",\n    \"log\", \"debug\"]`. Each string in this array names methods created on\n    the logger.\n\n* `formatter`:\n    The function that should format arguments.\n    See [`eventedLogger.format`](#eventedloggerformatobject).\n","_attachments":{},"homepage":"http://busterjs.org/docs/evented-logger","bugs":{"url":"https://github.com/busterjs/evented-logger/issues"},"license":"BSD-3-Clause"}