filter-log
Advanced tools
Comparing version 0.0.5 to 0.0.8
@@ -1,3 +0,1 @@ | ||
var _ = require('underscore') | ||
var util = require('util') | ||
@@ -14,5 +12,3 @@ var isStream = require('is-stream') | ||
function writeToProcessors(data) { | ||
_.each(_.values(filterLog.logsProc), function(processor) { | ||
processor.head.write(data) | ||
}) | ||
Object.values(filterLog.logsProc).forEach(processor => processor.head.write(data)) | ||
} | ||
@@ -29,3 +25,3 @@ | ||
} | ||
writeToProcessors(_.extend(filterLog.baseInformationGenerator(), | ||
writeToProcessors(Object.assign(filterLog.baseInformationGenerator(), | ||
{loggerName: name}, filterLog.logsData[name], stream.loggerSpecificData, data)) | ||
@@ -35,3 +31,3 @@ callback() | ||
_.each(_.keys(filterLog.levels), function(key) { | ||
Object.keys(filterLog.levels).forEach(key => { | ||
stream[key.toLowerCase()] = function(data) { | ||
@@ -49,3 +45,3 @@ if(typeof data == 'string') { | ||
if(typeof data == 'object') { | ||
stream.write(_.extend({}, data, {level: filterLog.levels[key]})) | ||
stream.write(Object.assign({}, data, {level: filterLog.levels[key]})) | ||
} | ||
@@ -123,3 +119,3 @@ } | ||
filterLog.defineLoggerBaseData = function(loggerName, data) { | ||
data = _.extend({}, data) | ||
data = Object.assign({}, data) | ||
delete data.loggerName | ||
@@ -134,3 +130,3 @@ filterLog.logsData[loggerName] = data | ||
destination: destination || process.stdout, | ||
baseData: _.extend({}, baseData, { processorName: name }), | ||
baseData: Object.assign({}, baseData, { processorName: name }), | ||
@@ -137,0 +133,0 @@ // should be a function or stream of some sort |
{ | ||
"name": "filter-log", | ||
"version": "0.0.5", | ||
"version": "0.0.8", | ||
"description": "flexible, minimalistic logging", | ||
"main": "filter-log.js", | ||
"scripts": { | ||
"test": "node_modules/mocha/bin/mocha", | ||
"testDebug": "node_modules/mocha/bin/mocha --inspect --debug-brk", | ||
"test": "node_modules/mocha/bin/mocha.js", | ||
"testDebug": "node_modules/mocha/bin/mocha.js --inspect --debug-brk", | ||
"gen-random-logs": "./examples/gen-random-logs.js > examples/gen-random-logs.json", | ||
@@ -16,5 +16,2 @@ "process-1": "cat examples/gen-random-logs.json | ./examples/process-1.js > examples/process-1.txt" | ||
}, | ||
"bin": { | ||
"filter-log": "./filter-log-command.js" | ||
}, | ||
"keywords": [ | ||
@@ -33,13 +30,16 @@ "logging", | ||
"chai": "^4.0.2", | ||
"mocha": "^3.4.2", | ||
"mocha": "^10.2.0", | ||
"random-strings": "0.0.1" | ||
}, | ||
"dependencies": { | ||
"JSONStream": "^1.3.1", | ||
"is-stream": "^1.1.0", | ||
"minimist": "^1.2.0", | ||
"through2": "^2.0.3", | ||
"tripartite": "^1.0.7", | ||
"underscore": "^1.8.3" | ||
} | ||
"is-stream": "^1.1.0" | ||
}, | ||
"files": [ | ||
"/filters", | ||
"/streams", | ||
"/transformers", | ||
"/filter-log.js", | ||
"/levels.js", | ||
"README.md" | ||
] | ||
} |
@@ -125,12 +125,5 @@ # filter-log | ||
``` | ||
filter-log -h | ||
``` | ||
or | ||
See the filter-log-tools package | ||
``` | ||
cat my-log.json | filter-log > my-log.txt | ||
``` | ||
Anything complicated though, and it may be much easier to write your own tiny program to process the entries. `exmaples/process-1.js` is a simple example. The source for `filter-log-command.js` may also serve as an example. | ||
@@ -140,2 +133,1 @@ | ||
@@ -1,11 +0,16 @@ | ||
var through2 = require('through2') | ||
const { Transform } = require('stream') | ||
var createStream = function(filter) { | ||
var stream = through2({ objectMode: true }, function(chunk, enc, callback) { | ||
if(filter(chunk)) { | ||
this.push(chunk) | ||
var createStream = function (filter) { | ||
let stream = new Transform({ | ||
objectMode: true, | ||
transform(chunk, encoding, callback) { | ||
if (filter(chunk)) { | ||
this.push(chunk) | ||
} | ||
callback() | ||
} | ||
callback() | ||
}) | ||
return stream | ||
@@ -12,0 +17,0 @@ } |
@@ -1,15 +0,18 @@ | ||
var through2 = require('through2') | ||
const { Transform } = require('stream') | ||
var createStream = function() { | ||
var stream = through2({ objectMode: true }, function(chunk, enc, callback) { | ||
this.data.push(chunk) | ||
callback() | ||
var createStream = function (filter) { | ||
let stream = new Transform({ | ||
objectMode: true, | ||
transform(chunk, encoding, callback) { | ||
this.data.push(chunk) | ||
callback() | ||
} | ||
}) | ||
stream.data = [] | ||
return stream | ||
} | ||
module.exports = createStream | ||
module.exports = createStream |
@@ -1,18 +0,14 @@ | ||
var through2 = require('through2') | ||
// var stream = require('stream'); | ||
const { Transform } = require('stream') | ||
// var createStream = function() { | ||
// return new stream.Transform({objectMode: true}) | ||
// } | ||
// | ||
// module.exports = createStream | ||
var createStream = function () { | ||
let stream = new Transform({ | ||
objectMode: true, | ||
var createStream = function() { | ||
var stream = through2({ objectMode: true }, function(chunk, enc, callback) { | ||
this.push(chunk) | ||
callback() | ||
transform(chunk, encoding, callback) { | ||
this.push(chunk) | ||
callback() | ||
} | ||
}) | ||
return stream | ||
@@ -19,0 +15,0 @@ } |
@@ -1,14 +0,17 @@ | ||
var through2 = require('through2') | ||
const { Transform } = require('stream') | ||
var createStream = function() { | ||
var stream = through2({ objectMode: false }, function(chunk, enc, callback) { | ||
var result = chunk.toString() | ||
this.data += result | ||
this.push(result) | ||
callback() | ||
var createStream = function () { | ||
let stream = new Transform({ | ||
objectMode: false, | ||
transform(chunk, encoding, callback) { | ||
var result = chunk.toString() | ||
this.data += result | ||
this.push(result) | ||
callback() | ||
} | ||
}) | ||
stream.data = '' | ||
return stream | ||
@@ -15,0 +18,0 @@ } |
@@ -1,12 +0,18 @@ | ||
var through2 = require('through2') | ||
const { Transform } = require('stream') | ||
var createStream = function(transform) { | ||
var stream = through2({ objectMode: true }, function(chunk, enc, callback) { | ||
this.push(transform(chunk)) | ||
callback() | ||
var createStream = function (transform) { | ||
let stream = new Transform({ | ||
objectMode: true, | ||
transform(chunk, encoding, callback) { | ||
this.push(transform(chunk)) | ||
callback() | ||
} | ||
}) | ||
return stream | ||
} | ||
module.exports = createStream | ||
module.exports = createStream | ||
@@ -1,11 +0,17 @@ | ||
var through2 = require('through2') | ||
const { Transform } = require('stream') | ||
var createStream = function (filter) { | ||
var transformer = function() { | ||
return through2({ objectMode: true }, function(chunk, enc, callback) { | ||
this.push(chunk) | ||
callback() | ||
let stream = new Transform({ | ||
objectMode: true, | ||
transform(chunk, encoding, callback) { | ||
// this.push(chunk) | ||
callback() | ||
} | ||
}) | ||
return stream | ||
} | ||
module.exports = transformer | ||
module.exports = createStream |
@@ -1,18 +0,33 @@ | ||
var through2 = require('through2') | ||
const { Transform } = require('stream') | ||
function errorSerialization(key, obj) { | ||
if (obj instanceof Error) { | ||
return { | ||
name: obj.name, | ||
message: obj.message, | ||
stack: obj.stack | ||
} | ||
} | ||
return obj | ||
} | ||
var transformer = function(prefix, suffix) { | ||
return through2({ objectMode: true }, function(chunk, enc, callback) { | ||
var result = JSON.stringify(chunk) | ||
if(prefix) { | ||
this.push(prefix) | ||
var transformer = function (prefix, suffix) { | ||
let stream = new Transform({ | ||
objectMode: true, | ||
transform(chunk, encoding, callback) { | ||
var result = JSON.stringify(chunk, errorSerialization) | ||
if (prefix) { | ||
this.push(prefix) | ||
} | ||
this.push(result) | ||
if (suffix) { | ||
this.push(suffix) | ||
} | ||
callback() | ||
} | ||
this.push(result) | ||
if(suffix) { | ||
this.push(suffix) | ||
} | ||
callback() | ||
}) | ||
return stream | ||
} | ||
module.exports = transformer |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
0
0
25895
13
254
132
- RemovedJSONStream@^1.3.1
- Removedminimist@^1.2.0
- Removedthrough2@^2.0.3
- Removedtripartite@^1.0.7
- Removedunderscore@^1.8.3
- RemovedJSONStream@1.3.5(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@1.0.0(transitive)
- Removedjsonparse@1.3.1(transitive)
- Removedminimist@1.2.8(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedthrough@2.3.8(transitive)
- Removedthrough2@2.0.5(transitive)
- Removedtripartite@1.1.4(transitive)
- Removedunderscore@1.13.7(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedxtend@4.0.2(transitive)