Comparing version 0.1.0 to 0.1.1
@@ -5,6 +5,8 @@ 'use strict' | ||
var info = pino.info | ||
var error = pino.error | ||
info('hello world') | ||
error('this is at error level') | ||
info('the answer is %d', 42) | ||
info({ obj: 42 }, 'hello world') | ||
setImmediate(info, 'after setImmediate') |
{ | ||
"name": "pino", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "your logger, inspired by bunyan", | ||
@@ -5,0 +5,0 @@ "main": "pino.js", |
49
pino.js
@@ -19,3 +19,3 @@ 'use strict' | ||
function sermon (stream, opts) { | ||
function pino (stream, opts) { | ||
stream = stream || process.stdout | ||
@@ -38,24 +38,3 @@ opts = opts || {} | ||
for (var key in levels) { | ||
// needed because we cannot put arguments manipulation | ||
// in another function without paying a perf drop | ||
eval('' + // eslint-disable-line no-eval | ||
'funcs.' + key + ' = function ' + key + ' () {\n' + | ||
' var base = 0\n' + | ||
' var obj = null\n' + | ||
' var msg // so it does not happear in the json\n' + | ||
' if (is.isObject(arguments[0])) {\n' + | ||
' obj = arguments[0]\n' + | ||
' base += 1\n' + | ||
' }\n' + | ||
' var toFormat = new Array(arguments.length - base)\n' + | ||
' for (var i = base; i < arguments.length; i++) {\n' + | ||
' toFormat[i - base] = arguments[i]\n' + | ||
' }\n' + | ||
' if (toFormat.length > 0) {\n' + | ||
' msg = format.apply(null, toFormat)\n' + | ||
' }\n' + | ||
' stream.write(asJson(obj, msg, ' + levels[key] + ' ))\n' + | ||
'}' | ||
) | ||
funcs[key] = genLogFunction(key) | ||
} | ||
@@ -88,2 +67,24 @@ | ||
function genLogFunction (key) { | ||
var level = levels[key] | ||
return function (a, b, c, d, e, f, g, h, i, j, k) { | ||
var base = 0 | ||
var obj = null | ||
var params = null | ||
var msg | ||
if (Object(a) === a) { | ||
obj = a | ||
params = [b, c, d, e, f, g, h, i, j, k] | ||
base = 1 | ||
} else { | ||
params = [a, b, c, d, e, f, g, h, i, j, k] | ||
} | ||
if ((params.length = arguments.length - base) > 0) { | ||
msg = format.apply(null, params) | ||
} | ||
stream.write(asJson(obj, msg, level)) | ||
} | ||
} | ||
function asJson (obj, msg, num) { // eslint-disable-line no-unused-vars | ||
@@ -114,2 +115,2 @@ var data = JSON.stringify(new Message(num, msg)) | ||
module.exports = sermon | ||
module.exports = pino |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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 eval() which is a dangerous function. This prevents 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
9
308
11081