pino-mozlog
Advanced tools
Comparing version
29
index.js
#!/usr/bin/env node | ||
'use strict'; | ||
"use strict"; | ||
const pump = require('pump'); | ||
const split = require('split2'); | ||
const through = require('through2'); | ||
var _require = require('./src/index'); | ||
const { | ||
Transform | ||
} = require('readable-stream'); | ||
const createParseFunction = _require.createParseFunction, | ||
createTransformFunction = _require.createTransformFunction, | ||
parseOptions = _require.parseOptions; | ||
const { | ||
createParseFunction, | ||
createTransformFunction, | ||
parseOptions | ||
} = require('./src/index'); | ||
const options = parseOptions(process.argv.slice(2)); | ||
const mozlogTransport = through.obj(createTransformFunction({ options })); | ||
pump(process.stdin, split(createParseFunction({ options })), mozlogTransport); | ||
const mozlogTransport = new Transform({ | ||
objectMode: true, | ||
transform: createTransformFunction({ | ||
options | ||
}) | ||
}); | ||
pump(process.stdin, split(createParseFunction({ | ||
options | ||
})), mozlogTransport, process.stdout); |
{ | ||
"name": "pino-mozlog", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "A transport for transforming pino logs into mozlog", | ||
"main": "index.js", | ||
"bin": { | ||
"pino-mozlog": "./index.js" | ||
"pino-mozlog": "index.js" | ||
}, | ||
@@ -18,16 +18,17 @@ "scripts": { | ||
"dependencies": { | ||
"minimist": "^1.2.0", | ||
"pino-syslog": "^1.2.0", | ||
"pump": "^3.0.0", | ||
"split2": "^2.2.0", | ||
"through2": "^2.0.3" | ||
"minimist": "1.2.5", | ||
"pino-syslog": "1.3.1", | ||
"pump": "3.0.0", | ||
"readable-stream": "3.6.0", | ||
"split2": "3.2.2" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-preset-env": "^1.7.0", | ||
"jest": "^23.4.2", | ||
"jest-json-schema": "^2.0.1", | ||
"prettier": "^1.14.0", | ||
"rimraf": "^2.6.2" | ||
"@babel/cli": "^7.12.10", | ||
"@babel/core": "^7.12.10", | ||
"@babel/plugin-transform-spread": "^7.12.1", | ||
"@babel/preset-env": "^7.12.11", | ||
"jest": "^26.0.0", | ||
"jest-json-schema": "^5.0.0", | ||
"prettier": "^2.0.0", | ||
"rimraf": "^3.0.0" | ||
}, | ||
@@ -34,0 +35,0 @@ "jest": { |
@@ -1,10 +0,8 @@ | ||
'use strict'; | ||
"use strict"; | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
const minimist = require('minimist'); | ||
const minimist = require('minimist'); | ||
const pinoSyslog = require('pino-syslog/lib/utils'); | ||
const ENV_VERSION = '2.0'; | ||
const DEFAULT_OPTIONS = { | ||
@@ -14,3 +12,2 @@ silent: false, | ||
}; | ||
const STACKDRIVER_LEVEL_MAP = { | ||
@@ -51,13 +48,13 @@ [pinoSyslog.severity.emergency]: 800, | ||
const format = (_ref, options = DEFAULT_OPTIONS) => { | ||
let hostname = _ref.hostname, | ||
level = _ref.level, | ||
name = _ref.name, | ||
pid = _ref.pid, | ||
time = _ref.time, | ||
v = _ref.v, | ||
fields = _objectWithoutProperties(_ref, ['hostname', 'level', 'name', 'pid', 'time', 'v']); | ||
const format = ({ | ||
hostname, | ||
level, | ||
name, | ||
pid, | ||
time, | ||
v, | ||
// this field is ignored | ||
...fields | ||
}, options = DEFAULT_OPTIONS) => { | ||
const syslogSeverity = pinoSyslog.levelToSeverity(level); | ||
return { | ||
@@ -70,3 +67,4 @@ EnvVersion: ENV_VERSION, | ||
Severity: syslogSeverity, | ||
Timestamp: time, // should be in nanoseconds | ||
Timestamp: time, | ||
// should be in nanoseconds | ||
Type: options.type, | ||
@@ -105,4 +103,6 @@ // Add a custom key for stackdriver. | ||
const keys = Object.keys(DEFAULT_OPTIONS); | ||
var _minimist = minimist(argv, { | ||
const { | ||
_, | ||
...options | ||
} = minimist(argv, { | ||
boolean: keys.filter(k => typeof DEFAULT_OPTIONS[k] === 'boolean'), | ||
@@ -113,6 +113,2 @@ default: DEFAULT_OPTIONS, | ||
}); | ||
const _ = _minimist._, | ||
options = _objectWithoutProperties(_minimist, ['_']); | ||
return options; | ||
@@ -119,0 +115,0 @@ }; |
128
11.3%21806
-2.04%8
14.29%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated