Permalink
Browse files

Add logger

* Log output is /var/log/beaglestache.log
  • Loading branch information...
1 parent f877aac commit d3b761c080e40120bdfe0b2f3c6d65209f055f67 @jadonk committed Jan 7, 2013
Showing with 13,851 additions and 21 deletions.
  1. +6 −0 node_modules/winston/.npmignore
  2. +12 −0 node_modules/winston/.travis.yml
  3. +19 −0 node_modules/winston/LICENSE
  4. +790 −0 node_modules/winston/README.md
  5. +342 −0 node_modules/winston/docs/transports.md
  6. +18 −0 node_modules/winston/examples/couchdb.js
  7. +4 −0 node_modules/winston/examples/exception.js
  8. +10 −0 node_modules/winston/examples/raw-mode.js
  9. +17 −0 node_modules/winston/examples/webhook-post.js
  10. +145 −0 node_modules/winston/lib/winston.js
  11. +259 −0 node_modules/winston/lib/winston/common.js
  12. +45 −0 node_modules/winston/lib/winston/config.js
  13. +35 −0 node_modules/winston/lib/winston/config/cli-config.js
  14. +27 −0 node_modules/winston/lib/winston/config/npm-config.js
  15. +31 −0 node_modules/winston/lib/winston/config/syslog-config.js
  16. +101 −0 node_modules/winston/lib/winston/container.js
  17. +56 −0 node_modules/winston/lib/winston/exception.js
  18. +668 −0 node_modules/winston/lib/winston/logger.js
  19. +29 −0 node_modules/winston/lib/winston/transports.js
  20. +88 −0 node_modules/winston/lib/winston/transports/console.js
  21. +575 −0 node_modules/winston/lib/winston/transports/file.js
  22. +200 −0 node_modules/winston/lib/winston/transports/http.js
  23. +120 −0 node_modules/winston/lib/winston/transports/transport.js
  24. +136 −0 node_modules/winston/lib/winston/transports/webhook.js
  25. +9 −0 node_modules/winston/node_modules/async/.gitmodules
  26. +4 −0 node_modules/winston/node_modules/async/.npmignore
  27. +19 −0 node_modules/winston/node_modules/async/LICENSE
  28. +25 −0 node_modules/winston/node_modules/async/Makefile
  29. +1,021 −0 node_modules/winston/node_modules/async/README.md
  30. +3 −0 node_modules/winston/node_modules/async/index.js
  31. +692 −0 node_modules/winston/node_modules/async/lib/async.js
  32. +33 −0 node_modules/winston/node_modules/async/package.json
  33. +22 −0 node_modules/winston/node_modules/colors/MIT-LICENSE.txt
  34. +77 −0 node_modules/winston/node_modules/colors/ReadMe.md
  35. +269 −0 node_modules/winston/node_modules/colors/colors.js
  36. +74 −0 node_modules/winston/node_modules/colors/example.html
  37. +65 −0 node_modules/winston/node_modules/colors/example.js
  38. +22 −0 node_modules/winston/node_modules/colors/package.json
  39. +65 −0 node_modules/winston/node_modules/colors/test.js
  40. +158 −0 node_modules/winston/node_modules/cycle/cycle.js
  41. +1 −0 node_modules/winston/node_modules/cycle/license.md
  42. +32 −0 node_modules/winston/node_modules/cycle/package.json
  43. +20 −0 node_modules/winston/node_modules/eyes/LICENSE
  44. +4 −0 node_modules/winston/node_modules/eyes/Makefile
  45. +73 −0 node_modules/winston/node_modules/eyes/README.md
  46. +236 −0 node_modules/winston/node_modules/eyes/lib/eyes.js
  47. +42 −0 node_modules/winston/node_modules/eyes/package.json
  48. +56 −0 node_modules/winston/node_modules/eyes/test/eyes-test.js
  49. +2 −0 node_modules/winston/node_modules/pkginfo/.npmignore
  50. +85 −0 node_modules/winston/node_modules/pkginfo/README.md
  51. +194 −0 node_modules/winston/node_modules/pkginfo/docs/docco.css
  52. +101 −0 node_modules/winston/node_modules/pkginfo/docs/pkginfo.html
  53. +19 −0 node_modules/winston/node_modules/pkginfo/examples/all-properties.js
  54. +20 −0 node_modules/winston/node_modules/pkginfo/examples/array-argument.js
  55. +19 −0 node_modules/winston/node_modules/pkginfo/examples/multiple-properties.js
  56. +22 −0 node_modules/winston/node_modules/pkginfo/examples/object-argument.js
  57. +10 −0 node_modules/winston/node_modules/pkginfo/examples/package.json
  58. +19 −0 node_modules/winston/node_modules/pkginfo/examples/single-property.js
  59. +132 −0 node_modules/winston/node_modules/pkginfo/lib/pkginfo.js
  60. +34 −0 node_modules/winston/node_modules/pkginfo/package.json
  61. +69 −0 node_modules/winston/node_modules/pkginfo/test/pkginfo-test.js
  62. +55 −0 node_modules/winston/node_modules/request/LICENSE
  63. +287 −0 node_modules/winston/node_modules/request/README.md
  64. +190 −0 node_modules/winston/node_modules/request/aws.js
  65. +128 −0 node_modules/winston/node_modules/request/aws2.js
  66. +103 −0 node_modules/winston/node_modules/request/forever.js
  67. +974 −0 node_modules/winston/node_modules/request/main.js
  68. +152 −0 node_modules/winston/node_modules/request/mimetypes.js
  69. +34 −0 node_modules/winston/node_modules/request/oauth.js
  70. +35 −0 node_modules/winston/node_modules/request/package.json
  71. BIN node_modules/winston/node_modules/request/tests/googledoodle.png
  72. +39 −0 node_modules/winston/node_modules/request/tests/run.js
  73. +82 −0 node_modules/winston/node_modules/request/tests/server.js
  74. +77 −0 node_modules/winston/node_modules/request/tests/squid.conf
  75. +20 −0 node_modules/winston/node_modules/request/tests/ssl/ca/ca.cnf
  76. 0 node_modules/winston/node_modules/request/tests/ssl/ca/ca.crl
  77. +17 −0 node_modules/winston/node_modules/request/tests/ssl/ca/ca.crt
  78. +13 −0 node_modules/winston/node_modules/request/tests/ssl/ca/ca.csr
  79. +18 −0 node_modules/winston/node_modules/request/tests/ssl/ca/ca.key
  80. +1 −0 node_modules/winston/node_modules/request/tests/ssl/ca/ca.srl
  81. +19 −0 node_modules/winston/node_modules/request/tests/ssl/ca/server.cnf
  82. +16 −0 node_modules/winston/node_modules/request/tests/ssl/ca/server.crt
  83. +11 −0 node_modules/winston/node_modules/request/tests/ssl/ca/server.csr
  84. +28 −0 node_modules/winston/node_modules/request/tests/ssl/ca/server.js
  85. +9 −0 node_modules/winston/node_modules/request/tests/ssl/ca/server.key
  86. +16 −0 node_modules/winston/node_modules/request/tests/ssl/npm-ca.crt
  87. +15 −0 node_modules/winston/node_modules/request/tests/ssl/test.crt
  88. +15 −0 node_modules/winston/node_modules/request/tests/ssl/test.key
  89. +80 −0 node_modules/winston/node_modules/request/tests/test-body.js
  90. +29 −0 node_modules/winston/node_modules/request/tests/test-cookie.js
  91. +90 −0 node_modules/winston/node_modules/request/tests/test-cookiejar.js
  92. +68 −0 node_modules/winston/node_modules/request/tests/test-defaults.js
  93. +37 −0 node_modules/winston/node_modules/request/tests/test-errors.js
  94. +52 −0 node_modules/winston/node_modules/request/tests/test-headers.js
  95. +94 −0 node_modules/winston/node_modules/request/tests/test-httpModule.js
  96. +97 −0 node_modules/winston/node_modules/request/tests/test-https-strict.js
  97. +86 −0 node_modules/winston/node_modules/request/tests/test-https.js
  98. +117 −0 node_modules/winston/node_modules/request/tests/test-oauth.js
  99. +92 −0 node_modules/winston/node_modules/request/tests/test-params.js
  100. +202 −0 node_modules/winston/node_modules/request/tests/test-pipes.js
  101. +16 −0 node_modules/winston/node_modules/request/tests/test-pool.js
  102. +39 −0 node_modules/winston/node_modules/request/tests/test-proxy.js
  103. +28 −0 node_modules/winston/node_modules/request/tests/test-qs.js
  104. +154 −0 node_modules/winston/node_modules/request/tests/test-redirect.js
  105. +13 −0 node_modules/winston/node_modules/request/tests/test-s3.js
  106. +87 −0 node_modules/winston/node_modules/request/tests/test-timeout.js
  107. +14 −0 node_modules/winston/node_modules/request/tests/test-toJSON.js
  108. +61 −0 node_modules/winston/node_modules/request/tests/test-tunnel.js
  109. +229 −0 node_modules/winston/node_modules/request/tunnel.js
  110. +19 −0 node_modules/winston/node_modules/request/uuid.js
  111. +65 −0 node_modules/winston/node_modules/request/vendor/cookie/index.js
  112. +72 −0 node_modules/winston/node_modules/request/vendor/cookie/jar.js
  113. +2 −0 node_modules/winston/node_modules/stack-trace/.npmignore
  114. +19 −0 node_modules/winston/node_modules/stack-trace/License
  115. +11 −0 node_modules/winston/node_modules/stack-trace/Makefile
  116. +98 −0 node_modules/winston/node_modules/stack-trace/Readme.md
  117. +111 −0 node_modules/winston/node_modules/stack-trace/lib/stack-trace.js
  118. +30 −0 node_modules/winston/node_modules/stack-trace/package.json
  119. +10 −0 node_modules/winston/node_modules/stack-trace/test/common.js
  120. +49 −0 node_modules/winston/node_modules/stack-trace/test/integration/test-get.js
  121. +14 −0 node_modules/winston/node_modules/stack-trace/test/integration/test-long-stack-trace.js
  122. +135 −0 node_modules/winston/node_modules/stack-trace/test/integration/test-parse.js
  123. +7 −0 node_modules/winston/node_modules/stack-trace/test/run.js
  124. +49 −0 node_modules/winston/package.json
  125. +40 −0 node_modules/winston/test/cli-test.js
  126. +99 −0 node_modules/winston/test/container-test.js
  127. +62 −0 node_modules/winston/test/custom-timestamp-test.js
  128. +47 −0 node_modules/winston/test/exception-test.js
  129. 0 node_modules/winston/test/fixtures/.gitkeep
  130. +13 −0 node_modules/winston/test/fixtures/keys/agent2-cert.pem
  131. +9 −0 node_modules/winston/test/fixtures/keys/agent2-key.pem
  132. 0 node_modules/winston/test/fixtures/logs/.gitkeep
  133. +21 −0 node_modules/winston/test/fixtures/scripts/default-exceptions.js
  134. +25 −0 node_modules/winston/test/fixtures/scripts/exit-on-error.js
  135. +25 −0 node_modules/winston/test/fixtures/scripts/log-exceptions.js
  136. +26 −0 node_modules/winston/test/fixtures/scripts/unhandle-exceptions.js
  137. +173 −0 node_modules/winston/test/helpers.js
  138. +60 −0 node_modules/winston/test/log-exception-test.js
  139. +98 −0 node_modules/winston/test/log-rewriter-test.js
  140. +200 −0 node_modules/winston/test/logger-test.js
  141. +39 −0 node_modules/winston/test/transports/console-test.js
  142. +102 −0 node_modules/winston/test/transports/file-maxfiles-test.js
  143. +82 −0 node_modules/winston/test/transports/file-maxsize-test.js
  144. +60 −0 node_modules/winston/test/transports/file-test.js
  145. +212 −0 node_modules/winston/test/transports/transport.js
  146. +125 −0 node_modules/winston/test/transports/webhook-test.js
  147. +98 −0 node_modules/winston/test/winston-test.js
  148. +24 −21 tweetstache.js
View
6 node_modules/winston/.npmignore
@@ -0,0 +1,6 @@
+test/*.log
+test/fixtures/*.json
+test/fixtures/logs/*.log
+node_modules/
+node_modules/*
+npm-debug.log
View
12 node_modules/winston/.travis.yml
@@ -0,0 +1,12 @@
+language: node_js
+node_js:
+ - 0.4
+ - 0.6
+branches:
+ only:
+ - master
+notifications:
+ email:
+ - travis@nodejitsu.com
+ irc: "irc.freenode.org#nodejitsu"
+
View
19 node_modules/winston/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010 Charlie Robbins
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
790 node_modules/winston/README.md
@@ -0,0 +1,790 @@
+# winston [![Build Status](https://secure.travis-ci.org/flatiron/winston.png)](http://travis-ci.org/flatiron/winston)
+
+A 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>
+
+## Motivation
+Winston 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.
+
+There 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.
+
+## Usage
+There 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.
+
+* [Logging](#logging)
+ * [Using the Default Logger](#using-the-default-logger)
+ * [Instantiating your own Logger](#instantiating-your-own-logger)
+ * [Logging with Metadata](#logging-with-metadata)
+* [Transports](https://github.com/flatiron/winston/blob/master/docs/transports.md)
+* [Profiling](#profiling)
+* [Streaming Logs](#streaming-logs)
+* [Querying Logs](#querying-logs)
+* [Exceptions](#exceptions)
+ * [Handling Uncaught Exceptions with winston](#handling-uncaught-exceptions-with-winston)
+ * [To Exit or Not to Exit](#to-exit-or-not-to-exit)
+* [Logging Levels](#logging-levels)
+ * [Using Logging Levels](#using-logging-levels)
+ * [Using Custom Logging Levels](#using-custom-logging-levels)
+* [Further Reading](#further-reading)
+ * [Events and Callbacks in Winston](#events-and-callbacks-in-winston)
+ * [Working with multiple Loggers in winston](#working-with-multiple-loggers-in-winston)
+ * [Using winston in a CLI tool](#using-winston-in-a-cli-tool)
+ * [Extending another object with Logging](#extending-another-object-with-logging)
+ * [Adding Custom Transports](#adding-custom-transports)
+
+## Logging
+
+### Using the Default Logger
+The 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:
+
+``` js
+ var winston = require('winston');
+
+ winston.log('info', 'Hello distributed log files!');
+ winston.info('Hello again distributed logs');
+```
+
+By default, only the Console transport is set on the default logger. You can add or remove transports via the add() and remove() methods:
+
+``` js
+ winston.add(winston.transports.File, { filename: 'somefile.log' });
+ winston.remove(winston.transports.Console);
+```
+
+For more documenation about working with each individual transport supported by Winston see the "Working with Transports" section below.
+
+### Instantiating your own Logger
+If you would prefer to manage the object lifetime of loggers you are free to instantiate them yourself:
+
+``` js
+ var logger = new (winston.Logger)({
+ transports: [
+ new (winston.transports.Console)(),
+ new (winston.transports.File)({ filename: 'somefile.log' })
+ ]
+ });
+```
+
+You can work with this logger in the same way that you work with the default logger:
+
+``` js
+ //
+ // Logging
+ //
+ logger.log('info', 'Hello distributed log files!');
+ logger.info('Hello again distributed logs');
+
+ //
+ // Adding / Removing Transports
+ // (Yes It's chainable)
+ //
+ logger.add(winston.transports.File)
+ .remove(winston.transports.Console);
+```
+
+### Logging with Metadata
+In addition to logging string messages, winston will also optionally log additional JSON metadata objects. Adding metadata is simple:
+
+``` js
+ winston.log('info', 'Test Log Message', { anything: 'This is metadata' });
+```
+
+The way these objects is stored varies from transport to transport (to best support the storage mechanisms offered). Here's a quick summary of how each transports handles metadata:
+
+1. __Console:__ Logged via util.inspect(meta)
+2. __File:__ Logged via util.inspect(meta)
+
+## Profiling
+In addition to logging messages and metadata, winston also has a simple profiling mechanism implemented for any logger:
+
+``` js
+ //
+ // Start profile of 'test'
+ // Remark: Consider using Date.now() with async operations
+ //
+ winston.profile('test');
+
+ setTimeout(function () {
+ //
+ // Stop profile of 'test'. Logging will now take place:
+ // "17 Jan 21:00:00 - info: test duration=1000ms"
+ //
+ winston.profile('test');
+ }, 1000);
+```
+
+All 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.
+
+
+## Querying Logs
+Winston supports querying of logs with Loggly-like options.
+Specifically: `File`, `Couchdb`, `Redis`, `Loggly`, `Nssocket`, and `Http`.
+
+``` js
+ var options = {
+ from: new Date - 24 * 60 * 60 * 1000,
+ until: new Date
+ };
+
+ //
+ // Find items logged between today and yesterday.
+ //
+ winston.query(options, function (err, results) {
+ if (err) {
+ throw err;
+ }
+
+ console.log(results);
+ });
+```
+
+## Streaming Logs
+Streaming allows you to stream your logs back from your chosen transport.
+
+``` js
+ //
+ // Start at the end.
+ //
+ winston.stream({ start: -1 }).on('log', function(log) {
+ console.log(log);
+ });
+```
+
+## Exceptions
+
+### Handling Uncaught Exceptions with winston
+
+With `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.
+
+If you want to use this feature with the default logger simply call `.handleExceptions()` with a transport instance.
+
+``` js
+ //
+ // You can add a separate exception logger by passing it to `.handleExceptions`
+ //
+ winston.handleExceptions(new winston.transports.File({ filename: 'path/to/exceptions.log' }))
+
+ //
+ // Alternatively you can set `.handleExceptions` to true when adding transports to winston
+ //
+ winston.add(winston.transports.File, {
+ filename: 'path/to/all-logs.log',
+ handleExceptions: true
+ });
+```
+
+### To Exit or Not to Exit
+
+by default, winston will exit after logging an uncaughtException. if this is not the behavior you want,
+set `exitOnError = false`
+
+``` js
+ var logger = new (winston.Logger)({ exitOnError: false });
+
+ //
+ // or, like this:
+ //
+ logger.exitOnError = false;
+```
+
+When working with custom logger instances, you can pass in separate transports to the `exceptionHandlers` property or set `.handleExceptions` on any transport.
+
+Example 1
+
+``` js
+ var logger = new (winston.Logger)({
+ transports: [
+ new winston.transports.File({ filename: 'path/to/all-logs.log' })
+ ]
+ exceptionHandlers: [
+ new winston.transports.File({ filename: 'path/to/exceptions.log' })
+ ]
+ });
+```
+
+Example 2
+
+```
+var logger = new winston.Logger({
+ transports: [
+ new winston.transports.Console({
+ handleExceptions: true,
+ json: true
+ })
+ ],
+ exitOnError: false
+});
+```
+
+The `exitOnError` option can also be a function to prevent exit on only certain types of errors:
+
+``` js
+ function ignoreEpipe(err) {
+ return err.code !== 'EPIPE';
+ }
+
+ var logger = new (winston.Logger)({ exitOnError: ignoreEpipe });
+
+ //
+ // or, like this:
+ //
+ logger.exitOnError = ignoreEpipe;
+```
+
+## Logging Levels
+
+### Using Logging Levels
+Setting 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.
+
+``` js
+ //
+ // Any logger instance
+ //
+ logger.log('info', "127.0.0.1 - there's no place like home");
+ logger.log('warn', "127.0.0.1 - there's no place like home");
+ logger.log('error', "127.0.0.1 - there's no place like home");
+ logger.info("127.0.0.1 - there's no place like home");
+ logger.warn("127.0.0.1 - there's no place like home");
+ logger.error("127.0.0.1 - there's no place like home");
+
+ //
+ // Default logger
+ //
+ winston.log('info', "127.0.0.1 - there's no place like home");
+ winston.info("127.0.0.1 - there's no place like home");
+```
+
+Winston 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:
+
+``` js
+ var logger = new (winston.Logger)({
+ transports: [
+ new (winston.transports.Console)({ level: 'error' }),
+ new (winston.transports.File)({ filename: 'somefile.log' })
+ ]
+ });
+```
+
+As of 0.2.0, winston supports customizable logging levels, defaulting to [npm][0] style logging levels. Changing logging levels is easy:
+
+``` js
+ //
+ // Change levels on the default winston logger
+ //
+ winston.setLevels(winston.config.syslog.levels);
+
+ //
+ // Change levels on an instance of a logger
+ //
+ logger.setLevels(winston.config.syslog.levels);
+```
+
+Calling `.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:
+
+``` js
+ //
+ // Logger does not have 'silly' defined since that level is not in the syslog levels
+ //
+ logger.silly('some silly message');
+```
+
+### Using Custom Logging Levels
+In addition to the predefined `npm` and `syslog` levels available in Winston, you can also choose to define your own:
+
+``` js
+ var myCustomLevels = {
+ levels: {
+ foo: 0,
+ bar: 1,
+ baz: 2,
+ foobar: 3
+ },
+ colors: {
+ foo: 'blue',
+ bar: 'green',
+ baz: 'yellow',
+ foobar: 'red'
+ }
+ };
+
+ var customLevelLogger = new (winston.Logger)({ levels: myCustomLevels.levels });
+ customLevelLogger.foobar('some foobar level-ed message');
+```
+
+Although 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:
+
+``` js
+ //
+ // Make winston aware of these colors
+ //
+ winston.addColors(myCustomLevels.colors);
+```
+
+This enables transports with the 'colorize' option set to appropriately color the output of custom levels.
+
+## Further Reading
+
+### Events and Callbacks in Winston
+Each 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:
+
+``` js
+ logger.on('logging', function (transport, level, msg, meta) {
+ // [msg] and [meta] have now been logged at [level] to [transport]
+ });
+
+ logger.info('CHILL WINSTON!', { seriously: true });
+```
+
+It 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:
+
+``` js
+ //
+ // Handle errors
+ //
+ logger.on('error', function (err) { /* Do Something */ });
+
+ //
+ // Or just suppress them.
+ //
+ logger.emitErrs = false;
+```
+
+Every 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.
+
+``` js
+ logger.info('CHILL WINSTON!', { seriously: true }, function (err, level, msg, meta) {
+ // [msg] and [meta] have now been logged at [level] to **every** transport.
+ });
+```
+
+### Working with multiple Loggers in winston
+
+Often 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`:
+
+``` js
+ var winston = require('winston');
+
+ //
+ // Configure the logger for `category1`
+ //
+ winston.loggers.add('category1', {
+ console: {
+ level: 'silly',
+ colorize: 'true'
+ },
+ file: {
+ filename: '/path/to/some/file'
+ }
+ });
+
+ //
+ // Configure the logger for `category2`
+ //
+ winston.loggers.add('category2', {
+ couchdb: {
+ host: '127.0.0.1',
+ port: 5984
+ }
+ });
+```
+
+Now that your loggers are setup you can require winston _in any file in your application_ and access these pre-configured loggers:
+
+``` js
+ var winston = require('winston');
+
+ //
+ // Grab your preconfigured logger
+ //
+ var category1 = winston.loggers.get('category1');
+
+ category1.info('logging from your IoC container-based logger');
+```
+
+If you prefer to manage the `Container` yourself you can simply instantiate one:
+
+``` js
+ var winston = require('winston'),
+ container = new winston.Container();
+
+ container.add('category1', {
+ console: {
+ level: 'silly',
+ colorize: 'true'
+ },
+ file: {
+ filename: '/path/to/some/file'
+ }
+ });
+```
+
+### Sharing transports between Loggers in winston
+
+``` js
+ var winston = require('winston');
+
+ //
+ // Setup transports to be shared across all loggers
+ // in three ways:
+ //
+ // 1. By setting it on the default Container
+ // 2. By passing `transports` into the constructor function of winston.Container
+ // 3. By passing `transports` into the `.get()` or `.add()` methods
+ //
+
+ //
+ // 1. By setting it on the default Container
+ //
+ winston.loggers.options.transports = [
+ // Setup your shared transports here
+ ];
+
+ //
+ // 2. By passing `transports` into the constructor function of winston.Container
+ //
+ var container = new winston.Container({
+ transports: [
+ // Setup your shared transports here
+ ]
+ });
+
+ //
+ // 3. By passing `transports` into the `.get()` or `.add()` methods
+ //
+ winston.loggers.add('some-category', {
+ transports: [
+ // Setup your shared transports here
+ ]
+ });
+
+ container.add('some-category', {
+ transports: [
+ // Setup your shared transports here
+ ]
+ });
+```
+
+### Using winston in a CLI tool
+A 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]:
+
+```
+ info: require-analyzer starting in /Users/Charlie/Nodejitsu/require-analyzer
+ info: Found existing dependencies
+ data: {
+ data: colors: '0.x.x',
+ data: eyes: '0.1.x',
+ data: findit: '0.0.x',
+ data: npm: '1.0.x',
+ data: optimist: '0.2.x',
+ data: semver: '1.0.x',
+ data: winston: '0.2.x'
+ data: }
+ info: Analyzing dependencies...
+ info: Done analyzing raw dependencies
+ info: Retrieved packages from npm
+ warn: No additional dependencies found
+```
+
+Configuring output for this style is easy, just use the `.cli()` method on `winston` or an instance of `winston.Logger`:
+
+``` js
+ var winston = require('winston');
+
+ //
+ // Configure CLI output on the default logger
+ //
+ winston.cli();
+
+ //
+ // Configure CLI on an instance of winston.Logger
+ //
+ var logger = new winston.Logger({
+ transports: [
+ new (winston.transports.Console)()
+ ]
+ });
+
+ logger.cli();
+```
+
+### Extending another object with Logging
+Often in a given code base with lots of Loggers it is useful to add logging methods a different object so that these methods can be called with less syntax. Winston exposes this functionality via the 'extend' method:
+
+``` js
+ var myObject = {};
+
+ logger.extend(myObject);
+
+ //
+ // You can now call logger methods on 'myObject'
+ //
+ myObject.info('127.0.0.1 - there's no place like home');
+```
+
+## Working with Transports
+Right now there are four 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__
+
+1. __Console:__ Output to the terminal
+2. __Files:__ Append to a file
+3. __Loggly:__ Log to Logging-as-a-Service platform Loggly
+
+### Console Transport
+``` js
+ winston.add(winston.transports.Console, options)
+```
+
+The Console transport takes two simple options:
+
+* __level:__ Level of messages that this transport should log (default 'info').
+* __silent:__ Boolean flag indicating whether to suppress output (default false).
+* __colorize:__ Boolean flag indicating if we should colorize output (default false).
+* __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.
+
+*Metadata:* Logged via util.inspect(meta);
+
+### File Transport
+``` js
+ winston.add(winston.transports.File, options)
+```
+
+The 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:
+
+* __level:__ Level of messages that this transport should log.
+* __silent:__ Boolean flag indicating whether to suppress output.
+* __colorize:__ Boolean flag indicating if we should colorize output.
+* __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.
+* __filename:__ The filename of the logfile to write output to.
+* __maxsize:__ Max size in bytes of the logfile, if the size is exceeded then a new file is created.
+* __maxFiles:__ Limit the number of files created when the size of the logfile is exceeded.
+* __stream:__ The WriteableStream to write output to.
+* __json:__ If true, messages will be logged as JSON (default true).
+
+*Metadata:* Logged via util.inspect(meta);
+
+### Loggly Transport
+``` js
+ var Loggly = require('winston-loggly').Loggly
+ winston.add(Loggly, options);
+```
+
+The Loggly transport is based on [Nodejitsu's][5] [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:
+
+* __level:__ Level of messages that this transport should log.
+* __subdomain:__ The subdomain of your Loggly account. *[required]*
+* __auth__: The authentication information for your Loggly account. *[required with inputName]*
+* __inputName:__ The name of the input this instance should log to.
+* __inputToken:__ The input token of the input this instance should log to.
+* __json:__ If true, messages will be sent to Loggly as JSON.
+
+*Metadata:* Logged in suggested [Loggly format][2]
+
+### Riak Transport
+As of `0.3.0` the Riak transport has been broken out into a new module: [winston-riak][17]. Using it is just as easy:
+
+``` js
+ var Riak = require('winston-riak').Riak;
+ winston.add(Riak, options);
+```
+
+In 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:
+
+* __level:__ Level of messages that this transport should log.
+* __bucket:__ The name of the Riak bucket you wish your logs to be in or a function to generate bucket names dynamically.
+
+``` js
+ // Use a single bucket for all your logs
+ var singleBucketTransport = new (Riak)({ bucket: 'some-logs-go-here' });
+
+ // Generate a dynamic bucket based on the date and level
+ var dynamicBucketTransport = new (Riak)({
+ bucket: function (level, msg, meta, now) {
+ var d = new Date(now);
+ return level + [d.getDate(), d.getMonth(), d.getFullYear()].join('-');
+ }
+ });
+```
+
+*Metadata:* Logged as JSON literal in Riak
+
+### MongoDB Transport
+As of `0.3.0` the MongoDB transport has been broken out into a new module: [winston-mongodb][16]. Using it is just as easy:
+
+``` js
+ var MongoDB = require('winston-mongodb').MongoDB;
+ winston.add(MongoDB, options);
+```
+
+The MongoDB transport takes the following options. 'db' is required:
+
+* __level:__ Level of messages that this transport should log.
+* __silent:__ Boolean flag indicating whether to suppress output.
+* __db:__ The name of the database you want to log to. *[required]*
+* __collection__: The name of the collection you want to store log messages in, defaults to 'log'.
+* __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.
+* __host:__ The host running MongoDB, defaults to localhost.
+* __port:__ The port on the host that MongoDB is running on, defaults to MongoDB's default port.
+
+*Metadata:* Logged as a native JSON object.
+
+### SimpleDB Transport
+
+The [winston-simpledb][18] transport is just as easy:
+
+``` js
+ var SimpleDB = require('winston-simpledb').SimpleDB;
+ winston.add(SimpleDB, options);
+```
+
+The SimpleDB transport takes the following options. All items marked with an asterisk are required:
+
+* __awsAccessKey__:* your AWS Access Key
+* __secretAccessKey__:* your AWS Secret Access Key
+* __awsAccountId__:* your AWS Account Id
+* __domainName__:* a string or function that returns the domain name to log to
+* __region__:* the region your domain resides in
+* __itemName__: a string ('uuid', 'epoch', 'timestamp') or function that returns the item name to log
+
+*Metadata:* Logged as a native JSON object to the 'meta' attribute of the item.
+
+### Mail Transport
+
+The [winston-mail][19] is an email transport:
+
+``` js
+ var Mail = require('winston-mail').Mail;
+ winston.add(Mail, options);
+```
+
+The Mail transport uses [emailjs](https://github.com/eleith/emailjs) behind the scenes. Options are the following:
+
+* __to:__ The address(es) you want to send to. *[required]*
+* __from:__ The address you want to send from. (default: `winston@[server-host-name]`)
+* __host:__ SMTP server hostname (default: localhost)
+* __port:__ SMTP port (default: 587 or 25)
+* __username__ User for server auth
+* __password__ Password for server auth
+* __ssl:__ Use SSL (boolean or object { key, ca, cert })
+* __tls:__ Boolean (if true, use starttls)
+* __level:__ Level of messages that this transport should log.
+* __silent:__ Boolean flag indicating whether to suppress output.
+
+*Metadata:* Stringified as JSON in email.
+
+### Amazon SNS (Simple Notification System) Transport
+
+The [winston-sns][21] transport uses amazon SNS to send emails, texts, or a bunch of other notifications.
+
+``` js
+ require('winston-sns').SNS;
+ winston.add(winston.transports.SNS, options);
+```
+
+Options:
+
+* __aws_key:__ Your Amazon Web Services Key. *[required]*
+* __aws_secret:__ Your Amazon Web Services Secret. *[required]*
+* __subscriber:__ Subscriber number - found in your SNS AWS Console, after clicking on a topic. Same as AWS Account ID. *[required]*
+* __topic_arn:__ Also found in SNS AWS Console - listed under a topic as Topic ARN. *[required]*
+* __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`)
+* __subject:__ Subject for notifications. (default: "Winston Error Report")
+* __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")
+* __level:__ lowest level this transport will log. (default: `info`)
+
+### Graylog2 Transport
+
+[winston-graylog2][22] is a Graylog2 transport:
+
+``` js
+ var Graylog2 = require('winston-graylog2').Graylog2;
+ winston.add(Graylog2, options);
+```
+
+The Graylog2 transport connects to a Graylog2 server over UDP using the following options:
+
+* __level:__ Level of messages this transport should log. (default: info)
+* __silent:__ Boolean flag indicating whether to suppress output. (default: false)
+
+* __graylogHost:__ IP address or hostname of the graylog2 server. (default: localhost)
+* __graylogPort:__ Port to send messages to on the graylog2 server. (default: 12201)
+* __graylogHostname:__ The hostname associated with graylog2 messages. (default: require('os').hostname())
+* __graylogFacility:__ The graylog2 facility to send log messages.. (default: nodejs)
+
+*Metadata:* Stringified as JSON in the full message GELF field.
+
+### Adding Custom Transports
+Adding 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.
+
+``` js
+ var util = require('util'),
+ winston = require('winston');
+
+ var CustomLogger = winston.transports.CustomerLogger = function (options) {
+ //
+ // Name this logger
+ //
+ this.name = 'customLogger';
+
+ //
+ // Set the level from your options
+ //
+ this.level = options.level || 'info';
+
+ //
+ // Configure your storage backing as you see fit
+ //
+ };
+
+ //
+ // Inherit from `winston.Transport` so you can take advantage
+ // of the base functionality and `.handleExceptions()`.
+ //
+ util.inherits(CustomLogger, winston.Transport);
+
+ CustomLogger.prototype.log = function (level, msg, meta, callback) {
+ //
+ // Store this message and metadata, maybe use some custom logic
+ // then callback indicating success.
+ //
+ callback(null, true);
+ };
+```
+
+### Inspirations
+1. [npm][0]
+2. [log.js][4]
+3. [socket.io][5]
+4. [node-rlog][6]
+5. [BigBrother][7]
+6. [Loggly][8]
+
+## Installation
+
+### Installing npm (node package manager)
+```
+ curl http://npmjs.org/install.sh | sh
+```
+
+### Installing winston
+```
+ [sudo] npm install winston
+```
+
+## Run Tests
+All of the winston tests are written in [vows][9], and designed to be run with npm.
+
+``` bash
+ $ npm test
+```
+
+#### Author: [Charlie Robbins](http://twitter.com/indexzero)
+#### Contributors: [Matthew Bergman](http://github.com/fotoverite), [Marak Squires](http://github.com/marak)
+
+[0]: https://github.com/isaacs/npm/blob/master/lib/utils/log.js
+[1]: http://nodejs.org/docs/v0.3.5/api/events.html#events.EventEmitter
+[2]: http://github.com/nodejitsu/require-analyzer
+[3]: http://nodejitsu.com
+[4]: https://github.com/visionmedia/log.js
+[5]: http://socket.io
+[6]: https://github.com/jbrisbin/node-rlog
+[7]: https://github.com/feisty/BigBrother
+[8]: http://loggly.com
+[9]: http://vowsjs.org
View
342 node_modules/winston/docs/transports.md
@@ -0,0 +1,342 @@
+# Winston Transports
+
+In `winston` a transport 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.
+
+There are several [core transports](#winston-core) included in `winston`, which leverage the built-in networking and file I/O offered by node.js core. In addition, there are [third-party transports which are supported by the winston core team](#winston-more). And last (but not least) there are [additional transports written by members of the community](#additional-transports).
+
+* **[Winston Core](#winston-core)**
+ * [Console](#console-transport)
+ * [File](#file-transport)
+ * [Http](#http-transport)
+ * [Webhook](#webhook-transport)
+
+* **[Winston More](#winston-more)**
+ * [CouchDB](#couchdb-transport)
+ * [Loggly](#loggly-transport)
+ * [MongoDB](#mongodb-transport)
+ * [Redis](#redis-transport)
+ * [Riak](#riak-transport)
+
+* **[Additional Transports](#additional-transports)**
+ * [SimpleDB](#simpledb-transport)
+ * [Mail](#mail-transport)
+ * [Amazon SNS](#amazon-sns-simple-notification-system-transport)
+ * [Graylog2](#graylog2-transport)
+
+## Winston Core
+
+There are several core transports included in `winston`, which leverage the built-in networking and file I/O offered by node.js core.
+
+* [Console](#console-transport)
+* [File](#file-transport)
+* [Http](#http-transport)
+* [Webhook](#webhook-transport)
+
+### Console Transport
+
+``` js
+ winston.add(winston.transports.Console, options)
+```
+
+The Console transport takes two simple options:
+
+* __level:__ Level of messages that this transport should log (default 'debug').
+* __silent:__ Boolean flag indicating whether to suppress output (default false).
+* __colorize:__ Boolean flag indicating if we should colorize output (default false).
+* __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.
+
+*Metadata:* Logged via util.inspect(meta);
+
+### File Transport
+
+``` js
+ winston.add(winston.transports.File, options)
+```
+
+The File transport should really be the 'Stream' transport since it will accept any [WritableStream][0]. It is named such because it will also accept filenames via the 'filename' option:
+
+* __level:__ Level of messages that this transport should log.
+* __silent:__ Boolean flag indicating whether to suppress output.
+* __colorize:__ Boolean flag indicating if we should colorize output.
+* __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.
+* __filename:__ The filename of the logfile to write output to.
+* __maxsize:__ Max size in bytes of the logfile, if the size is exceeded then a new file is created.
+* __maxFiles:__ Limit the number of files created when the size of the logfile is exceeded.
+* __stream:__ The WriteableStream to write output to.
+* __json:__ If true, messages will be logged as JSON (default true).
+
+*Metadata:* Logged via util.inspect(meta);
+
+### Http Transport
+
+``` js
+ winston.add(winston.transports.Http, options)
+```
+
+The `Http` transport is a generic way to log, query, and stream logs from an arbitrary Http endpoint, preferably [winstond][1]. It takes options that are passed to the node.js `http` or `https` request:
+
+* __host:__ (Default: **localhost**) Remote host of the HTTP logging endpoint
+* __port:__ (Default: **80 or 443**) Remote port of the HTTP logging endpoint
+* __path:__ (Default: **/**) Remote URI of the HTTP logging endpoint
+* __auth:__ (Default: **None**) An object representing the `username` and `password` for HTTP Basic Auth
+* __ssl:__ (Default: **false**) Value indicating if we should us HTTPS
+
+## Winston More
+
+Starting with `winston@0.3.0` an effort was made to remove any transport which added additional dependencies to `winston`. At the time there were several transports already in `winston` which will **always be supported by the winston core team.**
+
+* [CouchDB](#couchdb-transport)
+* [Redis](#redis-transport)
+* [MongoDB](#mongodb-transport)
+* [Riak](#riak-transport)
+* [Loggly](#loggly-transport)
+
+### CouchDB Transport
+
+_As of `winston@0.6.0` the CouchDB transport has been broken out into a new module: [winston-couchdb][2]._
+
+``` js
+ winston.add(winston.transports.Couchdb, options)
+```
+
+The `Couchdb` will place your logs in a remote CouchDB database. It will also create a [Design Document][3], `_design/Logs` for later querying and streaming your logs from CouchDB. The transport takes the following options:
+
+* __host:__ (Default: **localhost**) Remote host of the HTTP logging endpoint
+* __port:__ (Default: **5984**) Remote port of the HTTP logging endpoint
+* __db:__ (Default: **winston**) Remote URI of the HTTP logging endpoint
+* __auth:__ (Default: **None**) An object representing the `username` and `password` for HTTP Basic Auth
+* __ssl:__ (Default: **false**) Value indicating if we should us HTTPS
+
+### Redis Transport
+
+``` js
+ winston.add(winston.transports.Redis, options)
+```
+
+This transport accepts the options accepted by the [node-redis][4] client:
+
+* __host:__ (Default **localhost**) Remote host of the Redis server
+* __port:__ (Default **6379**) Port the Redis server is running on.
+* __auth:__ (Default **None**) Password set on the Redis server
+
+In addition to these, the Redis transport also accepts the following options.
+
+* __length:__ (Default **200**) Number of log messages to store.
+* __container:__ (Default **winston**) Name of the Redis container you wish your logs to be in.
+* __channel:__ (Default **None**) Name of the Redis channel to stream logs from.
+
+*Metadata:* Logged as JSON literal in Redis
+
+### Loggly Transport
+
+_As of `winston@0.6.0` the Loggly transport has been broken out into a new module: [winston-loggly][5]._
+
+``` js
+ winston.add(winston.transports.Loggly, options);
+```
+
+The Loggly transport is based on [Nodejitsu's][6] [node-loggly][7] implementation of the [Loggly][8] API. If you haven't heard of Loggly before, you should probably read their [value proposition][9]. The Loggly transport takes the following options. Either 'inputToken' or 'inputName' is required:
+
+* __level:__ Level of messages that this transport should log.
+* __subdomain:__ The subdomain of your Loggly account. *[required]*
+* __auth__: The authentication information for your Loggly account. *[required with inputName]*
+* __inputName:__ The name of the input this instance should log to.
+* __inputToken:__ The input token of the input this instance should log to.
+* __json:__ If true, messages will be sent to Loggly as JSON.
+
+*Metadata:* Logged in suggested [Loggly format][10]
+
+### Riak Transport
+
+_As of `winston@0.3.0` the Riak transport has been broken out into a new module: [winston-riak][11]._ Using it is just as easy:
+
+``` js
+ var Riak = require('winston-riak').Riak;
+ winston.add(Riak, options);
+```
+
+In addition to the options accepted by the [riak-js][12] [client][13], the Riak transport also accepts the following options. It is worth noting that the riak-js debug option is set to *false* by default:
+
+* __level:__ Level of messages that this transport should log.
+* __bucket:__ The name of the Riak bucket you wish your logs to be in or a function to generate bucket names dynamically.
+
+``` js
+ // Use a single bucket for all your logs
+ var singleBucketTransport = new (Riak)({ bucket: 'some-logs-go-here' });
+
+ // Generate a dynamic bucket based on the date and level
+ var dynamicBucketTransport = new (Riak)({
+ bucket: function (level, msg, meta, now) {
+ var d = new Date(now);
+ return level + [d.getDate(), d.getMonth(), d.getFullYear()].join('-');
+ }
+ });
+```
+
+*Metadata:* Logged as JSON literal in Riak
+
+### MongoDB Transport
+
+As of `winston@0.3.0` the MongoDB transport has been broken out into a new module: [winston-mongodb][14]. Using it is just as easy:
+
+``` js
+ var MongoDB = require('winston-mongodb').MongoDB;
+ winston.add(MongoDB, options);
+```
+
+The MongoDB transport takes the following options. 'db' is required:
+
+* __level:__ Level of messages that this transport should log.
+* __silent:__ Boolean flag indicating whether to suppress output.
+* __db:__ The name of the database you want to log to. *[required]*
+* __collection__: The name of the collection you want to store log messages in, defaults to 'log'.
+* __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.
+* __host:__ The host running MongoDB, defaults to localhost.
+* __port:__ The port on the host that MongoDB is running on, defaults to MongoDB's default port.
+
+*Metadata:* Logged as a native JSON object.
+
+## Additional Transports
+
+The community has truly embraced `winston`; there are over **23** winston transports and over half of them are maintained by authors external to the winston core team. If you want to check them all out, just search `npm`:
+
+``` bash
+ $ npm search winston
+```
+
+**If you have an issue using one of these modules you should contact the module author directly**
+
+### SimpleDB Transport
+
+The [winston-simpledb][15] transport is just as easy:
+
+``` js
+ var SimpleDB = require('winston-simpledb').SimpleDB;
+ winston.add(SimpleDB, options);
+```
+
+The SimpleDB transport takes the following options. All items marked with an asterisk are required:
+
+* __awsAccessKey__:* your AWS Access Key
+* __secretAccessKey__:* your AWS Secret Access Key
+* __awsAccountId__:* your AWS Account Id
+* __domainName__:* a string or function that returns the domain name to log to
+* __region__:* the region your domain resides in
+* __itemName__: a string ('uuid', 'epoch', 'timestamp') or function that returns the item name to log
+
+*Metadata:* Logged as a native JSON object to the 'meta' attribute of the item.
+
+### Mail Transport
+
+The [winston-mail][16] is an email transport:
+
+``` js
+ var Mail = require('winston-mail').Mail;
+ winston.add(Mail, options);
+```
+
+The Mail transport uses [node-mail][17] behind the scenes. Options are the following, `to` and `host` are required:
+
+* __to:__ The address(es) you want to send to. *[required]*
+* __from:__ The address you want to send from. (default: `winston@[server-host-name]`)
+* __host:__ SMTP server hostname
+* __port:__ SMTP port (default: 587 or 25)
+* __secure:__ Use secure
+* __username__ User for server auth
+* __password__ Password for server auth
+* __level:__ Level of messages that this transport should log.
+* __silent:__ Boolean flag indicating whether to suppress output.
+
+*Metadata:* Stringified as JSON in email.
+
+### Amazon SNS (Simple Notification System) Transport
+
+The [winston-sns][18] transport uses amazon SNS to send emails, texts, or a bunch of other notifications.
+
+``` js
+ require('winston-sns').SNS;
+ winston.add(winston.transports.SNS, options);
+```
+
+Options:
+
+* __aws_key:__ Your Amazon Web Services Key. *[required]*
+* __aws_secret:__ Your Amazon Web Services Secret. *[required]*
+* __subscriber:__ Subscriber number - found in your SNS AWS Console, after clicking on a topic. Same as AWS Account ID. *[required]*
+* __topic_arn:__ Also found in SNS AWS Console - listed under a topic as Topic ARN. *[required]*
+* __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`)
+* __subject:__ Subject for notifications. (default: "Winston Error Report")
+* __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")
+* __level:__ lowest level this transport will log. (default: `info`)
+
+### Graylog2 Transport
+
+[winston-graylog2][19] is a Graylog2 transport:
+
+``` js
+ var Graylog2 = require('winston-graylog2').Graylog2;
+ winston.add(Graylog2, options);
+```
+
+The Graylog2 transport connects to a Graylog2 server over UDP using the following options:
+
+* __level:__ Level of messages this transport should log. (default: info)
+* __silent:__ Boolean flag indicating whether to suppress output. (default: false)
+
+* __graylogHost:__ IP address or hostname of the graylog2 server. (default: localhost)
+* __graylogPort:__ Port to send messages to on the graylog2 server. (default: 12201)
+* __graylogHostname:__ The hostname associated with graylog2 messages. (default: require('os').hostname())
+* __graylogFacility:__ The graylog2 facility to send log messages.. (default: nodejs)
+
+*Metadata:* Stringified as JSON in the full message GELF field.
+
+## Find more Transports
+
+``` bash
+ $ npm search winston
+ (...)
+ winston-amon Winston transport for Amon logging =zoramite
+ winston-amqp An AMQP transport for winston =kr1sp1n
+ winston-couchdb a couchdb transport for winston =alz
+ winston-express Express middleware to let you use winston from the browser. =regality
+ winston-graylog2 A graylog2 transport for winston =smithclay
+ winston-hbase A HBase transport for winston =ddude
+ winston-loggly A Loggly transport for winston =indexzero
+ winston-mail A mail transport for winston =wavded
+ winston-mail2 A mail transport for winston =ivolo
+ winston-mongodb A MongoDB transport for winston =indexzero
+ winston-nodemail A mail transport for winston =reinpk
+ winston-nssocket nssocket transport for winston =mmalecki
+ winston-papertrail A Papertrail transport for winston =kenperkins
+ winston-redis A fixed-length Redis transport for winston =indexzero
+ winston-riak A Riak transport for winston =indexzero
+ winston-scribe A scribe transport for winston =wnoronha
+ winston-simpledb A Winston transport for Amazon SimpleDB =chilts
+ winston-skywriter A Windows Azure table storage transport for winston =pofallon
+ winston-sns A Simple Notification System Transport for winston =jesseditson
+ winston-syslog A syslog transport for winston =indexzero
+ winston-syslog-ain2 An ain2 based syslog transport for winston =lamtha
+ winston-winlog Windows Event Log logger for Winston =jfromaniello
+ winston-zmq A 0MQ transport for winston =dhendo
+```
+
+[0]: http://nodejs.org/docs/v0.3.5/api/streams.html#writable_Stream
+[1]: https://github.com/flatiron/winstond
+[2]: https://github.com/indexzero/winston-couchdb
+[3]: http://guide.couchdb.org/draft/design.html
+[4]: https://github.com/mranney/node_redis
+[5]: https://github.com/indexzero/winston-loggly
+[6]: http://nodejitsu.com
+[7]: https://github.com/nodejitsu/node-loggly
+[8]: http://loggly.com
+[9]: http://www.loggly.com/product/
+[10]: http://wiki.loggly.com/loggingfromcode
+[11]: https://github.com/indexzero/winston-riak
+[12]: http://riakjs.org
+[13]: https://github.com/frank06/riak-js/blob/master/src/http_client.coffee#L10
+[14]: http://github.com/indexzero/winston-mongodb
+[15]: http://github.com/appsattic/winston-simpledb
+[16]: http://github.com/wavded/winston-mail
+[17]: https://github.com/weaver/node-mail
+[18]: https://github.com/jesseditson/winston-sns
+[19]: https://github.com/flite/winston-graylog2
View
18 node_modules/winston/examples/couchdb.js
@@ -0,0 +1,18 @@
+var winston = require('../lib/winston');
+
+//
+// Create a new winston logger instance with two tranports: Console, and Couchdb
+//
+//
+// The Console transport will simply output to the console screen
+// The Couchdb tranport will perform an HTTP POST request to the specified CouchDB instance
+//
+var logger = new (winston.Logger)({
+ transports: [
+ new (winston.transports.Console)(),
+ new (winston.transports.Couchdb)({ 'host': 'localhost', 'db': 'logs' })
+ // if you need auth do this: new (winston.transports.Couchdb)({ 'user': 'admin', 'pass': 'admin', 'host': 'localhost', 'db': 'logs' })
+ ]
+});
+
+logger.log('info', 'Hello webhook log files!', { 'foo': 'bar' });
View
4 node_modules/winston/examples/exception.js
@@ -0,0 +1,4 @@
+var winston = require('../');
+winston.handleExceptions(new winston.transports.Console({ colorize: true, json: true }));
+
+throw new Error('Hello, winston!');
View
10 node_modules/winston/examples/raw-mode.js
@@ -0,0 +1,10 @@
+var winston = require('../lib/winston');
+
+var logger = new (winston.Logger)({
+ transports: [
+ new (winston.transports.Console)({ raw: true }),
+ ]
+});
+
+logger.log('info', 'Hello, this is a raw logging event', { 'foo': 'bar' });
+logger.log('info', 'Hello, this is a raw logging event 2', { 'foo': 'bar' });
View
17 node_modules/winston/examples/webhook-post.js
@@ -0,0 +1,17 @@
+var winston = require('../lib/winston');
+
+//
+// Create a new winston logger instance with two tranports: Console, and Webhook
+//
+//
+// The Console transport will simply output to the console screen
+// The Webhook tranports will perform an HTTP POST request to an abritrary end-point ( for post/recieve webhooks )
+//
+var logger = new (winston.Logger)({
+ transports: [
+ new (winston.transports.Console)(),
+ new (winston.transports.Webhook)({ 'host': 'localhost', 'port': 8080, 'path': '/collectdata' })
+ ]
+});
+
+logger.log('info', 'Hello webhook log files!', { 'foo': 'bar' });
View
145 node_modules/winston/lib/winston.js
@@ -0,0 +1,145 @@
+/*
+ * winston.js: Top-level include defining Winston.
+ *
+ * (C) 2010 Charlie Robbins
+ * MIT LICENCE
+ *
+ */
+
+var winston = exports;
+
+//
+// Expose version using `pkginfo`
+//
+require('pkginfo')(module, 'version');
+
+//
+// Include transports defined by default by winston
+//
+winston.transports = require('./winston/transports');
+
+//
+// Expose utility methods
+//
+var common = require('./winston/common');
+winston.hash = common.hash;
+winston.clone = common.clone;
+winston.longestElement = common.longestElement;
+winston.exception = require('./winston/exception');
+winston.config = require('./winston/config');
+winston.addColors = winston.config.addColors;
+
+//
+// Expose core Logging-related prototypes.
+//
+winston.Container = require('./winston/container').Container;
+winston.Logger = require('./winston/logger').Logger;
+winston.Transport = require('./winston/transports/transport').Transport;
+
+//
+// We create and expose a default `Container` to `winston.loggers` so that the
+// programmer may manage multiple `winston.Logger` instances without any additional overhead.
+//
+// ### some-file1.js
+//
+// var logger = require('winston').loggers.get('something');
+//
+// ### some-file2.js
+//
+// var logger = require('winston').loggers.get('something');
+//
+winston.loggers = new winston.Container();
+
+//
+// We create and expose a 'defaultLogger' so that the programmer may do the
+// following without the need to create an instance of winston.Logger directly:
+//
+// var winston = require('winston');
+// winston.log('info', 'some message');
+// winston.error('some error');
+//
+var defaultLogger = new winston.Logger({
+ transports: [new winston.transports.Console()]
+});
+
+//
+// Pass through the target methods onto `winston.
+//
+var methods = [
+ 'log',
+ 'query',
+ 'stream',
+ 'add',
+ 'remove',
+ 'profile',
+ 'startTimer',
+ 'extend',
+ 'cli',
+ 'handleExceptions',
+ 'unhandleExceptions'
+];
+common.setLevels(winston, null, defaultLogger.levels);
+methods.forEach(function (method) {
+ winston[method] = function () {
+ return defaultLogger[method].apply(defaultLogger, arguments);
+ };
+});
+
+//
+// ### function cli ()
+// Configures the default winston logger to have the
+// settings for command-line interfaces: no timestamp,
+// colors enabled, padded output, and additional levels.
+//
+winston.cli = function () {
+ winston.padLevels = true;
+ common.setLevels(winston, defaultLogger.levels, winston.config.cli.levels);
+ defaultLogger.setLevels(winston.config.cli.levels);
+ winston.config.addColors(winston.config.cli.colors);
+
+ if (defaultLogger.transports.console) {
+ defaultLogger.transports.console.colorize = true;
+ defaultLogger.transports.console.timestamp = false;
+ }
+
+ return winston;
+};
+
+//
+// ### function setLevels (target)
+// #### @target {Object} Target levels to use
+// Sets the `target` levels specified on the default winston logger.
+//
+winston.setLevels = function (target) {
+ common.setLevels(winston, defaultLogger.levels, target);
+ defaultLogger.setLevels(target);
+};
+
+//
+// Define getters / setters for appropriate properties of the
+// default logger which need to be exposed by winston.
+//
+['emitErrs', 'exitOnError', 'padLevels', 'level', 'levelLength', 'stripColors'].forEach(function (prop) {
+ Object.defineProperty(winston, prop, {
+ get: function () {
+ return defaultLogger[prop];
+ },
+ set: function (val) {
+ defaultLogger[prop] = val;
+ }
+ });
+});
+
+//
+// @default {Object}
+// The default transports and exceptionHandlers for
+// the default winston logger.
+//
+Object.defineProperty(winston, 'default', {
+ get: function () {
+ return {
+ transports: defaultLogger.transports,
+ exceptionHandlers: defaultLogger.exceptionHandlers
+ };
+ }
+});
View
259 node_modules/winston/lib/winston/common.js
@@ -0,0 +1,259 @@
+/*
+ * common.js: Internal helper and utility functions for winston
+ *
+ * (C) 2010 Charlie Robbins
+ * MIT LICENCE
+ *
+ */
+
+var util = require('util'),
+ crypto = require('crypto'),
+ cycle = require('cycle'),
+ config = require('./config');
+
+//
+// ### function setLevels (target, past, current)
+// #### @target {Object} Object on which to set levels.
+// #### @past {Object} Previous levels set on target.
+// #### @current {Object} Current levels to set on target.
+// Create functions on the target objects for each level
+// in current.levels. If past is defined, remove functions
+// for each of those levels.
+//
+exports.setLevels = function (target, past, current, isDefault) {
+ if (past) {
+ Object.keys(past).forEach(function (level) {
+ delete target[level];
+ });
+ }
+
+ target.levels = current || config.npm.levels;
+ if (target.padLevels) {
+ target.levelLength = exports.longestElement(Object.keys(target.levels));
+ }
+
+ //
+ // Define prototype methods for each log level
+ // e.g. target.log('info', msg) <=> target.info(msg)
+ //
+ Object.keys(target.levels).forEach(function (level) {
+ target[level] = function (msg) {
+ var args = Array.prototype.slice.call(arguments),
+ callback = typeof args[args.length - 1] === 'function' || !args[args.length - 1] ? args.pop() : null,
+ meta = args.length === 2 ? args.pop() : null;
+
+ return target.log(level, msg, meta, callback);
+ };
+ });
+
+ return target;
+};
+
+//
+// ### function longestElement
+// #### @xs {Array} Array to calculate against
+// Returns the longest element in the `xs` array.
+//
+exports.longestElement = function (xs) {
+ return Math.max.apply(
+ null,
+ xs.map(function (x) { return x.length; })
+ );
+};
+
+//
+// ### function clone (obj)
+// #### @obj {Object} Object to clone.
+// Helper method for deep cloning pure JSON objects
+// i.e. JSON objects that are either literals or objects (no Arrays, etc)
+//
+exports.clone = function (obj) {
+ // we only need to clone refrence types (Object)
+ if (!(obj instanceof Object)) {
+ return obj;
+ }
+ else if (obj instanceof Date) {
+ return obj;
+ }
+
+ var copy = {};
+ for (var i in obj) {
+ if (Array.isArray(obj[i])) {
+ copy[i] = obj[i].slice(0);
+ }
+ else if (obj[i] instanceof Buffer) {
+ copy[i] = obj[i].slice(0);
+ }
+ else if (typeof obj[i] != 'function') {
+ copy[i] = obj[i] instanceof Object ? exports.clone(obj[i]) : obj[i];
+ }
+ }
+
+ return copy;
+};
+
+//
+// ### function log (options)
+// #### @options {Object} All information about the log serialization.
+// Generic logging function for returning timestamped strings
+// with the following options:
+//
+// {
+// level: 'level to add to serialized message',
+// message: 'message to serialize',
+// meta: 'additional logging metadata to serialize',
+// colorize: false, // Colorizes output (only if `.json` is false)
+// timestamp: true // Adds a timestamp to the serialized message
+// }
+//
+exports.log = function (options) {
+ var timestampFn = typeof options.timestamp === 'function'
+ ? options.timestamp
+ : exports.timestamp,
+ timestamp = options.timestamp ? timestampFn() : null,
+ meta = options.meta ? exports.clone(cycle.decycle(options.meta)) : null,
+ output;
+
+ //
+ // raw mode is intended for outputing winston as streaming JSON to STDOUT
+ //
+ if (options.raw) {
+ if (typeof meta !== 'object' && meta != null) {
+ meta = { meta: meta };
+ }
+ output = exports.clone(meta) || {};
+ output.level = options.level;
+ output.message = options.message.stripColors;
+ return JSON.stringify(output);
+ }
+
+ //
+ // json mode is intended for pretty printing multi-line json to the terminal
+ //
+ if (options.json) {
+ if (typeof meta !== 'object' && meta != null) {
+ meta = { meta: meta };
+ }
+
+ output = exports.clone(meta) || {};
+ output.level = options.level;
+ output.message = options.message;
+
+ if (timestamp) {
+ output.timestamp = timestamp;
+ }
+
+ if (typeof options.stringify === 'function') {
+ return options.stringify(output);
+ }
+
+ return JSON.stringify(output, function (key, value) {
+ return value instanceof Buffer
+ ? value.toString('base64')
+ : value;
+ });
+ }
+
+ output = timestamp ? timestamp + ' - ' : '';
+ output += options.colorize ? config.colorize(options.level) : options.level;
+ output += (': ' + options.message);
+
+ if (meta) {
+ if (typeof meta !== 'object') {
+ output += ' ' + meta;
+ }
+ else if (Object.keys(meta).length > 0) {
+ output += ' ' + (options.prettyPrint ? ('\n' + util.inspect(meta, false, null, options.colorize)) : exports.serialize(meta));
+ }
+ }
+
+ return output;
+};
+
+exports.capitalize = function (str) {
+ return str && str[0].toUpperCase() + str.slice(1);
+};
+
+//
+// ### function hash (str)
+// #### @str {string} String to hash.
+// Utility function for creating unique ids
+// e.g. Profiling incoming HTTP requests on the same tick
+//
+exports.hash = function (str) {
+ return crypto.createHash('sha1').update(str).digest('hex');
+};
+
+//
+// ### function pad (n)
+// Returns a padded string if `n < 10`.
+//
+exports.pad = function (n) {
+ return n < 10 ? '0' + n.toString(10) : n.toString(10);
+};
+
+//
+// ### function timestamp ()
+// Returns a timestamp string for the current time.
+//
+exports.timestamp = function () {
+ return new Date().toISOString();
+};
+
+//
+// ### function serialize (obj, key)
+// #### @obj {Object|literal} Object to serialize
+// #### @key {string} **Optional** Optional key represented by obj in a larger object
+// Performs simple comma-separated, `key=value` serialization for Loggly when
+// logging to non-JSON inputs.
+//
+exports.serialize = function (obj, key) {
+ if (obj === null) {
+ obj = 'null';
+ }
+ else if (obj === undefined) {
+ obj = 'undefined';
+ }
+ else if (obj === false) {
+ obj = 'false';
+ }
+
+ if (typeof obj !== 'object') {
+ return key ? key + '=' + obj : obj;
+ }
+
+ if (obj instanceof Buffer) {
+ return key ? key + '=' + obj.toString('base64') : obj.toString('base64');
+ }
+
+ var msg = '',
+ keys = Object.keys(obj),
+ length = keys.length;
+
+ for (var i = 0; i < length; i++) {
+ if (Array.isArray(obj[keys[i]])) {
+ msg += keys[i] + '=[';
+
+ for (var j = 0, l = obj[keys[i]].length; j < l; j++) {
+ msg += exports.serialize(obj[keys[i]][j]);
+ if (j < l - 1) {
+ msg += ', ';
+ }
+ }
+
+ msg += ']';
+ }
+ else if (obj[keys[i]] instanceof Date) {
+ msg += keys[i] + '=' + obj[keys[i]];
+ }
+ else {
+ msg += exports.serialize(obj[keys[i]], keys[i]);
+ }
+
+ if (i < length - 1) {
+ msg += ', ';
+ }
+ }
+
+ return msg;
+};
View
45 node_modules/winston/lib/winston/config.js
@@ -0,0 +1,45 @@
+/*
+ * config.js: Default settings for all levels that winston knows about
+ *
+ * (C) 2010 Charlie Robbins
+ * MIT LICENCE
+ *
+ */
+
+var colors = require('colors');
+
+var config = exports,
+ allColors = exports.allColors = {};
+
+config.addColors = function (colors) {
+ mixin(allColors, colors);
+};
+
+config.colorize = function (level) {
+ return level[allColors[level]];
+};
+
+//
+// Export config sets
+//
+config.cli = require('./config/cli-config');
+config.npm = require('./config/npm-config');
+config.syslog = require('./config/syslog-config');
+
+//
+// Add colors for pre-defined config sets
+//
+config.addColors(config.npm.colors);
+config.addColors(config.syslog.colors);
+
+function mixin (target) {
+ var args = Array.prototype.slice.call(arguments, 1);
+
+ args.forEach(function (a) {
+ var keys = Object.keys(a);
+ for (var i = 0; i < keys.length; i++) {
+ target[keys[i]] = a[keys[i]];
+ }
+ });
+ return target;
+};
View
35 node_modules/winston/lib/winston/config/cli-config.js
@@ -0,0 +1,35 @@
+/*
+ * cli-config.js: Config that conform to commonly used CLI logging levels.
+ *
+ * (C) 2010 Charlie Robbins
+ * MIT LICENCE
+ *
+ */
+
+var cliConfig = exports;
+
+cliConfig.levels = {
+ silly: 0,
+ input: 1,
+ verbose: 2,
+ prompt: 3,
+ info: 4,
+ data: 5,
+ help: 6,
+ warn: 7,
+ debug: 8,
+ error: 9
+};
+
+cliConfig.colors = {
+ silly: 'magenta',
+ input: 'grey',
+ verbose: 'cyan',
+ prompt: 'grey',
+ info: 'green',
+ data: 'grey',
+ help: 'cyan',
+ warn: 'yellow',
+ debug: 'blue',
+ error: 'red'
+};
View
27 node_modules/winston/lib/winston/config/npm-config.js
@@ -0,0 +1,27 @@
+/*
+ * npm-config.js: Config that conform to npm logging levels.
+ *
+ * (C) 2010 Charlie Robbins
+ * MIT LICENCE
+ *
+ */
+
+var npmConfig = exports;
+
+npmConfig.levels = {
+ silly: 0,
+ verbose: 1,
+ info: 2,
+ warn: 3,
+ debug: 4,
+ error: 5
+};
+
+npmConfig.colors = {
+ silly: 'magenta',
+ verbose: 'cyan',
+ info: 'green',
+ warn: 'yellow',
+ debug: 'blue',
+ error: 'red'
+};
View
31 node_modules/winston/lib/winston/config/syslog-config.js
@@ -0,0 +1,31 @@
+/*
+ * syslog-config.js: Config that conform to syslog logging levels.
+ *
+ * (C) 2010 Charlie Robbins
+ * MIT LICENCE
+ *
+ */
+
+var syslogConfig = exports;
+
+syslogConfig.levels = {
+ debug: 0,
+ info: 1,
+ notice: 2,
+ warning: 3,
+ error: 4,
+ crit: 5,
+ alert: 6,
+ emerg: 7
+};
+
+syslogConfig.colors = {
+ debug: 'blue',
+ info: 'green',
+ notice: 'yellow',
+ warning: 'red',
+ error: 'red',
+ crit: 'red',
+ alert: 'yellow',
+ emerg: 'red'
+};
View
101 node_modules/winston/lib/winston/container.js
@@ -0,0 +1,101 @@
+/*
+ * container.js: Inversion of control container for winston logger instances
+ *
+ * (C) 2010 Charlie Robbins
+ * MIT LICENCE
+ *
+ */
+
+var common = require('./common'),
+ winston = require('../winston');
+
+//
+// ### function Container (options)
+// #### @options {Object} Default pass-thru options for Loggers
+// Constructor function for the Container object responsible for managing
+// a set of `winston.Logger` instances based on string ids.
+//
+var Container = exports.Container = function (options) {
+ this.loggers = {};
+ this.options = options || {};
+ this.default = {
+ transports: [
+ new winston.transports.Console({
+ level: 'silly',
+ colorize: false
+ })
+ ]
+ }
+};
+
+//
+// ### function get / add (id, options)
+// #### @id {string} Id of the Logger to get
+// #### @options {Object} **Optional** Options for the Logger instance
+// Retreives a `winston.Logger` instance for the specified `id`. If
+// an instance does not exist, one is created.
+//
+Container.prototype.get = Container.prototype.add = function (id, options) {
+ if (!this.loggers[id]) {
+ options = common.clone(options || this.options || this.default);
+ options.transports = options.transports || [];
+
+ if (options.transports.length === 0 && (!options || !options['console'])) {
+ options.transports.push(this.default.transports[0]);
+ }
+
+ Object.keys(options).forEach(function (key) {
+ if (key === 'transports') {
+ return;
+ }
+
+ var name = common.capitalize(key);
+
+ if (!winston.transports[name]) {
+ throw new Error('Cannot add unknown transport: ' + name);
+ }
+
+ var namedOptions = options[key];
+ namedOptions.id = id;
+ options.transports.push(new (winston.transports[name])(namedOptions));
+ });
+
+ this.loggers[id] = new winston.Logger(options);
+ }
+
+ return this.loggers[id];
+};
+
+//
+// ### function close (id)
+// #### @id {string} **Optional** Id of the Logger instance to find
+// Returns a boolean value indicating if this instance
+// has a logger with the specified `id`.
+//
+Container.prototype.has = function (id) {
+ return !!this.loggers[id];
+};
+
+//
+// ### function close (id)
+// #### @id {string} **Optional** Id of the Logger instance to close
+// Closes a `Logger` instance with the specified `id` if it exists.
+// If no `id` is supplied then all Loggers are closed.
+//
+Container.prototype.close = function (id) {
+ var self = this;
+
+ function _close (id) {
+ if (!self.loggers[id]) {
+ return;
+ }
+
+ self.loggers[id].close();
+ delete self.loggers[id];
+ }
+
+ return id ? _close(id) : Object.keys(this.loggers).forEach(function (id) {
+ _close(id);
+ });
+};
+
View
56 node_modules/winston/lib/winston/exception.js
@@ -0,0 +1,56 @@
+/*
+ * exception.js: Utility methods for gathing information about uncaughtExceptions.
+ *
+ * (C) 2010 Charlie Robbins
+ * MIT LICENCE
+ *
+ */
+
+var os = require('os'),
+ stackTrace = require('stack-trace');
+
+var exception = exports;
+
+exception.getAllInfo = function (err) {
+ return {
+ date: new Date().toString(),
+ process: exception.getProcessInfo(),
+ os: exception.getOsInfo(),
+ trace: exception.getTrace(err),
+ stack: err.stack && err.stack.split('\n')
+ };
+};
+
+exception.getProcessInfo = function () {
+ return {
+ pid: process.pid,
+ uid: process.getuid ? process.getuid() : null,
+ gid: process.getgid ? process.getgid() : null,
+ cwd: process.cwd(),
+ execPath: process.execPath,
+ version: process.version,
+ argv: process.argv,
+ memoryUsage: process.memoryUsage()
+ };
+};
+
+exception.getOsInfo = function () {
+ return {
+ loadavg: os.loadavg(),
+ uptime: os.uptime()
+ };
+};
+
+exception.getTrace = function (err) {
+ var trace = err ? stackTrace.parse(err) : stackTrace.get();
+ return trace.map(function (site) {
+ return {
+ column: site.getColumnNumber(),
+ file: site.getFileName(),
+ function: site.getFunctionName(),
+ line: site.getLineNumber(),
+ method: site.getMethodName(),
+ native: site.isNative(),
+ }
+ });
+};
View
668 node_modules/winston/lib/winston/logger.js
@@ -0,0 +1,668 @@
+/*
+ * logger.js: Core logger object used by winston.
+ *
+ * (C) 2010 Charlie Robbins
+ * MIT LICENCE
+ *
+ */
+
+var events = require('events'),
+ util = require('util'),
+ async = require('async'),
+ config = require('./config'),
+ common = require('./common'),
+ exception = require('./exception'),
+ Stream = require('stream').Stream;
+
+//
+// Time constants
+//
+var ticksPerMillisecond = 10000;
+
+//
+// ### function Logger (options)
+// #### @options {Object} Options for this instance.
+// Constructor function for the Logger object responsible
+// for persisting log messages and metadata to one or more transports.
+//
+var Logger = exports.Logger = function (options) {
+ events.EventEmitter.call(this);
+ options = options || {};
+
+ var self = this,
+ handleExceptions = false;
+
+ //
+ // Set Levels and default logging level
+ //
+ this.padLevels = options.padLevels || false;
+ this.setLevels(options.levels);
+ if (options.colors) {
+ config.addColors(options.colors);
+ }
+
+ //
+ // Hoist other options onto this instance.
+ //
+ this.level = options.level || 'info';
+ this.emitErrs = options.emitErrs || false;
+ this.stripColors = options.stripColors || false;
+ this.exitOnError = typeof options.exitOnError !== 'undefined'
+ ? options.exitOnError
+ : true;
+
+ //
+ // Setup other intelligent default settings.
+ //
+ this.transports = {};
+ this.rewriters = [];
+ this.exceptionHandlers = {};
+ this.profilers = {};
+ this._names = [];
+ this._hnames = [];
+
+ if (options.transports) {
+ options.transports.forEach(function (transport) {
+ self.add(transport, null, true);
+
+ if (transport.handleExceptions) {
+ handleExceptions = true;
+ }
+ });
+ }
+
+ if (options.rewriters) {
+ options.rewriters.forEach(function (rewriter) {
+ self.addRewriter(rewriter);
+ });
+ }
+
+ if (options.exceptionHandlers) {
+ handleExceptions = true;
+ options.exceptionHandlers.forEach(function (handler) {
+ self._hnames.push(handler.name);
+ self.exceptionHandlers[handler.name] = handler;
+ });
+ }
+
+ if (options.handleExceptions || handleExceptions) {
+ this.handleExceptions();
+ }
+};
+
+//
+// Inherit from `events.EventEmitter`.
+//
+util.inherits(Logger, events.EventEmitter);
+
+//