{"_id":"book","_rev":"96256","name":"book","description":"flexible node.js logging library","dist-tags":{"latest":"1.3.3"},"maintainers":[{"name":"defunctzombie","email":""}],"time":{"modified":"2021-06-03T10:32:10.000Z","created":"2012-05-09T10:54:32.045Z","1.3.3":"2017-09-24T19:08:58.141Z","1.3.2":"2016-11-27T03:11:47.293Z","1.3.1":"2013-12-06T17:52:40.250Z","1.3.0":"2013-01-24T18:45:27.801Z","1.2.0":"2012-05-26T14:22:24.853Z","1.1.0":"2012-05-10T22:32:36.390Z","1.0.0":"2012-05-09T10:54:32.045Z"},"users":{},"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"repository":{"type":"git","url":"git://github.com/defunctzombie/node-book.git"},"versions":{"1.3.3":{"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"name":"book","description":"flexible node.js logging library","version":"1.3.3","repository":{"type":"git","url":"git://github.com/defunctzombie/node-book.git"},"keywords":["logging","logger","log"],"main":"logger.js","scripts":{"test":"mocha"},"dependencies":{"error-stack-parser":"1.3.6"},"devDependencies":{"mocha":"3.2.0"},"optionalDependencies":{},"engines":{"node":"*"},"gitHead":"da92ccfd284989e77b3beb78467b4a5202b5d200","bugs":{"url":"https://github.com/defunctzombie/node-book/issues"},"homepage":"https://github.com/defunctzombie/node-book#readme","_id":"book@1.3.3","_npmVersion":"5.0.4","_nodeVersion":"8.1.3","_npmUser":{"name":"defunctzombie","email":"shtylman@gmail.com"},"dist":{"shasum":"53654254bfe083db102e461544ae9f84be199985","size":6418,"noattachment":false,"key":"/book/-/book-1.3.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/book/download/book-1.3.3.tgz"},"maintainers":[{"name":"defunctzombie","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/book-1.3.3.tgz_1506280138049_0.2092839682009071"},"directories":{},"publish_time":1506280138141,"_hasShrinkwrap":false,"_cnpm_publish_time":1506280138141},"1.3.2":{"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"name":"book","description":"flexible node.js logging library","version":"1.3.2","repository":{"type":"git","url":"git://github.com/defunctzombie/node-book.git"},"keywords":["logging","logger","log"],"main":"logger.js","scripts":{"test":"mocha"},"dependencies":{"error-stack-parser":"1.3.6"},"devDependencies":{"mocha":"3.2.0"},"optionalDependencies":{},"engines":{"node":"*"},"gitHead":"ed83a0ac4a885d406f83919345091295b956a130","bugs":{"url":"https://github.com/defunctzombie/node-book/issues"},"homepage":"https://github.com/defunctzombie/node-book#readme","_id":"book@1.3.2","_shasum":"16fe207349a0efd5ca8cfc307316305c438afc5a","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.2.0","_npmUser":{"name":"defunctzombie","email":"shtylman@gmail.com"},"dist":{"shasum":"16fe207349a0efd5ca8cfc307316305c438afc5a","size":6421,"noattachment":false,"key":"/book/-/book-1.3.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/book/download/book-1.3.2.tgz"},"maintainers":[{"name":"defunctzombie","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/book-1.3.2.tgz_1480216307066_0.6153102607931942"},"directories":{},"publish_time":1480216307293,"_cnpm_publish_time":1480216307293,"_hasShrinkwrap":false},"1.3.1":{"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"name":"book","description":"flexible node.js logging library","version":"1.3.1","repository":{"type":"git","url":"git://github.com/shtylman/node-book.git"},"keywords":["logging","logger","log"],"main":"logger.js","scripts":{"test":"mocha"},"dependencies":{},"devDependencies":{"mocha":"1.8.x"},"optionalDependencies":{},"engines":{"node":"*"},"readmeFilename":"README.md","bugs":{"url":"https://github.com/shtylman/node-book/issues"},"homepage":"https://github.com/shtylman/node-book","_id":"book@1.3.1","dist":{"shasum":"3194fb229bd8748d6bde3c69b0badfed5f58a13d","size":6505,"noattachment":false,"key":"/book/-/book-1.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/book/download/book-1.3.1.tgz"},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"shtylman","email":"shtylman@gmail.com"},"maintainers":[{"name":"defunctzombie","email":""}],"directories":{},"publish_time":1386352360250,"_cnpm_publish_time":1386352360250,"_hasShrinkwrap":false},"1.3.0":{"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"name":"book","description":"flexible node.js logging library","version":"1.3.0","repository":{"type":"git","url":"git://github.com/shtylman/node-book.git"},"keywords":["logging","logger","log"],"main":"logger.js","scripts":{"test":"mocha"},"dependencies":{},"devDependencies":{"mocha":"1.8.x"},"optionalDependencies":{},"engines":{"node":"*"},"readmeFilename":"README.md","_id":"book@1.3.0","dist":{"shasum":"06f0c98749e888d51fb43de3b0e0e294c047965d","size":6590,"noattachment":false,"key":"/book/-/book-1.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/book/download/book-1.3.0.tgz"},"_npmVersion":"1.1.70","_npmUser":{"name":"shtylman","email":"shtylman@gmail.com"},"maintainers":[{"name":"defunctzombie","email":""}],"directories":{},"publish_time":1359053127801,"_cnpm_publish_time":1359053127801,"_hasShrinkwrap":false},"1.2.0":{"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"name":"book","description":"flexible node.js logging library","version":"1.2.0","repository":{"type":"git","url":"git://github.com/shtylman/node-book.git"},"keywords":["logging","logger","log"],"main":"logger.js","scripts":{"test":"mocha"},"dependencies":{},"devDependencies":{"mocha":">=1.0.0"},"optionalDependencies":{},"engines":{"node":"*"},"_npmUser":{"name":"shtylman","email":"shtylman@gmail.com"},"_id":"book@1.2.0","_engineSupported":true,"_npmVersion":"1.1.12","_nodeVersion":"v0.6.14","_defaultsLoaded":true,"dist":{"shasum":"fcd119064a6cdd7d91b4e31b64187824d76e9de5","size":6622,"noattachment":false,"key":"/book/-/book-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/book/download/book-1.2.0.tgz"},"maintainers":[{"name":"defunctzombie","email":""}],"directories":{},"publish_time":1338042144853,"_cnpm_publish_time":1338042144853,"_hasShrinkwrap":false},"1.1.0":{"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"name":"book","description":"flexible node.js logging library","version":"1.1.0","repository":{"type":"git","url":"git://github.com/shtylman/node-book.git"},"keywords":["logging","logger","log"],"main":"logger.js","scripts":{"test":"mocha"},"dependencies":{},"devDependencies":{"mocha":">=1.0.0"},"optionalDependencies":{},"engines":{"node":"*"},"_npmUser":{"name":"shtylman","email":"shtylman@gmail.com"},"_id":"book@1.1.0","_engineSupported":true,"_npmVersion":"1.1.12","_nodeVersion":"v0.6.14","_defaultsLoaded":true,"dist":{"shasum":"1254d234fe90734fff3083a457fec269c771ac4c","size":5930,"noattachment":false,"key":"/book/-/book-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/book/download/book-1.1.0.tgz"},"maintainers":[{"name":"defunctzombie","email":""}],"directories":{},"publish_time":1336689156390,"_cnpm_publish_time":1336689156390,"_hasShrinkwrap":false},"1.0.0":{"author":{"name":"Roman Shtylman","email":"shtylman@gmail.com"},"name":"book","description":"flexible node.js logging library","version":"1.0.0","repository":{"type":"git","url":"git://github.com/shtylman/node-book.git"},"keywords":["logging","logger","log"],"main":"logger.js","scripts":{"test":"mocha"},"dependencies":{},"devDependencies":{"mocha":">=1.0.0"},"_npmUser":{"name":"shtylman","email":"shtylman@gmail.com"},"_id":"book@1.0.0","optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.12","_nodeVersion":"v0.6.14","_defaultsLoaded":true,"dist":{"shasum":"fb8be526a3f5e616dc9b9432ef77ac5e5bc94b7c","size":5827,"noattachment":false,"key":"/book/-/book-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/book/download/book-1.0.0.tgz"},"maintainers":[{"name":"defunctzombie","email":""}],"directories":{},"publish_time":1336560872045,"_cnpm_publish_time":1336560872045,"_hasShrinkwrap":false}},"readme":"# book [![Build Status](https://secure.travis-ci.org/defunctzombie/node-book.svg?branch=master)](http://travis-ci.org/defunctzombie/node-book) #\n\nbook is a flexible and extensible logging library for node.js\n\nInstead of trying to solve the problem of figuring out what and how you want to do logging in your project, book provides some basic functions for you to customize and create the logging system you want. Think of it like middleware, except for logging.\n\n## install\n\n```\nnpm install book\n```\n\n## quickstart\n\nTo get started with basic logging, just ```require('book')``` and start logging!\n\n```javascript\nvar log = require('book');\n\n// You can now log using the methods: panic, error, warn, info, debug, trace\nlog.info('haters be loggin');\n```\n\nWill output (on stdout):\n```\n[info] haters be loggin\n```\n\n## how to log\n\nBelow are the basics of logging using the default logger.\n\nThere are 6 log levels ( panic | error | warn | info | debug | trace ). See the examples.\n\nThe arguments you pass to the logging functions will determine how they are processed.\n\n```javascript\n// if the first argument is a string, it is assumed to be a format string\n// it will consume all of the remaining arguments when formatting\nlog.info('hello world');\n[info] hello world\n\nlog.info('secret: %d', 42);\n[info] secret 42\n\nlog.info('json: %j', { secret: 42 });\n[info] { \"secret\": 42 }\n```\n\n```javascript\n// if the first argument is an Error\n// the logger will capture the stacktrace into error.stack of the final log entry\nlog.error(new Error('fail!'));\n[error] fail!\n\n// any arguments after the first Error arg are processed as if they appeared as the first\n// you can capture an error and print other messages\nlog.error(new Error('again?'), 'another %s', 'cat');\n[error] another cat\n```\n\n```javascript\n// lastly, the first argument can be an object\n// this will cause the fields of the object to the added to the fields of the final log entry\n// after the first arguments, remaining arguments are again treated as if they were the first\nlog.warn({ something: 'bad' }, 'foo %s', 'bar');\n\n// will print the message 'foo bar', however the {something: 'bad'} object can be accessed in your custom middleware as you please.\n[warn] foo bar\n```\n\nNote: Only when a string is encountered are all of the remaining arguments consumed. Until then, each argument is processed independently as if it appeared first.\n\nIf you want your logs to go to a file, use the [book-file](https://github.com/defunctzombie/node-book-file) module.\n\n## options\n\nThe default logging setup will write logs to stdout. If you would like to disable this behavior use the following:\n\n```javascript\nvar log = require('book').default({\n  stdout: false\n});\n```\n\nThis will give you a new default logger with no output to stdout. For more flexible configuration read about middleware below.\n\n## middleware\n\nThe entire functionality of the default logger is built using middleware. These create pipeline of 'features' for the logger. You can customize loggers to include/exclude any features you want. Middleware can add fields to the logging output our it can act as a transport to send the log entry someplace else.\n\nThe 'default' logger is simply a certain selection of middleware provided with the library. You are not required to use it and can roll your own custom solution.\n\n### make your own\n\nMiddleware is simply a function which will do some processing on the logging entry. It is passed all of the arguments of the original log call (info, error, etc) and the 'this' is set to the logging entry. Your middleware should modify the fields of 'this' to add or remove relevant entries.\n\n```javascript\n// simple middleware that adds a timestamp to the entry\nfunction sample_middleware() {\n  var entry = this;\n\n  // this is the only provided field\n  // set to [0..5] 0=panic, by the called log functions\n  // usually you won't change this\n  entry.level;\n\n  // add a new field to our entry\n  entry.timestamp = Date.now();\n}\n```\n\nDecorators are processed in the order you push them onto a logger.\n\n### using your middleware\n\n```javascript\n// book.blank creates a logging object with no middleware\nvar log = require('book').blank();\n\n// remember, middleware is processed in the order you use it\nlog.use(sample_middleware);\n\n// you can now call any of the logging functions\nlog.info('hello');\n\n// output will depend on any middleware you have added\n// use any of the provided middleware to build up your own logger\n```\n\n### attaching middleware\n\nYou can add middleware to the default logger similar to the blank logger above. Lets say we want to provide out own middleware to print to stdout. We can disable the default stdout and provide out own.\n\n```javascript\n// create a default logger with no stdout middleware\nvar log = require('book').default({\n  stdout: false\n});\n\nlog.use(function() {\n  var entry = this;\n\n  // our own code for printing to stdout\n  // console.log(...);\n});\n\n// this will use our own stdout middleware\nlog.info('hello world!');\n```\n\n### provided middleware\n\nBook ships with some builtin middleware. You can access it with:\n\n```javascript\nvar book_middleware = require('book').middleware;\n```\n\nThe default logger is composed from this middleware. Use a blank logger if you want to pick and choose which ones to use.\n\n#### base\n> provides the basic argument processing outlined above\n\n#### trace\n> provides tracing where the log line was called. Adds 'filename' and 'lineno' fields to the log entry.\n  This is different from the stack trace of Errors. This is the filename and lineno of the call site of the log line.\n\n#### stdout\n> basic printing to console\n\n#### hostname\n> inserts a 'hostname' field into the entry\n\n#### timestamp\n> inserts a 'timestamp' entry (seconds using Date.now()/1000.0)\n\n### middleware modules ###\n\nThere are a number of npm modules which provide various transports and other logging features.\n\n#### book-file ####\n\n[book-file](https://github.com/defunctzombie/node-book-file) records your log entries to a file.\n\nYou can add the file transport to your logger using the following:\n\n```javascript\nlog.use(require('book-file')({\n      filename: '/path/to/file.log'\n});\n```\n\n#### book-email ####\n\n[book-email](https://github.com/defunctzombie/node-book-email) sends your log messages over email.\n\n#### book-git ####\n\n[book-git](https://github.com/defunctzombie/node-book-git) adds a ```commit``` field to your log entry which has the deployed git commit id.\n","_attachments":{},"homepage":"https://github.com/defunctzombie/node-book#readme","bugs":{"url":"https://github.com/defunctzombie/node-book/issues"}}