winston
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -0,1 +1,11 @@ | ||
## v2.3.0 / 2016-11-02 | ||
### ZOMG WHY WOULD YOU ASK EDITION | ||
- Full `CHANGELOG.md` entry forthcoming. See [the `git` diff for `2.3.0`](https://github.com/winstonjs/winston/compare/2.2.0...2.3.0) for now. | ||
## v2.2.0 / 2016-02-25 | ||
### LEAVING CALIFORNIA EDITION | ||
- Full `CHANGELOG.md` entry forthcoming. See [the `git` diff for `2.2.0`](https://github.com/winstonjs/winston/compare/2.1.1...2.2.0) for now. | ||
## v2.1.1 / 2015-11-18 | ||
@@ -2,0 +12,0 @@ ### COLOR ME IMPRESSED EDITION |
@@ -12,5 +12,5 @@ /* | ||
// | ||
// Expose version using `pkginfo` | ||
// use require method for webpack bundle | ||
// | ||
require('pkginfo')(module, 'version'); | ||
winston.version = require('../package.json').version | ||
@@ -67,3 +67,3 @@ // | ||
// | ||
// Pass through the target methods onto `winston. | ||
// Pass through the target methods onto `winston`. | ||
// | ||
@@ -83,4 +83,3 @@ var methods = [ | ||
'unhandleExceptions', | ||
'addRewriter', | ||
'addFilter' | ||
'configure' | ||
]; | ||
@@ -87,0 +86,0 @@ common.setLevels(winston, null, defaultLogger.levels); |
@@ -76,2 +76,3 @@ /* | ||
options.id = id; | ||
this.loggers[id] = new winston.Logger(options); | ||
@@ -78,0 +79,0 @@ |
@@ -17,3 +17,3 @@ /* | ||
const formatRegExp = /%[sdj%]/g; | ||
var formatRegExp = /%[sdj%]/g; | ||
@@ -76,2 +76,3 @@ // | ||
// | ||
this.id = options.id || null; | ||
this.level = options.level || 'info'; | ||
@@ -170,10 +171,15 @@ this.emitErrs = options.emitErrs || false; | ||
// | ||
var metaType = Object.prototype.toString.call(args[args.length - 1]), | ||
fmtMatch = args[0] && args[0].match && args[0].match(formatRegExp), | ||
isFormat = fmtMatch && fmtMatch.length, | ||
validMeta = !isFormat | ||
? metaType === '[object Object]' || metaType === '[object Error]' || metaType === '[object Array]' | ||
: metaType === '[object Object]', | ||
meta = validMeta ? args.pop() : {}, | ||
msg = util.format.apply(null, args); | ||
var msg, meta = {}, validMeta = false; | ||
var hasFormat = args && args[0] && args[0].match && args[0].match(formatRegExp) !== null; | ||
var tokens = (hasFormat) ? args[0].match(formatRegExp) : []; | ||
var ptokens = tokens.filter(function(t) { return t === '%%' }); | ||
if (((args.length - 1) - (tokens.length - ptokens.length)) > 0 || args.length === 1) { | ||
// last arg is meta | ||
meta = args[args.length - 1] || args; | ||
var metaType = Object.prototype.toString.call(meta); | ||
validMeta = metaType === '[object Object]' || | ||
metaType === '[object Error]' || metaType === '[object Array]'; | ||
meta = validMeta ? args.pop() : {}; | ||
} | ||
msg = util.format.apply(null, args); | ||
@@ -180,0 +186,0 @@ // |
@@ -9,22 +9,29 @@ /* | ||
var path = require('path'); | ||
// | ||
// Setup all transports as lazy-loaded getters. | ||
// | ||
Object.defineProperties( | ||
exports, | ||
['Console', 'File', 'Http', 'Memory'] | ||
.reduce(function (acc, name) { | ||
acc[name] = { | ||
configurable: true, | ||
enumerable: true, | ||
get: function () { | ||
var fullpath = path.join(__dirname, 'transports', name.toLowerCase()); | ||
return require(fullpath)[name]; | ||
} | ||
}; | ||
return acc; | ||
}, {}) | ||
); | ||
Object.defineProperty(exports, 'Console', { | ||
configurable: true, | ||
enumerable: true, | ||
get: function () { | ||
return require('./transports/console').Console; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'File', { | ||
configurable: true, | ||
enumerable: true, | ||
get: function () { | ||
return require('./transports/file').File; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'Http', { | ||
configurable: true, | ||
enumerable: true, | ||
get: function () { | ||
return require('./transports/http').Http; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'Memory', { | ||
configurable: true, | ||
enumerable: true, | ||
get: function () { | ||
return require('./transports/memory').Memory; | ||
} | ||
}); |
@@ -24,2 +24,3 @@ var util = require('util'), | ||
this.path = options.path || ''; | ||
this.agent = options.agent; | ||
@@ -61,2 +62,3 @@ if (!this.port) { | ||
headers: { 'Content-Type': 'application/json' }, | ||
agent: this.agent, | ||
auth: (auth) ? auth.username + ':' + auth.password : '' | ||
@@ -63,0 +65,0 @@ }); |
{ | ||
"name": "winston", | ||
"description": "A multi-transport async logging library for Node.js", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"author": "Charlie Robbins <charlie.robbins@gmail.com>", | ||
@@ -26,3 +26,2 @@ "maintainers": [ | ||
"isstream": "0.1.x", | ||
"pkginfo": "0.3.x", | ||
"stack-trace": "0.0.x" | ||
@@ -29,0 +28,0 @@ }, |
@@ -75,2 +75,12 @@ # winston | ||
Or do it with one call to configure(): | ||
``` js | ||
winston.configure({ | ||
transports: [ | ||
new (winston.transports.File)({ filename: 'somefile.log' }) | ||
] | ||
}); | ||
``` | ||
For more documentation about working with each individual transport supported by Winston see the [Winston Transports](docs/transports.md) document. | ||
@@ -683,3 +693,3 @@ | ||
var logger = new winston.Logger({ | ||
rewriters: [function (level, msg, meta) { /* etc etc */ }] | ||
rewriters: [function (level, msg, meta) { /* etc etc */ }], | ||
filters: [function (level, msg, meta) { /* etc etc */ }] | ||
@@ -780,3 +790,3 @@ }) | ||
// Return string will be passed to logger. | ||
return options.timestamp() +' '+ options.level.toUpperCase() +' '+ (undefined !== options.message ? options.message : '') + | ||
return options.timestamp() +' '+ options.level.toUpperCase() +' '+ (options.message ? options.message : '') + | ||
(options.meta && Object.keys(options.meta).length ? '\n\t'+ JSON.stringify(options.meta) : '' ); | ||
@@ -783,0 +793,0 @@ } |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
170453
6
3904
849
11
- Removedpkginfo@0.3.x
- Removedpkginfo@0.3.1(transitive)