Comparing version 1.0.0 to 1.0.1
@@ -77,3 +77,3 @@ # Winston Transports | ||
* __json:__ If true, messages will be logged as JSON (default true). | ||
* __eol:__ string indicating the end-of-live characters to use (default to `\n`). | ||
* __eol:__ string indicating the end-of-line characters to use (default to `\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. | ||
@@ -402,2 +402,18 @@ * __depth__ Numeric indicating how many times to recurse while formatting the object with `util.inspect` (only used with `prettyPrint: true`) (default null, unlimited) | ||
### Winlog2 Transport | ||
[winston-winlog2][19] is a Windows Event log transport: | ||
``` js | ||
var winston = require('winston'); | ||
winston.add(require('winston-winlog2'), options); | ||
``` | ||
The winlog2 transport uses the following options: | ||
* __name__: Transport name | ||
* __eventLog__: Log type (default: 'APPLICATION') | ||
* __source__: Name of application which will appear in event log (default: 'node') | ||
## Find more Transports | ||
@@ -431,2 +447,3 @@ | ||
winston-winlog Windows Event Log logger for Winston =jfromaniello | ||
winston-winlog2 Windows Event Log logger for Winston (no node-gyp) =peteward44 | ||
winston-zmq A 0MQ transport for winston =dhendo | ||
@@ -433,0 +450,0 @@ winston-growl A growl transport for winston =pgherveou |
@@ -464,3 +464,5 @@ /* | ||
instance._onError = this._onError.bind(this, instance) | ||
instance.on('error', instance._onError); | ||
if (!created) { | ||
instance.on('error', instance._onError); | ||
} | ||
@@ -533,3 +535,5 @@ // | ||
instance.removeListener('error', instance._onError); | ||
if (instance._onError) { | ||
instance.removeListener('error', instance._onError); | ||
} | ||
return this; | ||
@@ -536,0 +540,0 @@ }; |
@@ -14,2 +14,3 @@ /* | ||
async = require('async'), | ||
zlib = require('zlib'), | ||
common = require('../common'), | ||
@@ -28,2 +29,3 @@ Transport = require('./transport').Transport, | ||
var File = exports.File = function (options) { | ||
var self = this; | ||
Transport.call(this, options); | ||
@@ -80,2 +82,3 @@ | ||
this.rotationFormat = options.rotationFormat || false; | ||
this.zippedArchive = options.zippedArchive || false; | ||
this.maxFiles = options.maxFiles || null; | ||
@@ -106,2 +109,3 @@ this.prettyPrint = options.prettyPrint || false; | ||
this._failures = 0; | ||
this._archive = null; | ||
}; | ||
@@ -378,2 +382,4 @@ | ||
this._archive = this.zippedArchive ? this._stream.path : null; | ||
// | ||
@@ -504,3 +510,2 @@ // Otherwise we have a valid (and ready) stream. | ||
}); | ||
// | ||
@@ -513,4 +518,19 @@ // Remark: It is possible that in the time it has taken to find the | ||
self.flush(); | ||
compressFile(); | ||
} | ||
function compressFile() { | ||
if (self._archive) { | ||
var gzip = zlib.createGzip(); | ||
var inp = fs.createReadStream(String(self._archive)); | ||
var out = fs.createWriteStream(self._archive + '.gz'); | ||
inp.pipe(gzip).pipe(out); | ||
fs.unlink(String(self._archive)); | ||
self._archive = ''; | ||
} | ||
} | ||
fs.stat(fullname, function (err, stats) { | ||
@@ -521,3 +541,2 @@ if (err) { | ||
} | ||
return createAndFlush(0); | ||
@@ -541,2 +560,3 @@ } | ||
File.prototype._incFile = function (callback) { | ||
@@ -582,11 +602,20 @@ var ext = path.extname(this._basename), | ||
File.prototype._checkMaxFilesIncrementing = function (ext, basename, callback) { | ||
var oldest, target; | ||
var oldest, target, | ||
self = this; | ||
if (self.zippedArchive) { | ||
self._archive = path.join(self.dirname, basename + | ||
((self._created === 1) ? '' : self._created-1) + | ||
ext); | ||
} | ||
// Check for maxFiles option and delete file | ||
if (!this.maxFiles || this._created < this.maxFiles) { | ||
if (!self.maxFiles || self._created < self.maxFiles) { | ||
return callback(); | ||
} | ||
oldest = this._created - this.maxFiles; | ||
target = path.join(this.dirname, basename + (oldest !== 0 ? oldest : '') + ext); | ||
oldest = self._created - self.maxFiles; | ||
target = path.join(self.dirname, basename + (oldest !== 0 ? oldest : '') + ext + | ||
(self.zippedArchive ? '.gz' : '')); | ||
fs.unlink(target, callback); | ||
@@ -613,3 +642,4 @@ }; | ||
return function (cb) { | ||
var tmppath = path.join(self.dirname, basename + (i - 1) + ext); | ||
var tmppath = path.join(self.dirname, basename + (i - 1) + ext + | ||
(self.zippedArchive ? '.gz' : '')); | ||
fs.exists(tmppath, function (exists) { | ||
@@ -620,3 +650,4 @@ if (!exists) { | ||
fs.rename(tmppath, path.join(self.dirname, basename + i + ext), cb); | ||
fs.rename(tmppath, path.join(self.dirname, basename + i + ext + | ||
(self.zippedArchive ? '.gz' : '')), cb); | ||
}); | ||
@@ -627,2 +658,5 @@ }; | ||
if (self.zippedArchive) { | ||
self._archive = path.join(self.dirname, basename + 1 + ext); | ||
} | ||
async.series(tasks, function (err) { | ||
@@ -629,0 +663,0 @@ fs.rename( |
{ | ||
"name": "winston", | ||
"description": "A multi-transport async logging library for Node.js", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": "Nodejitsu Inc. <info@nodejitsu.com>", | ||
@@ -39,8 +39,3 @@ "maintainers": [ | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://raw.github.com/winstonjs/winston/master/LICENSE" | ||
} | ||
] | ||
"license": "MIT" | ||
} |
@@ -40,3 +40,3 @@ # winston [![Build Status](https://secure.travis-ci.org/winstonjs/winston.svg?branch=master)](http://travis-ci.org/winstonjs/winston) | ||
* [Extending another object with Logging](#extending-another-object-with-logging) | ||
* [Filters](#filters) | ||
* [Filters and Rewriters](#filters-and-rewriters) | ||
* [Working with transports](#working-with-transports) | ||
@@ -635,10 +635,12 @@ * [Adding Custom Transports](#adding-custom-transports) | ||
### Filters | ||
Filters allow modifying the contents of log messages, e.g. to mask data that | ||
should not appear in logs. | ||
### Filters and Rewriters | ||
Filters allow modifying the contents of **log messages**, and Rewriters allow modifying the contents of **log meta** e.g. to mask data that should not appear in logs. | ||
``` js | ||
logger.addFilter(function(msg) { | ||
return maskCardNumbers(msg); | ||
logger.addFilter(function(msg, meta, level) { | ||
return meta.production | ||
? maskCardNumbers(msg) | ||
: msg; | ||
}); | ||
logger.info('transaction with card number 123456789012345 successful.'); | ||
@@ -653,5 +655,24 @@ ``` | ||
See [log-filter-test.js](./test/log-filter-test.js), where card number masking | ||
is implemented as an example. | ||
Where as for rewriters, if you wanted to sanitize the `creditCard` field of your `meta` you could: | ||
``` js | ||
logger.addRewriter(function(level, msg, meta) { | ||
if (meta.creditCard) { | ||
meta.creditCard = maskCardNumbers(meta.creditCard) | ||
} | ||
return meta; | ||
}); | ||
logger.info('transaction ok', { creditCard: 123456789012345 }); | ||
``` | ||
which may result in this output: | ||
``` | ||
info: transaction ok creditCard=123456****2345 | ||
``` | ||
See [log-filter-test.js](./test/log-filter-test.js), where card number masking is implemented as an example along with [log-rewriter-test.js](./test/log-rewriter-test.js) | ||
## Working with Transports | ||
@@ -703,2 +724,3 @@ There 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__ | ||
* __maxRetries:__ The number of stream creation retry attempts before entering a failed state. In a failed state the transport stays active but performs a NOOP on it's log function. (default 2) | ||
* __zippedArchive:__ If true, all log files but the current one will be zipped. | ||
@@ -829,3 +851,3 @@ *Metadata:* Logged via util.inspect(meta); | ||
The [winston-sns][18] transport uses amazon SNS to send emails, texts, or a bunch of other notifications. Since this transport uses the Amazon AWS SDK for JavaScript, you can take advantage of the various methods of authentication found in Amazon's [Configuring the SDK in Node.js](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html) document. | ||
The [winston-sns][25] transport uses amazon SNS to send emails, texts, or a bunch of other notifications. Since this transport uses the Amazon AWS SDK for JavaScript, you can take advantage of the various methods of authentication found in Amazon's [Configuring the SDK in Node.js](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html) document. | ||
@@ -1025,1 +1047,2 @@ ``` js | ||
[24]: https://github.com/jorgebay/winston-cassandra | ||
[25]: https://github.com/jesseditson/winston-sns |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
266324
72
5910
1043
22
15