diff --git a/README.md b/README.md index eead2dec3..5a2bf5459 100644 --- a/README.md +++ b/README.md @@ -606,6 +606,8 @@ The Console transport takes a few simple options: * __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. +* __prettyPrint:__ Boolean flag indicating if we should `util.inspect` the meta (default false). +* __depth__ Numeric indicating how many times to recurse while formatting the object with `util.inspect` (only used with `prettyPrint: true`) (default null, unlimited) *Metadata:* Logged via util.inspect(meta); @@ -626,6 +628,7 @@ The File transport should really be the 'Stream' transport since it will accept * __stream:__ The WriteableStream to write output to. * __json:__ If true, messages will be logged as JSON (default true). * __prettyPrint:__ If true, additional JSON metadata objects that are added to logging string messages will be displayed as a JSON string representation. +* __depth__ Numeric indicating how many times to recurse while formatting the object with `util.inspect` (only used with `prettyPrint: true`) (default null, unlimited) * __logstash:__ If true, messages will be logged as JSON and formatted for logstash (default false). *Metadata:* Logged via util.inspect(meta); @@ -637,7 +640,7 @@ The File transport should really be the 'Stream' transport since it will accept The Daily Rotate File transport lets you rotate log files based on time. -In addition to the options accepted by the File transport, the Daily Rotate File Transport also accepts the following option. +In addition to the options accepted by the File transport, the Daily Rotate File Transport also accepts the following option. * __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. diff --git a/docs/transports.md b/docs/transports.md index 4fa0fc995..a76b33d69 100644 --- a/docs/transports.md +++ b/docs/transports.md @@ -17,7 +17,7 @@ There are several [core transports](#winston-core) included in `winston`, which * [MongoDB](#mongodb-transport) * [Redis](#redis-transport) * [Riak](#riak-transport) - + * **[Additional Transports](#additional-transports)** * [SimpleDB](#simpledb-transport) * [Mail](#mail-transport) @@ -26,7 +26,7 @@ There are several [core transports](#winston-core) included in `winston`, which ## 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. +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) @@ -48,6 +48,8 @@ The Console transport takes four simple options: * __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. * __json:__ Boolean flag indicating whether or not the output should be JSON. If true, will log out multi-line JSON objects. (default false) * __stringify:__ Boolean flag indiciating if the output should be passed through JSON.stringify, resulting in single-line output. Most useful when used in conjunction with the json flag. (default false) +* __prettyPrint:__ Boolean flag indicating if we should `util.inspect` the meta (default false). +* __depth__ Numeric indicating how many times to recurse while formatting the object with `util.inspect` (only used with `prettyPrint: true`) (default null, unlimited) *Metadata:* Logged via util.inspect(meta); @@ -69,6 +71,8 @@ The File transport should really be the 'Stream' transport since it will accept * __stream:__ The WriteableStream to write output to. * __json:__ If true, messages will be logged as JSON (default true). * __eol:__ string indicating the end-of-live characters to use (default to `\n`). +* __prettyPrint:__ Boolean flag indicating if we should `util.inspect` the meta (default false). +* __depth__ Numeric indicating how many times to recurse while formatting the object with `util.inspect` (only used with `prettyPrint: true`) (default null, unlimited) *Metadata:* Logged via util.inspect(meta); @@ -107,7 +111,7 @@ The `Http` transport is a generic way to log, query, and stream logs from an arb * __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 +* __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 @@ -133,7 +137,7 @@ The `Couchdb` will place your logs in a remote CouchDB database. It will also cr * __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 +* __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 @@ -153,7 +157,7 @@ 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. +* __channel:__ (Default **None**) Name of the Redis channel to stream logs from. *Metadata:* Logged as JSON literal in Redis @@ -321,7 +325,7 @@ The Graylog2 transport connects to a Graylog2 server over UDP using the followin - __hostname__: the name of this host (default: os.hostname()) - __facility__: the facility for these log messages (default: "Node.js") - __bufferSize__: max UDP packet size, should never exceed the MTU of your system (default: 1400) - + ### Cassandra Transport @@ -351,28 +355,28 @@ Array of strings containing the hosts, for example `['host1', 'host2']` (require ``` bash $ npm search winston (...) - winston-amon Winston transport for Amon logging =zoramite - winston-amqp An AMQP transport for winston =kr1sp1n - winston-cassandra A Cassandra transport for winston =jorgebay - 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-amon Winston transport for Amon logging =zoramite + winston-amqp An AMQP transport for winston =kr1sp1n + winston-cassandra A Cassandra transport for winston =jorgebay + 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-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 winston-growl A growl transport for winston =pgherveou diff --git a/lib/winston/common.js b/lib/winston/common.js index 121ca6ede..3472060ba 100644 --- a/lib/winston/common.js +++ b/lib/winston/common.js @@ -209,7 +209,7 @@ exports.log = function (options) { if (typeof options.prettyPrint === 'function') { output += ' ' + options.prettyPrint(meta); } else if (options.prettyPrint) { - output += ' ' + '\n' + util.inspect(meta, false, null, options.colorize); + output += ' ' + '\n' + util.inspect(meta, false, options.depth || null, options.colorize); } else { output += ' ' + exports.serialize(meta); } diff --git a/lib/winston/transports/console.js b/lib/winston/transports/console.js index da7f24523..c368dd460 100644 --- a/lib/winston/transports/console.js +++ b/lib/winston/transports/console.js @@ -29,6 +29,7 @@ var Console = exports.Console = function (options) { this.label = options.label || null; this.logstash = options.logstash || false; this.debugStdout = options.debugStdout || false; + this.depth = options.depth || null; if (this.json) { this.stringify = options.stringify || function (obj) { @@ -74,7 +75,8 @@ Console.prototype.log = function (level, msg, meta, callback) { prettyPrint: this.prettyPrint, raw: this.raw, label: this.label, - logstash: this.logstash + logstash: this.logstash, + depth: this.depth }); if (level === 'error' || (level === 'debug' && !this.debugStdout) ) { diff --git a/lib/winston/transports/daily-rotate-file.js b/lib/winston/transports/daily-rotate-file.js index f81a016f8..29ea8323d 100644 --- a/lib/winston/transports/daily-rotate-file.js +++ b/lib/winston/transports/daily-rotate-file.js @@ -73,7 +73,8 @@ var DailyRotateFile = exports.DailyRotateFile = function (options) { this.prettyPrint = options.prettyPrint || false; this.timestamp = options.timestamp != null ? options.timestamp : true; this.datePattern = options.datePattern != null ? options.datePattern : '.yyyy-MM-dd'; - + this.depth = options.depth || null; + if (this.json) { this.stringify = options.stringify; } @@ -156,7 +157,8 @@ DailyRotateFile.prototype.log = function (level, msg, meta, callback) { prettyPrint: this.prettyPrint, timestamp: this.timestamp, label: this.label, - stringify: this.stringify + stringify: this.stringify, + depth: this.depth }) + '\n'; this._size += output.length; @@ -322,11 +324,11 @@ DailyRotateFile.prototype.stream = function (options) { }; stream.destroy = common.tailFile(tail, function (err, line) { - + if(err){ return stream.emit('error',err); } - + try { stream.emit('data', line); line = JSON.parse(line); @@ -335,7 +337,7 @@ DailyRotateFile.prototype.stream = function (options) { stream.emit('error', e); } }); - + if(stream.resume){ stream.resume(); } diff --git a/lib/winston/transports/file.js b/lib/winston/transports/file.js index a1ab92af2..965ccc4ae 100644 --- a/lib/winston/transports/file.js +++ b/lib/winston/transports/file.js @@ -76,6 +76,7 @@ var File = exports.File = function (options) { this.label = options.label || null; this.timestamp = options.timestamp != null ? options.timestamp : true; this.eol = options.eol || '\n'; + this.depth = options.depth || null; if (this.json) { this.stringify = options.stringify; @@ -131,7 +132,8 @@ File.prototype.log = function (level, msg, meta, callback) { prettyPrint: this.prettyPrint, timestamp: this.timestamp, stringify: this.stringify, - label: this.label + label: this.label, + depth: this.depth }) + this.eol; this._size += output.length; diff --git a/lib/winston/transports/memory.js b/lib/winston/transports/memory.js index 4c86e1c82..2a1ea9684 100644 --- a/lib/winston/transports/memory.js +++ b/lib/winston/transports/memory.js @@ -22,6 +22,7 @@ var Memory = exports.Memory = function (options) { this.prettyPrint = options.prettyPrint || false; this.timestamp = typeof options.timestamp !== 'undefined' ? options.timestamp : false; this.label = options.label || null; + this.depth = options.depth || null; if (this.json) { this.stringify = options.stringify || function (obj) { @@ -66,7 +67,8 @@ Memory.prototype.log = function (level, msg, meta, callback) { timestamp: this.timestamp, prettyPrint: this.prettyPrint, raw: this.raw, - label: this.label + label: this.label, + depth: this.depth }); if (level === 'error' || level === 'debug') {