Sorry, the diff of this file is not supported yet
+2
-2
| language: node_js | ||
| node_js: | ||
| #- 0.8 -- cannot build the dependencies, make fs-ext optional and try again | ||
| - 0.8 | ||
| - 0.10 | ||
@@ -9,3 +9,3 @@ - 4 | ||
| - 10 | ||
| - 11 | ||
| - 12 | ||
| env: | ||
@@ -12,0 +12,0 @@ - CXX=g++-4.8 |
+2
-1
@@ -27,3 +27,4 @@ /** | ||
| module.exports.JsonFilter = require('./lib/filter-json.js'); | ||
| module.exports.BasicFilter = BasicFilter; //require('./lib/filter-basic.js').BasicFilter; | ||
| module.exports.KubeFilter = require('./lib/filter-json.js').KubeFilter; | ||
| module.exports.BasicFilter = BasicFilter; | ||
| // filterBasic is legacy | ||
@@ -30,0 +31,0 @@ module.exports.filterBasic = module.exports.BasicFilter.create(); |
+21
-0
@@ -16,2 +16,3 @@ /** | ||
| module.exports = JsonFilter; | ||
| module.exports.KubeFilter = KubeFilter; | ||
| var timestamps = require('./timestamps'); | ||
@@ -38,2 +39,22 @@ | ||
| function KubeFilter( opts ) { | ||
| this.options = copyObject({ | ||
| type: undefined, | ||
| encode: JSON.stringify, | ||
| timestamp: timestamps.formatJsDateIsoString, | ||
| level: false, | ||
| }, typeof opts === 'string' ? { type: opts } : opts); | ||
| this.filter = function(message, loglevel) { | ||
| var timestamp = this.options.timestamp(); | ||
| var level = (this.options.level) ? '","level":"' + QLogger.LEVELNAMES[loglevel] : ''; | ||
| message = _tryEncode(this.options.encode, message) || '"[unserializable object]"'; | ||
| return '{"time":"' + timestamp + '","type":"' + this.options.type + level + '","message":' + message + '}\n'; | ||
| } | ||
| } | ||
| KubeFilter.create = function create( type ) { | ||
| var kubeFilter = new KubeFilter(type); | ||
| return function(message, level) { return kubeFilter.filter(message, level) }; | ||
| } | ||
| // also allow the legacy name | ||
@@ -40,0 +61,0 @@ JsonFilter.makeFilter = JsonFilter.create; |
+3
-3
| { | ||
| "name": "qlogger", | ||
| "version": "1.6.0", | ||
| "version": "1.7.0", | ||
| "description": "very fast easily customizable logger", | ||
@@ -15,3 +15,3 @@ "license": "Apache-2.0", | ||
| "dependencies": { | ||
| "qfputs": "1.7.2" | ||
| "qfputs": "1.8.0" | ||
| }, | ||
@@ -23,3 +23,3 @@ "devDependencies": { | ||
| "scripts": { | ||
| "prepublishOnly": "mkdir -p .git/ar/ && mv * .git/ar/ && cd .git/ar/ && mv [piLRfl]* ../.. && cd ../..", | ||
| "prepublishOnly": "mv * .git/ar/ && cd .git/ar/ && mv [piLRfl]* ../.. && cd ../..", | ||
| "postpublish": "mv .git/ar/* .", | ||
@@ -26,0 +26,0 @@ "test": "env TZ=America/New_York qnit test", |
+46
-9
@@ -20,2 +20,5 @@ qlogger | ||
| If the optional dependency `fs-ext` is present, files writes will be mutexed to ensure that | ||
| concurrent writes do not overwrite each other. | ||
| And it's nice and fast. On my system I get 1450k 200 byte lines per second saved to a shared | ||
@@ -142,3 +145,3 @@ logfile under LOCK_EX mutex | ||
| Return the array of writers added to this qlogger. | ||
| Return the array of writers attached to this qlogger. | ||
@@ -194,3 +197,3 @@ ### removeWriter( writerObject ) | ||
| Return the array of filters added to this logger. | ||
| Return the array of filters attached to this logger. | ||
@@ -206,4 +209,4 @@ ### removeFilter( filterFunction ) | ||
| `BasicFilter` produces a plaintext logline with a human-readable timestamp | ||
| and the logelevel. | ||
| Returns a `BasicFilter` function, which produces a plaintext logline with a human-readable | ||
| timestamp and the logelevel. | ||
@@ -217,3 +220,3 @@ var filter = require('qlogger/filters').BasicFilter.create(); | ||
| `filterJson(message, level)` logs a stringified json bundle with fields "time", | ||
| `filterJson(message, level)` converts to a stringified json bundle with fields "time", | ||
| "level" and possibly "message" (unless explicitly disabled by setting them to | ||
@@ -258,2 +261,5 @@ `false`). `time` is a millisecond timestamp, `level` is the name of the message | ||
| logger.info({ a: 1, b: 'two' }); | ||
| // {"time":1414627805981,"level":"info","custom1":123,"a":1,"b":"two"} | ||
| logger.info(new Error("oops")); | ||
@@ -270,8 +276,27 @@ // {"time":1414627805981,"level":"info","custom1":123,"message":"Error: oops", | ||
| - `timestamp` - function to generate the timestamp value to include in the output, | ||
| eg `filters.formatJsDateIsoString()`. Default is `filters.getTimestamp()`. | ||
| eg `filters.formatJsDateIsoString`. Default is `filters.getTimestamp`. | ||
| #### filterKube = require('qlogger/filters').KubeFilter.create( options ) | ||
| Returns a function that formats log messages as newline terminated k8s (Kubernetes) | ||
| compatible json strings, each entry with fields `time`, `type` and `message`. Unlike | ||
| JsonFilter, the logged message is always included as the `message` property and not | ||
| merged into the top-level json object. | ||
| If `options` is a string, it will be interpreted as the type, as if `{ type: options }`. | ||
| const KubeFilter = require('qlogger/filters').KubeFilter; | ||
| const filter = KubeFilter.create('test-stream'); | ||
| let str = filter({ a: 1, b: 2 }); | ||
| // => {"time":"2019-02-09T11:05:19.471Z","type":"test-stream","message":{"a":1,"b":2}} | ||
| Options: | ||
| - `type` - log stream type, default `undefined`. The type is included in every logline. | ||
| - `timestamp` - function to compose the logged timestamp. Default is `filters.formatJsDateIsoString`. | ||
| ### Timestamps | ||
| `qlogger` exports its source of high-speed millisecond timestamps. These timestamps | ||
| are also tuned for groups of reads close together. | ||
| are tuned for groups of reads close together. | ||
@@ -298,7 +323,11 @@ const filters = require('qlogger/filters'); | ||
| QLogger exports a few simple timestamp formatters. The formatters take a millisecond | ||
| timestamp as returned by `Date.now()`, and convert it to a datetime string. The formatters | ||
| are optimized to be esepcially fast for clustered timestamps, many close together. | ||
| timestamp as returned by `new Date().getTime()`, and convert it to a datetime string. The | ||
| formatters are very very fast, optimized for realtime timestamps: faster than | ||
| `String(Date.now())`, faster even than `String(count++)`. | ||
| #### filters.formatIsoDate( [timestamp] ) | ||
| SQL ISO-8601 DATETIME, in 'YYYY-MM-DD hh:mm:ss' format, local timezone. | ||
| var timestamp = Date.now(); | ||
@@ -312,2 +341,4 @@ // => 1414627805981 | ||
| SQL DATETIME in GMT timezone. | ||
| filters.formatIsoDateUtc(1414627805981); | ||
@@ -318,2 +349,4 @@ // => 2014-10-30 00:10:05 | ||
| Just the digits from an ISO-8601 datetime, with milliseconds added, in GMT. | ||
| filters.formatNumericDateUtc(1414627805981); | ||
@@ -327,2 +360,4 @@ // => "20141030001005.981" | ||
| JavaScript `new Date().toISOString()` format, always GMT. | ||
| filters.formatJsDateIsoString(); | ||
@@ -333,2 +368,4 @@ // => "2019-02-03T19:41:04.461Z" | ||
| The generic timestamp used by the BasicFilter, an SQL DATETIME with milliseconds, local timezone. | ||
| filters.formatBasicDate(); | ||
@@ -335,0 +372,0 @@ // => "2019-02-03 19:41:04.461" |
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.
47218
11.21%10
11.11%511
4.07%469
8.56%3
-25%+ Added
+ Added
- Removed
- Removed
Updated