Comparing version 0.8.0 to 0.8.1
@@ -0,5 +1,29 @@ | ||
## 0.8.1 / 2014-10-06 | ||
0.6.2 / 2012-07-08 | ||
================== | ||
* [Add label option for DailyRotateFile transport (`francoisTemasys`)](https://github.com/flatiron/winston/pull/459) | ||
* [fix Logger#transports length check upon Logger#log (`adriano-di-giovanni`, `indexzero`)](https://github.com/flatiron/winston/pull/404) | ||
* [err can be a string. (`gdw2`, `indexzero`)](https://github.com/flatiron/winston/pull/396) | ||
* [Added color for pre-defined cli set. (`danilo1105`, `indexzero`)](https://github.com/flatiron/winston/pull/365) | ||
* [Fix dates on transport test (`revington`)](https://github.com/flatiron/winston/pull/346) | ||
* [Included the label from options to the output in JSON mode. (`arxony`)](https://github.com/flatiron/winston/pull/326) | ||
* [Allow using logstash option with the File transport (`gmajoulet`)](https://github.com/flatiron/winston/pull/299) | ||
* [Be more defensive when working with `query` methods from Transports. Fixes #356. (indexzero)](https://github.com/flatiron/winston/commit/b80638974057f74b521dbe6f43fef2105110afa2) | ||
* [Catch exceptions for file transport unlinkSync (`calvinfo`)](https://github.com/flatiron/winston/pull/266) | ||
* [Adding the 'addRewriter' to winston (`machadogj`)](https://github.com/flatiron/winston/pull/258) | ||
* [Updates to transport documentation (`pose`)](https://github.com/flatiron/winston/pull/262) | ||
* [fix typo in "Extending another object with Logging" section.](https://github.com/flatiron/winston/pull/281) | ||
* [Updated README.md - Replaced properties with those listed in winston-mongodb module](https://github.com/flatiron/winston/pull/264) | ||
## 0.8.0 / 2014-09-15 | ||
* [Fixes for HTTP Transport](https://github.com/flatiron/winston/commit/a876a012641f8eba1a976eada15b6687d4a03f82) | ||
* Removing [jsonquest](https://github.com/flatiron/winston/commit/4f088382aeda28012b7a0498829ceb243ed74ac1) and [request](https://github.com/flatiron/winston/commit/a5676313b4e9744802cc3b8e1468e4af48830876) dependencies. | ||
* Configuration is now [shalow cloned](https://github.com/flatiron/winston/commit/08fccc81d18536d33050496102d98bde648853f2). | ||
* [Added logstash support](https://github.com/flatiron/winston/pull/445/files) | ||
* Fix for ["flush" event should always fire after "flush" call bug](https://github.com/flatiron/winston/pull/446/files) | ||
* Added tests for file: [open and stress](https://github.com/flatiron/winston/commit/47d885797a2dd0d3cd879305ca813a0bd951c378). | ||
* [Test fixes](https://github.com/flatiron/winston/commit/9e39150e0018f43d198ca4c160acef2af9860bf4) | ||
* [Fix ")" on string interpolation](https://github.com/flatiron/winston/pull/394/files) | ||
## 0.6.2 / 2012-07-08 | ||
* Added prettyPrint option for console logging | ||
@@ -6,0 +30,0 @@ * Multi-line values for conditional returns are not allowed |
@@ -10,2 +10,3 @@ # Winston Transports | ||
* [File](#file-transport) | ||
* [DailyRotateFile](#dailyrotatefile-transport) | ||
* [Http](#http-transport) | ||
@@ -33,2 +34,3 @@ * [Webhook](#webhook-transport) | ||
* [File](#file-transport) | ||
* [DailyRotateFile](#dailyrotatefile-transport) | ||
* [Http](#http-transport) | ||
@@ -43,3 +45,3 @@ * [Webhook](#webhook-transport) | ||
The Console transport takes two simple options: | ||
The Console transport takes four simple options: | ||
@@ -73,2 +75,27 @@ * __level:__ Level of messages that this transport should log (default 'debug'). | ||
### DailyRotateFile Transport | ||
``` js | ||
winston.add(winston.transports.DailyRotateFile, options) | ||
``` | ||
The DailyRotateFile transport can rotate files by minute, hour, day, month or year. Its options are identical to the File transport with the lone addition of the 'datePattern' option: | ||
* __datePattern:__ A string representing the pattern to be used when appending the date to the filename (default '.yyyy-MM-dd'). The meta characters used in this string will dictate the frequency of the file rotation. For example if your datePattern is simply '.HH' you will end up with 24 log files that are picked up and appended to every day. | ||
Valid meta characters in the datePattern are: | ||
* __yy:__ Last two digits of the year. | ||
* __yyyy:__ Full year. | ||
* __M:__ The month. | ||
* __MM:__ The zero padded month. | ||
* __d:__ The day. | ||
* __dd:__ The zero padded day. | ||
* __H:__ The hour. | ||
* __HH:__ The zero padded hour. | ||
* __m:__ The minute. | ||
* __mm:__ The zero padded minute. | ||
*Metadata:* Logged via util.inspect(meta); | ||
### Http Transport | ||
@@ -75,0 +102,0 @@ |
@@ -80,3 +80,4 @@ /* | ||
'handleExceptions', | ||
'unhandleExceptions' | ||
'unhandleExceptions', | ||
'addRewriter' | ||
]; | ||
@@ -83,0 +84,0 @@ common.setLevels(winston, null, defaultLogger.levels); |
@@ -136,3 +136,3 @@ /* | ||
// | ||
if (options.json) { | ||
if (options.json || true === options.logstash) { | ||
if (typeof meta !== 'object' && meta != null) { | ||
@@ -145,3 +145,5 @@ meta = { meta: meta }; | ||
output.message = options.message; | ||
if (options.label) { | ||
output.label = options.label; | ||
} | ||
if (timestamp) { | ||
@@ -148,0 +150,0 @@ output.timestamp = timestamp; |
@@ -46,2 +46,3 @@ /* | ||
// | ||
config.addColors(config.cli.colors); | ||
config.addColors(config.npm.colors); | ||
@@ -48,0 +49,0 @@ config.addColors(config.syslog.colors); |
@@ -18,7 +18,2 @@ /* | ||
// | ||
// Time constants | ||
// | ||
var ticksPerMillisecond = 10000; | ||
// | ||
// ### function Logger (options) | ||
@@ -150,3 +145,4 @@ // #### @options {Object} Options for this instance. | ||
if (this.transports.length === 0) { | ||
if (Object.keys(this.transports).length === 0) { | ||
return onError(new Error('Cannot log with no transports.')); | ||
@@ -257,7 +253,16 @@ } | ||
queryTransport(transport, function (err, result) { | ||
result = err || result; | ||
if (result) { | ||
results[transport.name] = result; | ||
// | ||
// queryTransport could potentially invoke the callback | ||
// multiple times since Transport code can be unpredictable. | ||
// | ||
if (next) { | ||
result = err || result; | ||
if (result) { | ||
results[transport.name] = result; | ||
} | ||
next(); | ||
} | ||
next(); | ||
next = null; | ||
}); | ||
@@ -613,3 +618,3 @@ } | ||
function logAndWait(transport, next) { | ||
transport.logException('uncaughtException: ' + err.message, info, next, err); | ||
transport.logException('uncaughtException: ' + (err.message || err), info, next, err); | ||
} | ||
@@ -616,0 +621,0 @@ |
@@ -72,2 +72,3 @@ /* | ||
this.maxFiles = options.maxFiles || null; | ||
this.label = options.label || null; | ||
this.prettyPrint = options.prettyPrint || false; | ||
@@ -158,2 +159,3 @@ this.timestamp = options.timestamp != null ? options.timestamp : true; | ||
timestamp: this.timestamp, | ||
label: this.label, | ||
stringify: this.stringify | ||
@@ -160,0 +162,0 @@ }) + '\n'; |
@@ -69,2 +69,3 @@ /* | ||
this.json = options.json !== false; | ||
this.logstash = options.logstash || false; | ||
this.colorize = options.colorize || false; | ||
@@ -127,2 +128,3 @@ this.maxsize = options.maxsize || null; | ||
json: this.json, | ||
logstash: this.logstash, | ||
colorize: this.colorize, | ||
@@ -507,8 +509,12 @@ prettyPrint: this.prettyPrint, | ||
remaining = this._created - (this.maxFiles - 1); | ||
if (remaining === 0) { | ||
fs.unlinkSync(path.join(this.dirname, basename + ext)); | ||
try { | ||
if (remaining === 0) { | ||
fs.unlinkSync(path.join(this.dirname, basename + ext)); | ||
} | ||
else { | ||
fs.unlinkSync(path.join(this.dirname, basename + remaining + ext)); | ||
} | ||
} catch (e) { | ||
// If the file was already removed | ||
} | ||
else { | ||
fs.unlinkSync(path.join(this.dirname, basename + remaining + ext)); | ||
} | ||
} | ||
@@ -515,0 +521,0 @@ |
{ | ||
"name": "winston", | ||
"description": "A multi-transport async logging library for Node.js", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"author": "Nodejitsu Inc. <info@nodejitsu.com>", | ||
@@ -6,0 +6,0 @@ "maintainers": [ |
@@ -27,3 +27,3 @@ # winston [![Build Status](https://secure.travis-ci.org/flatiron/winston.png?branch=master)](http://travis-ci.org/flatiron/winston) | ||
* [Streaming Logs](#streaming-logs) | ||
* [Querying Logs](#querying-logs) | ||
* [Querying Logs](#querying-logs) | ||
* [Exceptions](#exceptions) | ||
@@ -130,3 +130,3 @@ * [Handling Uncaught Exceptions with winston](#handling-uncaught-exceptions-with-winston) | ||
### String interpolation | ||
The `log` method provides the same string interpolation methods like [`util.format`][10]. | ||
The `log` method provides the same string interpolation methods like [`util.format`][10]. | ||
@@ -189,3 +189,3 @@ This allows for the following log messages. | ||
} | ||
console.log(results); | ||
@@ -252,3 +252,3 @@ }); | ||
new winston.transports.File({ filename: 'path/to/all-logs.log' }) | ||
] | ||
], | ||
exceptionHandlers: [ | ||
@@ -334,3 +334,3 @@ new winston.transports.File({ filename: 'path/to/exceptions.log' }) | ||
] | ||
}); | ||
}); | ||
logger.debug("Will not be logged in either transport!"); | ||
@@ -633,3 +633,3 @@ logger.transports.console.level = 'debug'; | ||
* __json:__ If true, messages will be logged as JSON (default true). | ||
* __logstash:__ If true, messages will be logged using the logstash JSON format. | ||
* __logstash:__ If true, messages will be logged as JSON and formatted for logstash (default false). | ||
@@ -646,3 +646,3 @@ *Metadata:* Logged via util.inspect(meta); | ||
* __level:__ Level of messages that this transport should log. | ||
* __level:__ Level of messages that this transport should log. | ||
* __subdomain:__ The subdomain of your Loggly account. *[required]* | ||
@@ -672,3 +672,3 @@ * __auth__: The authentication information for your Loggly account. *[required with inputName]* | ||
var singleBucketTransport = new (Riak)({ bucket: 'some-logs-go-here' }); | ||
// Generate a dynamic bucket based on the date and level | ||
@@ -693,14 +693,4 @@ var dynamicBucketTransport = new (Riak)({ | ||
The MongoDB transport takes the following options. 'db' is required: | ||
For more information about its arguments, check [winston-mongodb's README][16]. | ||
* __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 | ||
@@ -745,3 +735,3 @@ | ||
* __tls:__ Boolean (if true, use starttls) | ||
* __level:__ Level of messages that this transport should log. | ||
* __level:__ Level of messages that this transport should log. | ||
* __silent:__ Boolean flag indicating whether to suppress output. | ||
@@ -893,3 +883,3 @@ | ||
## Run Tests | ||
All of the winston tests are written in [vows][9], and designed to be run with npm. | ||
All of the winston tests are written in [vows][9], and designed to be run with npm. | ||
@@ -896,0 +886,0 @@ ``` bash |
@@ -16,2 +16,14 @@ /* | ||
vows.describe('winston/logger/cli').addBatch({ | ||
"When an instance of winston.transports.Console()": { | ||
"has colorize true": { | ||
topic: function () { | ||
var transport = new winston.transports.Console({ colorize: true }); | ||
transport.log('prompt', 'This had better work.', { test: true }, this.callback); | ||
}, | ||
"should function without error": function (err, ok) { | ||
assert.isNull(err); | ||
assert.isTrue(ok); | ||
} | ||
} | ||
}, | ||
"When an instance of winston.Logger": { | ||
@@ -34,3 +46,3 @@ topic: function () { | ||
}); | ||
Object.keys(winston.config.cli.colors).forEach(function (color) { | ||
@@ -37,0 +49,0 @@ assert.isString(winston.config.allColors[color]); |
@@ -15,4 +15,4 @@ /* | ||
vows = require('vows'), | ||
winston = require('../lib/winston'); | ||
winston = require('../lib/winston'); | ||
var helpers = exports; | ||
@@ -27,3 +27,3 @@ | ||
} | ||
return size; | ||
@@ -128,2 +128,5 @@ }; | ||
helpers.assertTrace(data.trace); | ||
if (options.message) { | ||
assert.equal('uncaughtException: ' + options.message, data.message); | ||
} | ||
} | ||
@@ -143,3 +146,3 @@ } | ||
var tests = {}; | ||
Object.keys(levels).forEach(function (level) { | ||
@@ -151,7 +154,7 @@ var test = { | ||
}; | ||
test[assertMsg] = assertFn; | ||
tests['with the ' + level + ' level'] = test; | ||
}); | ||
var metadatatest = { | ||
@@ -162,3 +165,3 @@ topic: function () { | ||
}; | ||
metadatatest[assertMsg] = assertFn; | ||
@@ -176,3 +179,3 @@ tests['when passed metadata'] = metadatatest; | ||
var circmetadata = { }; | ||
var circmetadata = { }; | ||
circmetadata['metadata'] = circmetadata; | ||
@@ -179,0 +182,0 @@ |
@@ -29,2 +29,7 @@ /* | ||
}), | ||
"when strings are thrown as errors": helpers.assertHandleExceptions({ | ||
script: path.join(__dirname, 'fixtures', 'scripts', 'log-string-exception.js'), | ||
logfile: path.join(__dirname, 'fixtures', 'logs', 'string-exception.log'), | ||
message: 'OMG NEVER DO THIS STRING EXCEPTIONS ARE AWFUL' | ||
}), | ||
"when a custom exitOnError function is set": { | ||
@@ -34,3 +39,3 @@ topic: function () { | ||
scriptDir = path.join(__dirname, 'fixtures', 'scripts'); | ||
that.child = spawn('node', [path.join(scriptDir, 'exit-on-error.js')]); | ||
@@ -50,3 +55,3 @@ setTimeout(this.callback.bind(this), 1500); | ||
exception = path.join(__dirname, 'fixtures', 'logs', 'unhandle-exception.log'); | ||
helpers.tryUnlink(exception); | ||
@@ -53,0 +58,0 @@ child.on('exit', function () { |
@@ -19,9 +19,25 @@ /* | ||
"An instance of winston.Logger": { | ||
topic: new (winston.Logger)({ transports: [new (winston.transports.Console)({ level: 'info' })] }), | ||
"should have the correct methods / properties defined": function (logger) { | ||
helpers.assertLogger(logger); | ||
"with transports": { | ||
topic: new (winston.Logger)({ transports: [new (winston.transports.Console)({ level: 'info' })] }), | ||
"should have the correct methods / properties defined": function (logger) { | ||
helpers.assertLogger(logger); | ||
}, | ||
"the add() with an unsupported transport": { | ||
"should throw an error": function () { | ||
assert.throws(function () { logger.add('unsupported') }, Error); | ||
} | ||
} | ||
}, | ||
"the add() with an unsupported transport": { | ||
"should throw an error": function () { | ||
assert.throws(function () { logger.add('unsupported') }, Error); | ||
"with no transports": { | ||
topic: new winston.Logger(), | ||
"the log method": { | ||
topic: function (logger) { | ||
var that = this; | ||
logger.log('error', 'This should be an error', function (err) { | ||
that.callback(null, err); | ||
}); | ||
}, | ||
"should respond with the appropriate error": function (err) { | ||
assert.instanceOf(err, Error); | ||
} | ||
} | ||
@@ -28,0 +44,0 @@ } |
@@ -174,4 +174,4 @@ var assert = require('assert'), | ||
var cb = this.callback; | ||
var start = new Date - 100 * 1000; | ||
var end = new Date + 100 * 1000; | ||
var start = Date.now() - (100 * 1000); | ||
var end = Date.now() + (100 * 1000); | ||
logger.query({ from: start, until: end }, cb); | ||
@@ -194,3 +194,3 @@ }, | ||
logger.log('info', 'bad from and until', {}, function () { | ||
var now = new Date + 1000000; | ||
var now = Date.now() + 1000000; | ||
logger.query({ from: now, until: now }, cb); | ||
@@ -197,0 +197,0 @@ }); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
213383
59
4934
12
902