filter-log
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "filter-log", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "flexible, minimalistic logging", | ||
"main": "filter-log.js", | ||
"scripts": { | ||
"test": "node_modules/mocha/bin/mocha" | ||
"test": "node_modules/mocha/bin/mocha", | ||
"testDebug": "node_modules/mocha/bin/mocha --inspect --debug-brk" | ||
}, | ||
@@ -13,2 +14,5 @@ "repository": { | ||
}, | ||
"bin": { | ||
"filter-log": "./filter-log-command.js" | ||
}, | ||
"keywords": [ | ||
@@ -24,3 +28,15 @@ "logging", | ||
}, | ||
"homepage": "https://github.com/EmergentIdeas/filter-log#readme" | ||
"homepage": "https://github.com/EmergentIdeas/filter-log#readme", | ||
"devDependencies": { | ||
"chai": "^4.0.2", | ||
"mocha": "^3.4.2" | ||
}, | ||
"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" | ||
} | ||
} |
# filter-log | ||
flexible, minimalistic logging | ||
flexible, minimalistic event-bus style logging | ||
## Description | ||
Logging is really two things. | ||
1. Creating information about what code is doing. | ||
2. Doing something with that information (like saving it or filtering it). | ||
Filter log separates those concerns using the event bus pattern. Code that produces log entries get tools that make event log entries easy to create and informational. The application can set up how log events will be captured and saved. Log events are JS objects so we can save lots of information. | ||
## The Basic Boring Example | ||
``` | ||
var filog = require('filter-log') | ||
filog.defineProcessor(process.stdout) | ||
var log = filog() | ||
log.info('hello, world!') | ||
``` | ||
Here we've done the basics. Line 2 creates a processor which is listening for log entries. It has no filter and will log absolutely everything. Since no transformer was specfied, the log entries will be formatted as streamable JSON. | ||
Line 3 creates a new logger. It has the basic tools you'd expect for logging by level and string interpolation. Line 4 creates a new log entry, sets the level to "info" and publishes it. | ||
If you run this example, a JSON formatted log entry will show up in stdout. | ||
## Logging more Data | ||
Strings are fine, but objects contain more information. Let's log an object. | ||
``` | ||
log.write({ event: 'vip login', firstName: 'John'}) | ||
``` | ||
The object above will be augmented with date information and (given the processor set up in the first example) logged to std out. Filter log loggers are streams. You can write and pipe data to them like normal streams. | ||
## Letting the Logger Help | ||
Lots of times the logger will have contextual information you want to save with every log entry. This could be just the name of the component creating the log entry or could be selected configuration items that are determing behavior or environmental information that will help with debugging. Let's create a logger which with will help us keep our code DRY. | ||
``` | ||
var log = filog('my-auth-component', { hostName: require('os').hostname() }) | ||
log.info('successful log in for %s', userName) | ||
``` | ||
A couple new things. When we created the logger on line 1, we gave it a name, `my-auth-component`. This will be used to identify all log entries created through this logger. We also set a single property that will be added to every log entry, the `hostName`. On line 2, we've used string interpolation to make it a little easier to create a message. | ||
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
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
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
26846
19
304
57
6
2
1
3
+ AddedJSONStream@^1.3.1
+ Addedis-stream@^1.1.0
+ Addedminimist@^1.2.0
+ Addedthrough2@^2.0.3
+ Addedtripartite@^1.0.7
+ Addedunderscore@^1.8.3
+ AddedJSONStream@1.3.5(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjsonparse@1.3.1(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedthrough2@2.0.5(transitive)
+ Addedtripartite@1.1.4(transitive)
+ Addedunderscore@1.13.7(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedxtend@4.0.2(transitive)