Comparing version 0.18.1 to 0.19.0
@@ -64,2 +64,15 @@ logfmt = require('../logfmt'); | ||
logger.error = function(err, stream){ | ||
var now = (new Date()).getTime() | ||
var id = Math.random().toString().slice(2, 12); | ||
data = { error:true, id:id }; | ||
for (key in top_data) { | ||
data[key] = top_data[key]; | ||
} | ||
data[label] = (now - startTime).toString() + 'ms'; | ||
var stream = stream || self.stream; | ||
self.log(data, stream); | ||
self.error(err, id); | ||
} | ||
if (typeof callback === 'function') { | ||
@@ -91,4 +104,6 @@ callback(logger); | ||
exports.error = function(err) { | ||
var id = Math.random().toString().slice(2, 12); | ||
exports.error = function(err, id) { | ||
if (id === undefined) { | ||
id = Math.random().toString().slice(2, 12); | ||
} | ||
this.log({ error:true, id:id, message:err.message }); | ||
@@ -95,0 +110,0 @@ var stack = err.stack.split('\n'); |
@@ -1,6 +0,6 @@ | ||
var logfmt = function(){ | ||
var logfmt = function(stream){ | ||
var parse = require('./lib/logfmt_parser').parse; | ||
this.parse = parse; | ||
this.stream = process.stdout; | ||
this.stream = stream || process.stdout; | ||
@@ -7,0 +7,0 @@ var logger = require('./lib/logger'); |
{ | ||
"name": "logfmt", | ||
"version": "0.18.1", | ||
"version": "0.19.0", | ||
"description": "key=value logger and parser", | ||
@@ -27,8 +27,8 @@ "main": "logfmt.js", | ||
"keywords": [ | ||
"Log", | ||
"Parser", | ||
"log", | ||
"parser", | ||
"logfmt" | ||
], | ||
"author": "csquared", | ||
"license": "BSD" | ||
"license": "MIT" | ||
} |
@@ -24,2 +24,10 @@ var logfmt = require('../logfmt'), | ||
}) | ||
test('constructor accepts a stream', function(){ | ||
stream = new OutStream; | ||
var logfmt2 = new logfmt(stream); | ||
var data = {foo: 'bar', a: 14} | ||
logfmt2.log(data); | ||
assert.equal("foo=bar a=14\n", stream.logline) | ||
}) | ||
}) |
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
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
55574
0
0
1305