Comparing version 1.2.0 to 1.2.1
@@ -6,3 +6,3 @@ 'use strict'; | ||
/* | ||
* function align (opts) | ||
* function align (info) | ||
* Returns a new instance of the align Format which adds a `\t` | ||
@@ -9,0 +9,0 @@ * delimiter before the message to properly align it in the same place. |
# CHANGELOG | ||
### 1.2.1 | ||
**2017/10/01** | ||
- [#3] Strip `info.splat` in `format.simple` to avoid double inclusion. | ||
### 1.2.0 | ||
@@ -4,0 +9,0 @@ **2017/09/30** |
@@ -8,3 +8,3 @@ 'use strict'; | ||
/* | ||
* function cli (opts) | ||
* function cli (info) | ||
* Returns a new instance of the CLI format that turns a log | ||
@@ -11,0 +11,0 @@ * `info` object into the same format previously available |
'use strict'; | ||
const colors = require('colors/safe'); | ||
const format = require('./format'); | ||
@@ -18,3 +17,3 @@ // | ||
/* | ||
* function colorize (opts) | ||
* function colorize (info) | ||
* Returns a new instance of the colorize Format that applies | ||
@@ -36,3 +35,3 @@ * level colors to `info` objects. This was previously exposed | ||
/* | ||
* function setupColors(opts) | ||
* function setupColors(info) | ||
* Attaches a Colorizer instance to the format. | ||
@@ -49,3 +48,3 @@ */ | ||
/** | ||
/* | ||
* Adds the colors Object to the set of allColors | ||
@@ -67,5 +66,5 @@ * known by the Colorizer | ||
return Colorizer.allColors; | ||
} | ||
}; | ||
/** | ||
/* | ||
* Adds the colors Object to the set of allColors | ||
@@ -72,0 +71,0 @@ * known by the Colorizer |
@@ -6,3 +6,3 @@ 'use strict'; | ||
/* | ||
* function combine (opts) | ||
* function combine (info) | ||
* Returns a new instance of the combine Format which combines the specified | ||
@@ -32,3 +32,3 @@ * formats into a new format. This is similar to a pipe-chain in transform streams. | ||
return function cascaded(info, opts) { | ||
return function cascaded(info) { | ||
let obj = info; | ||
@@ -58,3 +58,3 @@ for (var i = 0; i < formats.length; i++) { | ||
'const instance = myFormat();' | ||
].join('\n')) | ||
].join('\n')); | ||
} | ||
@@ -61,0 +61,0 @@ |
'use strict'; | ||
const stream = require('stream'); | ||
const util = require('util'); | ||
/* | ||
* Displays a helpful message and the source of | ||
* the format when it is invalid. | ||
*/ | ||
class InvalidFormatError extends Error { | ||
constructor(formatFn) { | ||
super(`Format functions must be synchronous taking a two arguments: (info, opts) | ||
Found: ${formatFn.toString().split('\n')[0]}\n`); | ||
Error.captureStackTrace(this, InvalidFormatError); | ||
} | ||
} | ||
/* | ||
@@ -20,3 +30,3 @@ * function format (formatFn) | ||
*/ | ||
function Format(options) { this.options = options || {}; }; | ||
function Format(options) { this.options = options || {}; } | ||
Format.prototype.transform = formatFn; | ||
@@ -41,14 +51,1 @@ | ||
}; | ||
/* | ||
* Displays a helpful message and the source of | ||
* the format when it is invalid. | ||
*/ | ||
class InvalidFormatError extends Error { | ||
constructor(formatFn) { | ||
super(`Format functions must be synchronous taking a two arguments: (info, opts) | ||
Found: ${formatFn.toString().split('\n')[0]}\n`); | ||
Error.captureStackTrace(this, InvalidFormatError); | ||
} | ||
} |
'use strict'; | ||
/** | ||
/* | ||
* @api public | ||
@@ -11,3 +11,3 @@ * @property {function} format | ||
/** | ||
/* | ||
* @api public | ||
@@ -17,5 +17,5 @@ * @method {function} levels | ||
*/ | ||
const levels = exports.levels = require('./levels'); | ||
exports.levels = require('./levels'); | ||
/** | ||
/* | ||
* @api private | ||
@@ -22,0 +22,0 @@ * method {function} exposeFormat |
@@ -7,3 +7,3 @@ 'use strict'; | ||
/* | ||
* function json (opts) | ||
* function json (info) | ||
* Returns a new instance of the JSON format that turns a log `info` | ||
@@ -10,0 +10,0 @@ * object into pure JSON. This was previously exposed as { json: true } |
@@ -6,3 +6,3 @@ 'use strict'; | ||
/* | ||
* function label (opts) | ||
* function label (info) | ||
* Returns a new instance of the label Format which adds the specified | ||
@@ -9,0 +9,0 @@ * `opts.label` before the message. This was previously exposed as |
@@ -7,3 +7,3 @@ 'use strict'; | ||
/* | ||
* function logstash (opts) | ||
* function logstash (info) | ||
* Returns a new instance of the LogStash Format that turns a | ||
@@ -14,5 +14,5 @@ * log `info` object into pure JSON with the appropriate logstash | ||
*/ | ||
module.exports = format(function (info, opts) { | ||
module.exports = format(function (info) { | ||
const logstash = {}; | ||
if (!!info.message) { | ||
if (info.message) { | ||
logstash['@message'] = info.message; | ||
@@ -22,3 +22,3 @@ delete info.message; | ||
if (!!info.timestamp) { | ||
if (info.timestamp) { | ||
logstash['@timestamp'] = info.timestamp; | ||
@@ -25,0 +25,0 @@ delete info.timestamp; |
{ | ||
"name": "logform", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "An mutable object-based log format designed for chaining & objectMode streams.", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "populist *.js", | ||
"pretest": "populist *.js test/*.js examples/*.js", | ||
"test": "nyc mocha test/*.test.js" | ||
@@ -31,2 +33,3 @@ }, | ||
"assume": "^1.5.1", | ||
"eslint-config-populist": "^4.1.0", | ||
"mocha": "^3.5.3", | ||
@@ -33,0 +36,0 @@ "nyc": "^11.2.1" |
@@ -0,1 +1,2 @@ | ||
/* eslint no-unused-vars: 0 */ | ||
'use strict'; | ||
@@ -6,3 +7,3 @@ | ||
/* | ||
* function padLevels (opts) | ||
* function padLevels (info) | ||
* Returns a new instance of the padLevels Format which pads | ||
@@ -9,0 +10,0 @@ * levels to be the same length. This was previously exposed as |
@@ -8,3 +8,3 @@ 'use strict'; | ||
/* | ||
* function prettyPrint (opts) | ||
* function prettyPrint (info) | ||
* Returns a new instance of the prettyPrint Format that "prettyPrint" | ||
@@ -11,0 +11,0 @@ * serializes `info` objects. This was previously exposed as |
@@ -0,1 +1,2 @@ | ||
/* eslint no-undefined: 0 */ | ||
'use strict'; | ||
@@ -7,3 +8,3 @@ | ||
/* | ||
* function simple (opts) | ||
* function simple (info) | ||
* Returns a new instance of the simple format TransformStream | ||
@@ -15,5 +16,9 @@ * which writes a simple representation of logs. | ||
*/ | ||
module.exports = format(function (info, opts) { | ||
module.exports = format(function (info) { | ||
info[MESSAGE] = info.level + ': ' + info.message + ' ' + JSON.stringify( | ||
Object.assign({}, info, { level: undefined, message: undefined }) | ||
Object.assign({}, info, { | ||
level: undefined, | ||
message: undefined, | ||
splat: undefined | ||
}) | ||
); | ||
@@ -20,0 +25,0 @@ |
@@ -7,3 +7,3 @@ 'use strict'; | ||
/* | ||
* function splat (opts) | ||
* function splat (info) | ||
* Returns a new instance of the splat format TransformStream | ||
@@ -13,3 +13,3 @@ * which performs string interpolation from `info` objects. This was | ||
*/ | ||
module.exports = format(function (info, opts) { | ||
module.exports = format(function (info) { | ||
if (info.splat) { | ||
@@ -16,0 +16,0 @@ info.message = util.format(info.message, ...info.splat); |
@@ -7,3 +7,3 @@ 'use strict'; | ||
/* | ||
* function timestamp (opts) | ||
* function timestamp (info) | ||
* Returns a new instance of the timestamp Format which adds a timestamp | ||
@@ -10,0 +10,0 @@ * to the info. It was previously available in winston < 3.0.0 as: |
@@ -8,3 +8,3 @@ 'use strict'; | ||
/* | ||
* function uncolorize (opts) | ||
* function uncolorize (info) | ||
* Returns a new instance of the uncolorize Format that strips colors | ||
@@ -11,0 +11,0 @@ * from `info` objects. This was previously exposed as { stripColors: true } |
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
24209
27
525
4