{
  "name": "winston",
  "description": "A multi-transport async logging library for Node.js",
  "version": "0.9.0",
  "author": {
    "name": "Nodejitsu Inc.",
    "email": "info@nodejitsu.com"
  },
  "maintainers": [
    {
      "name": "indexzero",
      "email": "charlie@nodejitsu.com"
    }
  ],
  "repository": {
    "type": "git",
    "url": "https://github.com/flatiron/winston.git"
  },
  "keywords": [
    "logging",
    "sysadmin",
    "tools"
  ],
  "dependencies": {
    "async": "0.9.x",
    "colors": "1.0.x",
    "cycle": "1.0.x",
    "eyes": "0.1.x",
    "isstream": "0.1.x",
    "pkginfo": "0.3.x",
    "stack-trace": "0.0.x"
  },
  "devDependencies": {
    "hock": "1.x.x",
    "std-mocks": "~1.0.0",
    "vows": "0.7.x"
  },
  "main": "./lib/winston",
  "scripts": {
    "test": "vows --spec --isolate"
  },
  "engines": {
    "node": ">= 0.8.0"
  },
  "licenses": [
    {
      "type": "MIT",
      "url": "https://raw.github.com/flatiron/winston/master/LICENSE"
    }
  ],
  "readme": "# winston [![Build Status](https://secure.travis-ci.org/flatiron/winston.svg?branch=master)](http://travis-ci.org/flatiron/winston)\n\nA multi-transport async logging library for node.js. <span style=\"font-size:28px; font-weight:bold;\">&quot;CHILL WINSTON! ... I put it in the logs.&quot;</span>\n\n## Motivation\nWinston is designed to be a simple and universal logging library with support for multiple transports. A transport is essentially a storage device for your logs. Each instance of a winston logger can have multiple transports configured at different levels. For example, one may want error logs to be stored in a persistent remote location (like a database), but all logs output to the console or a local file.\n\nThere also seemed to be a lot of logging libraries out there that coupled their implementation of logging (i.e. how the logs are stored / indexed) to the API that they exposed to the programmer. This library aims to decouple those parts of the process to make it more flexible and extensible.\n\n## Installation\n\n```bashp\nnpm install winston\n```\n\n## Usage\nThere are two different ways to use winston: directly via the default logger, or by instantiating your own Logger. The former is merely intended to be a convenient shared logger to use throughout your application if you so choose.\n\n* [Logging](#logging)\n  * [Using the Default Logger](#using-the-default-logger)\n  * [Instantiating your own Logger](#instantiating-your-own-logger)\n  * [Logging with Metadata](#logging-with-metadata)\n  * [String interpolation](#string-interpolation)\n* [Transports](https://github.com/flatiron/winston/blob/master/docs/transports.md)\n  * [Multiple transports of the same type](#multiple-transports-of-the-same-type)\n* [Profiling](#profiling)\n* [Streaming Logs](#streaming-logs)\n* [Querying Logs](#querying-logs)\n* [Exceptions](#exceptions)\n  * [Handling Uncaught Exceptions with winston](#handling-uncaught-exceptions-with-winston)\n  * [To Exit or Not to Exit](#to-exit-or-not-to-exit)\n* [Logging Levels](#logging-levels)\n  * [Using Logging Levels](#using-logging-levels)\n  * [Using Custom Logging Levels](#using-custom-logging-levels)\n* [Further Reading](#further-reading)\n  * [Events and Callbacks in Winston](#events-and-callbacks-in-winston)\n  * [Working with multiple Loggers in winston](#working-with-multiple-loggers-in-winston)\n  * [Using winston in a CLI tool](#using-winston-in-a-cli-tool)\n  * [Extending another object with Logging](#extending-another-object-with-logging)\n  * [Filters](#filters)\n* [Working with transports](#working-with-transports)\n    * [Adding Custom Transports](#adding-custom-transports)\n* [Installation](#installation)\n* [Run Tests](#run-tests)\n\n\n## Logging\n\n### Using the Default Logger\nThe default logger is accessible through the winston module directly. Any method that you could call on an instance of a logger is available on the default logger:\n\n``` js\n  var winston = require('winston');\n\n  winston.log('info', 'Hello distributed log files!');\n  winston.info('Hello again distributed logs');\n```\n\nBy default, only the Console transport is set on the default logger. You can add or remove transports via the add() and remove() methods:\n\n``` js\n  winston.add(winston.transports.File, { filename: 'somefile.log' });\n  winston.remove(winston.transports.Console);\n```\n\nFor more documentation about working with each individual transport supported by Winston see the [Working with transports](#working-with-transports) section below.\n\n### Instantiating your own Logger\nIf you would prefer to manage the object lifetime of loggers you are free to instantiate them yourself:\n\n``` js\n  var logger = new (winston.Logger)({\n    transports: [\n      new (winston.transports.Console)(),\n      new (winston.transports.File)({ filename: 'somefile.log' })\n    ]\n  });\n```\n\nYou can work with this logger in the same way that you work with the default logger:\n\n``` js\n  //\n  // Logging\n  //\n  logger.log('info', 'Hello distributed log files!');\n  logger.info('Hello again distributed logs');\n\n  //\n  // Adding / Removing Transports\n  //   (Yes It's chainable)\n  //\n  logger.add(winston.transports.File)\n        .remove(winston.transports.Console);\n```\n\n### Logging with Metadata\nIn addition to logging string messages, winston will also optionally log additional JSON metadata objects. Adding metadata is simple:\n\n``` js\n  winston.log('info', 'Test Log Message', { anything: 'This is metadata' });\n```\n\nThe way these objects are stored varies from transport to transport (to best support the storage mechanisms offered). Here's a quick summary of how each transports handles metadata:\n\n1. __Console:__ Logged via util.inspect(meta)\n2. __File:__ Logged via util.inspect(meta)\n\n## Multiple transports of the same type\n\nIt is possible to use multiple transports of the same type e.g. `winston.transports.File` by passing in a custom `name` when you construct the transport.\n\n``` js\nvar logger = new (winston.Logger)({\n  transports: [\n    new (winston.transports.File)({\n      name: 'info-file',\n      filename: 'filelog-info.log',\n      level: 'info'\n    }),\n    new (winston.transports.File)({\n      name: 'error-file',\n      filename: 'filelog-error.log',\n      level: 'error'\n    })\n  ]\n});\n```\n\nIf you later want to remove one of these transports you can do so by using the string name. e.g.:\n\n``` js\nlogger.remove('info-file');\n```\n\nIn this example one could also remove by passing in the instance of the Transport itself. e.g. this is equivalent to the string example above;\n\n```\n// Notice it was first in the Array above\nvar infoFile = logger.transports[0];\nlogger.remove(infoFile);\n```\n\n## Profiling\nIn addition to logging messages and metadata, winston also has a simple profiling mechanism implemented for any logger:\n\n``` js\n  //\n  // Start profile of 'test'\n  // Remark: Consider using Date.now() with async operations\n  //\n  winston.profile('test');\n\n  setTimeout(function () {\n    //\n    // Stop profile of 'test'. Logging will now take place:\n    //   \"17 Jan 21:00:00 - info: test duration=1000ms\"\n    //\n    winston.profile('test');\n  }, 1000);\n```\n\nAll profile messages are set to the 'info' by default and both message and metadata are optional There are no plans in the Roadmap to make this configurable, but I'm open to suggestions / issues.\n\n### String interpolation\nThe `log` method provides the same string interpolation methods like [`util.format`][10].\n\nThis allows for the following log messages.\n``` js\nlogger.log('info', 'test message %s', 'my string');\n// info: test message my string\n\nlogger.log('info', 'test message %d', 123);\n// info: test message 123\n\nlogger.log('info', 'test message %j', {number: 123}, {});\n// info: test message {\"number\":123}\n// meta = {}\n\nlogger.log('info', 'test message %s, %s', 'first', 'second', {number: 123});\n// info: test message first, second\n// meta = {number: 123}\n\nlogger.log('info', 'test message', 'first', 'second', {number: 123});\n// info: test message first second\n// meta = {number: 123}\n\nlogger.log('info', 'test message %s, %s', 'first', 'second', {number: 123}, function(){});\n// info: test message first, second\n// meta = {numer: 123}\n// callback = function(){}\n\nlogger.log('info', 'test message', 'first', 'second', {number: 123}, function(){});\n// info: test message first second\n// meta = {numer: 123}\n// callback = function(){}\n```\n\n\n\n\n\n## Querying Logs\nWinston supports querying of logs with Loggly-like options. [See Loggly Search API](http://wiki.loggly.com/retrieve_events#optional).\nSpecifically: `File`, `Couchdb`, `Redis`, `Loggly`, `Nssocket`, and `Http`.\n\n``` js\n  var options = {\n    from: new Date - 24 * 60 * 60 * 1000,\n    until: new Date,\n    limit: 10,\n    start: 0,\n    order: 'desc',\n    fields: ['message']\n  };\n\n  //\n  // Find items logged between today and yesterday.\n  //\n  winston.query(options, function (err, results) {\n    if (err) {\n      throw err;\n    }\n\n    console.log(results);\n  });\n```\n\n## Streaming Logs\nStreaming allows you to stream your logs back from your chosen transport.\n\n``` js\n  //\n  // Start at the end.\n  //\n  winston.stream({ start: -1 }).on('log', function(log) {\n    console.log(log);\n  });\n```\n\n## Exceptions\n\n### Handling Uncaught Exceptions with winston\n\nWith `winston`, it is possible to catch and log `uncaughtException` events from your process. There are two distinct ways of enabling this functionality either through the default winston logger or your own logger instance.\n\nIf you want to use this feature with the default logger simply call `.handleExceptions()` with a transport instance.\n\n``` js\n  //\n  // You can add a separate exception logger by passing it to `.handleExceptions`\n  //\n  winston.handleExceptions(new winston.transports.File({ filename: 'path/to/exceptions.log' }))\n\n  //\n  // Alternatively you can set `.handleExceptions` to true when adding transports to winston\n  //\n  winston.add(winston.transports.File, {\n    filename: 'path/to/all-logs.log',\n    handleExceptions: true\n  });\n```\n\n### To Exit or Not to Exit\n\nBy default, winston will exit after logging an uncaughtException. if this is not the behavior you want,\nset `exitOnError = false`\n\n``` js\n  var logger = new (winston.Logger)({ exitOnError: false });\n\n  //\n  // or, like this:\n  //\n  logger.exitOnError = false;\n```\n\nWhen working with custom logger instances, you can pass in separate transports to the `exceptionHandlers` property or set `.handleExceptions` on any transport.\n\nExample 1\n\n``` js\n  var logger = new (winston.Logger)({\n    transports: [\n      new winston.transports.File({ filename: 'path/to/all-logs.log' })\n    ],\n    exceptionHandlers: [\n      new winston.transports.File({ filename: 'path/to/exceptions.log' })\n    ]\n  });\n```\n\nExample 2\n\n```\nvar logger = new winston.Logger({\n  transports: [\n    new winston.transports.Console({\n      handleExceptions: true,\n      json: true\n    })\n  ],\n  exitOnError: false\n});\n```\n\nThe `exitOnError` option can also be a function to prevent exit on only certain types of errors:\n\n``` js\n  function ignoreEpipe(err) {\n    return err.code !== 'EPIPE';\n  }\n\n  var logger = new (winston.Logger)({ exitOnError: ignoreEpipe });\n\n  //\n  // or, like this:\n  //\n  logger.exitOnError = ignoreEpipe;\n```\n\n## Logging Levels\n\n### Using Logging Levels\nSetting the level for your logging message can be accomplished in one of two ways. You can pass a string representing the logging level to the log() method or use the level specified methods defined on every winston Logger.\n\n``` js\n  //\n  // Any logger instance\n  //\n  logger.log('silly', \"127.0.0.1 - there's no place like home\");\n  logger.log('debug', \"127.0.0.1 - there's no place like home\");\n  logger.log('verbose', \"127.0.0.1 - there's no place like home\");\n  logger.log('info', \"127.0.0.1 - there's no place like home\");\n  logger.log('warn', \"127.0.0.1 - there's no place like home\");\n  logger.log('error', \"127.0.0.1 - there's no place like home\");\n  logger.info(\"127.0.0.1 - there's no place like home\");\n  logger.warn(\"127.0.0.1 - there's no place like home\");\n  logger.error(\"127.0.0.1 - there's no place like home\");\n\n  //\n  // Default logger\n  //\n  winston.log('info', \"127.0.0.1 - there's no place like home\");\n  winston.info(\"127.0.0.1 - there's no place like home\");\n```\n\nWinston allows you to set a `level` on each transport that specifies the level of messages this transport should log. For example, you could log only errors to the console, with the full logs in a file (note that the default level of a transport is `info`):\n\n``` js\n  var logger = new (winston.Logger)({\n    transports: [\n      new (winston.transports.Console)({ level: 'error' }),\n      new (winston.transports.File)({ filename: 'somefile.log' })\n    ]\n  });\n```\n\nYou may also dynamically change the log level of a transport:\n\n``` js\n  var logger = new (winston.Logger)({\n    transports: [\n      new (winston.transports.Console)({ level: 'warn' }),\n      new (winston.transports.File)({ filename: 'somefile.log', level: 'error' })\n    ]\n  });\n  logger.debug(\"Will not be logged in either transport!\");\n  logger.transports.console.level = 'debug';\n  logger.transports.file.level = 'verbose';\n  logger.verbose(\"Will be logged in both transports!\");\n```\n\nAs of 0.2.0, winston supports customizable logging levels, defaulting to [npm][0] style logging levels. Changing logging levels is easy:\n\n``` js\n  //\n  // Change levels on the default winston logger\n  //\n  winston.setLevels(winston.config.syslog.levels);\n\n  //\n  // Change levels on an instance of a logger\n  //\n  logger.setLevels(winston.config.syslog.levels);\n```\n\nCalling `.setLevels` on a logger will remove all of the previous helper methods for the old levels and define helper methods for the new levels. Thus, you should be careful about the logging statements you use when changing levels. For example, if you ran this code after changing to the syslog levels:\n\n``` js\n  //\n  // Logger does not have 'silly' defined since that level is not in the syslog levels\n  //\n  logger.silly('some silly message');\n```\n\n### Using Custom Logging Levels\nIn addition to the predefined `npm` and `syslog` levels available in Winston, you can also choose to define your own:\n\n``` js\n  var myCustomLevels = {\n    levels: {\n      foo: 0,\n      bar: 1,\n      baz: 2,\n      foobar: 3\n    },\n    colors: {\n      foo: 'blue',\n      bar: 'green',\n      baz: 'yellow',\n      foobar: 'red'\n    }\n  };\n\n  var customLevelLogger = new (winston.Logger)({ levels: myCustomLevels.levels });\n  customLevelLogger.foobar('some foobar level-ed message');\n```\n\nAlthough there is slight repetition in this data structure, it enables simple encapsulation if you not to have colors. If you do wish to have colors, in addition to passing the levels to the Logger itself, you must make winston aware of them:\n\n``` js\n  //\n  // Make winston aware of these colors\n  //\n  winston.addColors(myCustomLevels.colors);\n```\n\nThis enables transports with the 'colorize' option set to appropriately color the output of custom levels.\n\n## Further Reading\n\n### Events and Callbacks in Winston\nEach instance of winston.Logger is also an instance of an [EventEmitter][1]. A log event will be raised each time a transport successfully logs a message:\n\n``` js\n  logger.on('logging', function (transport, level, msg, meta) {\n    // [msg] and [meta] have now been logged at [level] to [transport]\n  });\n\n  logger.info('CHILL WINSTON!', { seriously: true });\n```\n\nIt is also worth mentioning that the logger also emits an 'error' event which you should handle or suppress if you don't want unhandled exceptions:\n\n``` js\n  //\n  // Handle errors\n  //\n  logger.on('error', function (err) { /* Do Something */ });\n\n  //\n  // Or just suppress them.\n  //\n  logger.emitErrs = false;\n```\n\nEvery logging method described in the previous section also takes an optional callback which will be called only when all of the transports have logged the specified message.\n\n``` js\n  logger.info('CHILL WINSTON!', { seriously: true }, function (err, level, msg, meta) {\n    // [msg] and [meta] have now been logged at [level] to **every** transport.\n  });\n```\n\n### Working with multiple Loggers in winston\n\nOften in larger, more complex applications it is necessary to have multiple logger instances with different settings. Each logger is responsible for a different feature area (or category). This is exposed in `winston` in two ways: through `winston.loggers` and instances of `winston.Container`. In fact, `winston.loggers` is just a predefined instance of `winston.Container`:\n\n``` js\n  var winston = require('winston');\n\n  //\n  // Configure the logger for `category1`\n  //\n  winston.loggers.add('category1', {\n    console: {\n      level: 'silly',\n      colorize: 'true',\n      label: 'category one'\n    },\n    file: {\n      filename: '/path/to/some/file'\n    }\n  });\n\n  //\n  // Configure the logger for `category2`\n  //\n  winston.loggers.add('category2', {\n    couchdb: {\n      host: '127.0.0.1',\n      port: 5984\n    }\n  });\n```\n\nNow that your loggers are setup you can require winston _in any file in your application_ and access these pre-configured loggers:\n\n``` js\n  var winston = require('winston');\n\n  //\n  // Grab your preconfigured logger\n  //\n  var category1 = winston.loggers.get('category1');\n\n  category1.info('logging from your IoC container-based logger');\n```\n\nIf you prefer to manage the `Container` yourself you can simply instantiate one:\n\n``` js\n  var winston = require('winston'),\n      container = new winston.Container();\n\n  container.add('category1', {\n    console: {\n      level: 'silly',\n      colorize: 'true'\n    },\n    file: {\n      filename: '/path/to/some/file'\n    }\n  });\n```\n\n### Sharing transports between Loggers in winston\n\n``` js\n  var winston = require('winston');\n\n  //\n  // Setup transports to be shared across all loggers\n  // in three ways:\n  //\n  // 1. By setting it on the default Container\n  // 2. By passing `transports` into the constructor function of winston.Container\n  // 3. By passing `transports` into the `.get()` or `.add()` methods\n  //\n\n  //\n  // 1. By setting it on the default Container\n  //\n  winston.loggers.options.transports = [\n    // Setup your shared transports here\n  ];\n\n  //\n  // 2. By passing `transports` into the constructor function of winston.Container\n  //\n  var container = new winston.Container({\n    transports: [\n      // Setup your shared transports here\n    ]\n  });\n\n  //\n  // 3. By passing `transports` into the `.get()` or `.add()` methods\n  //\n  winston.loggers.add('some-category', {\n    transports: [\n      // Setup your shared transports here\n    ]\n  });\n\n  container.add('some-category', {\n    transports: [\n      // Setup your shared transports here\n    ]\n  });\n```\n\n### Using winston in a CLI tool\nA common use-case for logging is output to a CLI tool. Winston has a special helper method which will pretty print output from your CLI tool. Here's an example from the [require-analyzer][2] written by [Nodejitsu][3]:\n\n```\n  info:   require-analyzer starting in /Users/Charlie/Nodejitsu/require-analyzer\n  info:   Found existing dependencies\n  data:   {\n  data:     colors: '0.x.x',\n  data:     eyes: '0.1.x',\n  data:     findit: '0.0.x',\n  data:     npm: '1.0.x',\n  data:     optimist: '0.2.x',\n  data:     semver: '1.0.x',\n  data:     winston: '0.2.x'\n  data:   }\n  info:   Analyzing dependencies...\n  info:   Done analyzing raw dependencies\n  info:   Retrieved packages from npm\n  warn:   No additional dependencies found\n```\n\nConfiguring output for this style is easy, just use the `.cli()` method on `winston` or an instance of `winston.Logger`:\n\n``` js\n  var winston = require('winston');\n\n  //\n  // Configure CLI output on the default logger\n  //\n  winston.cli();\n\n  //\n  // Configure CLI on an instance of winston.Logger\n  //\n  var logger = new winston.Logger({\n    transports: [\n      new (winston.transports.Console)()\n    ]\n  });\n\n  logger.cli();\n```\n\n### Extending another object with Logging\nOften in a given code base with lots of Loggers it is useful to add logging methods to a different object so that these methods can be called with less syntax. Winston exposes this functionality via the 'extend' method:\n\n``` js\n  var myObject = {};\n\n  logger.extend(myObject);\n\n  //\n  // You can now call logger methods on 'myObject'\n  //\n  myObject.info(\"127.0.0.1 - there's no place like home\");\n```\n\n### Filters\nFilters allow modifying the contents of log messages, e.g. to mask data that\nshould not appear in logs.\n\n``` js\nlogger.addFilter(function(msg) {\n  return maskCardNumbers(msg);\n});\nlogger.info('transaction with card number 123456789012345 successful.');\n```\n\nThis may result in this output:\n\n```\ninfo: transaction with card number 123456****2345 successful.\n```\n\nSee [log-filter-test.js](./test/log-filter-test.js), where card number masking\nis implemented as an example.\n\n## Working with Transports\nThere are many transports supported by winston core. If you have a transport you would like to add either open an issue or fork and submit a pull request. Commits are welcome, but I'll give you extra street cred if you __add tests too :D__\n\n\n### Console Transport\n``` js\n  winston.add(winston.transports.Console, options)\n```\n\nThe Console transport takes a few simple options:\n\n* __level:__ Level of messages that this transport should log (default 'info').\n* __silent:__ Boolean flag indicating whether to suppress output (default false).\n* __colorize:__ Boolean flag indicating if we should colorize output (default false).\n* __timestamp:__ Boolean flag indicating if we should prepend output with timestamps (default false). If function is specified, its return value will be used instead of timestamps.\n* __prettyPrint:__ Boolean flag indicating if we should `util.inspect` the meta (default false). If function is specified, its return value will be the string representing the meta.\n* __depth__ Numeric indicating how many times to recurse while formatting the object with `util.inspect` (only used with `prettyPrint: true`) (default null, unlimited)\n* __showLevel:__ Boolean flag indicating if we should prepend output with level (default true).\n* __formatter:__ If function is specified, its return value will be used instead of default output. (default undefined)\n\n*Metadata:* Logged via util.inspect(meta);\n\n### File Transport\n``` js\n  winston.add(winston.transports.File, options)\n```\n\nThe File transport should really be the 'Stream' transport since it will accept any [WritableStream][14]. It is named such because it will also accept filenames via the 'filename' option:\n\n* __level:__ Level of messages that this transport should log.\n* __silent:__ Boolean flag indicating whether to suppress output.\n* __colorize:__ Boolean flag indicating if we should colorize output.\n* __timestamp:__ Boolean flag indicating if we should prepend output with timestamps (default true). If function is specified, its return value will be used instead of timestamps.\n* __filename:__ The filename of the logfile to write output to.\n* __maxsize:__ Max size in bytes of the logfile, if the size is exceeded then a new file is created, a counter will become a suffix of the log file.\n* __maxFiles:__ Limit the number of files created when the size of the logfile is exceeded.\n* __stream:__ The WriteableStream to write output to.\n* __json:__ If true, messages will be logged as JSON (default true).\n* __prettyPrint:__ If true, additional JSON metadata objects that are added to logging string messages will be displayed as a JSON string representation. If function is specified, its return value will be the string representing the meta.\n* __depth__ Numeric indicating how many times to recurse while formatting the object with `util.inspect` (only used with `prettyPrint: true`) (default null, unlimited)\n* __logstash:__ If true, messages will be logged as JSON and formatted for logstash (default false).\n* __showLevel:__ Boolean flag indicating if we should prepend output with level (default true).\n* __formatter:__ If function is specified, its return value will be used instead of default output. (default undefined)\n* __tailable:__ If true, log files will be rolled based on maxsize and maxfiles, but in ascending order. The __filename__ will always have the most recent log lines. The larger the appended number, the older the log file.\n\n*Metadata:* Logged via util.inspect(meta);\n\n### Daily Rotate File Transport\n``` js\n  winston.add(winston.transports.DailyRotateFile, options)\n```\n\nThe Daily Rotate File transport lets you rotate log files based on time.\n\nIn addition to the options accepted by the File transport, the Daily Rotate File Transport also accepts the following option.\n\n* __datePattern:__ Defines rolling time of a log file and suffix appended to the file. Following meta characters can be used: `yy`, `yyyy`, `M`, `MM`, `d`, `dd`, `H`, `HH`, `m`, `mm`. The default pattern is `'.yyyy-MM-dd'`. Rotation time of the log file will be equal to the smallest given time token timespan, so `'.yyyy-MM-ddTHH'` will rotate logfile every hour. You can not rotate files more frequent then every minute.\n\n### Loggly Transport\n``` js\n  var Loggly = require('winston-loggly').Loggly\n  winston.add(Loggly, options);\n```\n\nThe Loggly transport is based on [Nodejitsu's][3] [node-loggly][6] implementation of the [Loggly][7] API. If you haven't heard of Loggly before, you should probably read their [value proposition][8]. The Loggly transport takes the following options. Either 'inputToken' or 'inputName' is required:\n\n* __level:__ Level of messages that this transport should log.\n* __subdomain:__ The subdomain of your Loggly account. *[required]*\n* __auth__: The authentication information for your Loggly account. *[required with inputName]*\n* __inputName:__ The name of the input this instance should log to.\n* __inputToken:__ The input token of the input this instance should log to.\n* __json:__ If true, messages will be sent to Loggly as JSON.\n\n*Metadata:* Logged in suggested [Loggly format][2]\n\n### Riak Transport\nAs of `0.3.0` the Riak transport has been broken out into a new module: [winston-riak][17]. Using it is just as easy:\n\n``` js\n  var Riak = require('winston-riak').Riak;\n  winston.add(Riak, options);\n```\n\nIn addition to the options accepted by the [riak-js][3] [client][4], the Riak transport also accepts the following options. It is worth noting that the riak-js debug option is set to *false* by default:\n\n* __level:__ Level of messages that this transport should log.\n* __bucket:__ The name of the Riak bucket you wish your logs to be in or a function to generate bucket names dynamically.\n\n``` js\n  // Use a single bucket for all your logs\n  var singleBucketTransport = new (Riak)({ bucket: 'some-logs-go-here' });\n\n  // Generate a dynamic bucket based on the date and level\n  var dynamicBucketTransport = new (Riak)({\n    bucket: function (level, msg, meta, now) {\n      var d = new Date(now);\n      return level + [d.getDate(), d.getMonth(), d.getFullYear()].join('-');\n    }\n  });\n```\n\n*Metadata:* Logged as JSON literal in Riak\n\n### MongoDB Transport\nAs of `0.3.0` the MongoDB transport has been broken out into a new module: [winston-mongodb][16]. Using it is just as easy:\n\n``` js\n  var MongoDB = require('winston-mongodb').MongoDB;\n  winston.add(MongoDB, options);\n```\n\nFor more information about its arguments, check [winston-mongodb's README][16].\n\n* __level:__ Level of messages that this transport should log.\n* __silent:__ Boolean flag indicating whether to suppress output.\n* __db:__ The name of the database you want to log to. *[required]*\n* __collection__: The name of the collection you want to store log messages in, defaults to 'log'.\n* __safe:__ Boolean indicating if you want eventual consistency on your log messages, if set to true it requires an extra round trip to the server to ensure the write was committed, defaults to true.\n* __host:__ The host running MongoDB, defaults to localhost.\n* __port:__ The port on the host that MongoDB is running on, defaults to MongoDB's default port.\n\n*Metadata:* Logged as a native JSON object.\n>>>>>>> 3b57730... Custom log formatter functionality were added.\n\n### SimpleDB Transport\n\nThe [winston-simpledb][18] transport is just as easy:\n\n``` js\n  var SimpleDB = require('winston-simpledb').SimpleDB;\n  winston.add(SimpleDB, options);\n```\n\nThe SimpleDB transport takes the following options. All items marked with an asterisk are required:\n\n* __awsAccessKey__:* your AWS Access Key\n* __secretAccessKey__:* your AWS Secret Access Key\n* __awsAccountId__:* your AWS Account Id\n* __domainName__:* a string or function that returns the domain name to log to\n* __region__:* the region your domain resides in\n* __itemName__: a string ('uuid', 'epoch', 'timestamp') or function that returns the item name to log\n\n*Metadata:* Logged as a native JSON object to the 'meta' attribute of the item.\n\n### Mail Transport\n\nThe [winston-mail][19] is an email transport:\n\n``` js\n  var Mail = require('winston-mail').Mail;\n  winston.add(Mail, options);\n```\n\nThe Mail transport uses [emailjs](https://github.com/eleith/emailjs) behind the scenes.  Options are the following:\n\n* __to:__ The address(es) you want to send to. *[required]*\n* __from:__ The address you want to send from. (default: `winston@[server-host-name]`)\n* __host:__ SMTP server hostname (default: localhost)\n* __port:__ SMTP port (default: 587 or 25)\n* __username__ User for server auth\n* __password__ Password for server auth\n* __ssl:__ Use SSL (boolean or object { key, ca, cert })\n* __tls:__ Boolean (if true, use starttls)\n* __level:__ Level of messages that this transport should log.\n* __silent:__ Boolean flag indicating whether to suppress output.\n\n*Metadata:* Stringified as JSON in email.\n\n### Amazon SNS (Simple Notification System) Transport\n\nThe [winston-sns][21] transport uses amazon SNS to send emails, texts, or a bunch of other notifications.\n\n``` js\n  require('winston-sns').SNS;\n  winston.add(winston.transports.SNS, options);\n```\n\nOptions:\n\n* __aws_key:__ Your Amazon Web Services Key. *[required]*\n* __aws_secret:__ Your Amazon Web Services Secret. *[required]*\n* __subscriber:__ Subscriber number - found in your SNS AWS Console, after clicking on a topic. Same as AWS Account ID. *[required]*\n* __topic_arn:__ Also found in SNS AWS Console - listed under a topic as Topic ARN. *[required]*\n* __region:__ AWS Region to use. Can be one of: `us-east-1`,`us-west-1`,`eu-west-1`,`ap-southeast-1`,`ap-northeast-1`,`us-gov-west-1`,`sa-east-1`. (default: `us-east-1`)\n* __subject:__ Subject for notifications. (default: \"Winston Error Report\")\n* __message:__ Message of notifications. Uses placeholders for level (%l), error message (%e), and metadata (%m). (default: \"Level '%l' Error:\\n%e\\n\\nMetadata:\\n%m\")\n* __level:__ lowest level this transport will log. (default: `info`)\n\n### Graylog2 Transport\n\n[winston-graylog2][22] is a Graylog2 transport:\n\n``` js\n  var Graylog2 = require('winston-graylog2').Graylog2;\n  winston.add(Graylog2, options);\n```\n\nThe Graylog2 transport connects to a Graylog2 server over UDP using the following options:\n\n* __level:__ Level of messages this transport should log. (default: info)\n* __silent:__ Boolean flag indicating whether to suppress output. (default: false)\n\n* __graylogHost:__ IP address or hostname of the graylog2 server. (default: localhost)\n* __graylogPort:__ Port to send messages to on the graylog2 server. (default: 12201)\n* __graylogHostname:__ The hostname associated with graylog2 messages. (default: require('os').hostname())\n* __graylogFacility:__ The graylog2 facility to send log messages.. (default: nodejs)\n\n*Metadata:* Stringified as JSON in the full message GELF field.\n\n### Papertrail Transport\n\n[winston-papertrail][23] is a Papertrail transport:\n\n``` js\n  var Papertrail = require('winston-papertrail').Papertrail;\n  winston.add(Papertrail, options);\n```\n\nThe Papertrail transport connects to a [PapertrailApp log destination](https://papertrailapp.com) over TCP (TLS) using the following options:\n\n* __level:__ Level of messages this transport should log. (default: info)\n* __host:__ FQDN or IP address of the Papertrail endpoint.\n* __port:__ Port for the Papertrail log destination.\n* __hostname:__ The hostname associated with messages. (default: require('os').hostname())\n* __program:__ The facility to send log messages.. (default: default)\n* __logFormat:__ a log formatting function with the signature `function(level, message)`, which allows custom formatting of the level or message prior to delivery\n\n*Metadata:* Logged as a native JSON object to the 'meta' attribute of the item.\n\n### Cassandra Transport\n\n[winston-cassandra][24] is a Cassandra transport:\n\n``` js\n  var Cassandra = require('winston-cassandra').Cassandra;\n  winston.add(Cassandra, options);\n```\n\nThe Cassandra transport connects to a cluster using the native protocol with the following options:\n\n* __level:__ Level of messages that this transport should log (default: `'info'`).\n* __table:__ The name of the Cassandra column family you want to store log messages in (default: `'logs'`).\n* __partitionBy:__ How you want the logs to be partitioned. Possible values `'hour'` and `'day'`(Default).\n* __consistency:__ The consistency of the insert query (default: `quorum`).\n\nIn addition to the options accepted by the [Node.js Cassandra driver](https://github.com/jorgebay/node-cassandra-cql) Client.\n\n* __hosts:__ Cluster nodes that will handle the write requests:\nArray of strings containing the hosts, for example `['host1', 'host2']` (required).\n* __keyspace:__ The name of the keyspace that will contain the logs table (required). The keyspace should be already created in the cluster.\n\n### Adding Custom Transports\nAdding a custom transport (say for one of the datastore on the Roadmap) is actually pretty easy. All you need to do is accept a couple of options, set a name, implement a log() method, and add it to the set of transports exposed by winston.\n\n``` js\n  var util = require('util'),\n      winston = require('winston');\n\n  var CustomLogger = winston.transports.CustomerLogger = function (options) {\n    //\n    // Name this logger\n    //\n    this.name = 'customLogger';\n\n    //\n    // Set the level from your options\n    //\n    this.level = options.level || 'info';\n\n    //\n    // Configure your storage backing as you see fit\n    //\n  };\n\n  //\n  // Inherit from `winston.Transport` so you can take advantage\n  // of the base functionality and `.handleExceptions()`.\n  //\n  util.inherits(CustomLogger, winston.Transport);\n\n  CustomLogger.prototype.log = function (level, msg, meta, callback) {\n    //\n    // Store this message and metadata, maybe use some custom logic\n    // then callback indicating success.\n    //\n    callback(null, true);\n  };\n```\n\n### Custom Log Format\nTo specify custom log format you should set formatter function for transport. Currently supported transports are: Console, File, Memory.\nOptions object will be passed to the format function. It's general properties are: timestamp, level, message, meta. Depending on the transport type may be additional properties.\n\n``` js\nvar logger = new (winston.Logger)({\n  transports: [\n    new (winston.transports.Console)({\n      timestamp: function() {\n        return Date.now();\n      },\n      formatter: function(options) {\n        // Return string will be passed to logger.\n        return options.timestamp() +' '+ options.level.toUpperCase() +' '+ (undefined !== options.message ? options.message : '') +\n          (options.meta && Object.keys(options.meta).length ? '\\n\\t'+ JSON.stringify(options.meta) : '' );\n      }\n    })\n  ]\n});\nlogger.info('Data to log.');\n```\n\n### Inspirations\n1. [npm][0]\n2. [log.js][4]\n3. [socket.io][5]\n4. [node-rlog][6]\n5. [BigBrother][7]\n6. [Loggly][8]\n\n## Installation\n\n### Installing npm (node package manager)\n```\n  curl http://npmjs.org/install.sh | sh\n```\n\n### Installing winston\n```\n  [sudo] npm install winston\n```\n\n## Run Tests\nAll of the winston tests are written in [vows][9], and designed to be run with npm.\n\n``` bash\n  $ npm test\n```\n\n#### Author: [Charlie Robbins](http://twitter.com/indexzero)\n#### Contributors: [Matthew Bergman](http://github.com/fotoverite), [Marak Squires](http://github.com/marak)\n\n[0]: https://github.com/npm/npmlog/blob/master/log.js\n[1]: http://nodejs.org/docs/v0.3.5/api/events.html#events.EventEmitter\n[2]: http://github.com/nodejitsu/require-analyzer\n[3]: http://nodejitsu.com\n[4]: https://github.com/visionmedia/log.js\n[5]: http://socket.io\n[6]: https://github.com/jbrisbin/node-rlog\n[7]: https://github.com/feisty/BigBrother\n[8]: http://loggly.com\n[9]: http://vowsjs.org\n[10]: http://nodejs.org/api/util.html#util_util_format_format\n[14]: http://nodejs.org/api/stream.html#stream_class_stream_writable\n[16]: https://github.com/indexzero/winston-mongodb\n[17]: https://github.com/indexzero/winston-riak\n[18]: https://github.com/appsattic/winston-simpledb\n[19]: https://github.com/wavded/winston-mail\n[21]: https://github.com/jesseditson/winston-sns\n[22]: https://github.com/flite/winston-graylog2\n[23]: https://github.com/kenperkins/winston-papertrail\n[24]: https://github.com/jorgebay/winston-cassandra\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/flatiron/winston/issues"
  },
  "_id": "winston@0.9.0",
  "_from": "winston@^0.9.0"
}
