strong-log-transformer
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -0,1 +1,15 @@ | ||
2018-12-14, Version 2.1.0 | ||
========================= | ||
* src: replace byline with custom splitter (Ryan Graham) | ||
* test: add color tag tests (Ryan Graham) | ||
* test: ensure test fixtures use consistent newlines (Ryan Graham) | ||
* test: replicate shell tests in JS (Ryan Graham) | ||
* test: add tests for truncated utf8 sequences (Ryan Graham) | ||
2018-08-11, Version 2.0.0 | ||
@@ -2,0 +16,0 @@ ========================= |
@@ -12,5 +12,5 @@ // Copyright IBM Corp. 2014,2018. All Rights Reserved. | ||
var byline = require('byline'); | ||
var through = require('through'); | ||
var duplexer = require('duplexer'); | ||
var StringDecoder = require('string_decoder').StringDecoder; | ||
@@ -34,3 +34,3 @@ module.exports = Logger; | ||
options = util._extend(defaults, options || {}); | ||
var catcher = new byline.LineStream; | ||
var catcher = deLiner(); | ||
var emitter = catcher; | ||
@@ -61,3 +61,3 @@ var transforms = [ | ||
// restore line endings that were removed by byline | ||
// restore line endings that were removed by line splitting | ||
transforms.push(reLiner()); | ||
@@ -72,2 +72,30 @@ | ||
function deLiner() { | ||
var decoder = new StringDecoder('utf8'); | ||
var last = ''; | ||
return new stream.Transform({ | ||
transform(chunk, _enc, callback) { | ||
last += decoder.write(chunk); | ||
var list = last.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/g); | ||
last = list.pop(); | ||
for (var i = 0; i < list.length; i++) { | ||
// swallow empty lines | ||
if (list[i]) { | ||
this.push(list[i]); | ||
} | ||
} | ||
callback(); | ||
}, | ||
flush(callback) { | ||
// incomplete UTF8 sequences become UTF8 replacement characters | ||
last += decoder.end(); | ||
if (last) { | ||
this.push(last); | ||
} | ||
callback(); | ||
}, | ||
}); | ||
} | ||
function reLiner() { | ||
@@ -74,0 +102,0 @@ return through(appendNewline); |
{ | ||
"name": "strong-log-transformer", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Stream transformer that prefixes lines with timestamps and other things.", | ||
@@ -30,3 +30,2 @@ "author": "Ryan Graham <ryan@strongloop.com>", | ||
"dependencies": { | ||
"byline": "^5.0.0", | ||
"duplexer": "^0.1.1", | ||
@@ -33,0 +32,0 @@ "minimist": "^1.2.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
16436
3
231
- Removedbyline@^5.0.0
- Removedbyline@5.0.0(transitive)