@invisible/logger
Advanced tools
Comparing version
14
index.js
@@ -5,15 +5,15 @@ 'use strict' | ||
const isTest = (process.env.NODE_ENV === 'test') | ||
const enabledInTest = (process.env.LOGGER_ENABLED_IN_TEST === 'true') | ||
const isTest = process.env.NODE_ENV === 'test' | ||
const enabledInTest = process.env.LOGGER_ENABLED_IN_TEST === 'true' | ||
const transports = [ | ||
(process.env.LOGGER_TIMBER === 'true') ? | ||
require('./transports/timber') : | ||
require('./transports/console'), | ||
process.env.LOGGER_TIMBER === 'true' | ||
? require('./transports/timber') | ||
: require('./transports/console'), | ||
] | ||
const logger = new (winston.Logger)({ | ||
const logger = new winston.Logger({ | ||
exitOnError: false, | ||
transports: (isTest && ! enabledInTest) ? undefined : transports, | ||
transports: isTest && ! enabledInTest ? undefined : transports, | ||
}) | ||
module.exports = logger |
{ | ||
"name": "@invisible/logger", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Invisible Logging Wrapper", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
'use strict' | ||
const serialize = meta => { | ||
if (! meta || typeof meta === 'string') return meta | ||
if (meta.toJSON) return JSON.parse(meta.toJSON()) | ||
const serialize = (meta, levels = 0) => { | ||
if (levels > 10) return meta // just a precaution. Should never get here | ||
if (! meta || typeof meta !== 'object') return meta | ||
if (meta.toJSON) return meta.toJSON() | ||
if (meta.dataValues) return serialize(meta.dataValues) | ||
Object.keys(meta).forEach(key => { | ||
meta[key] = serialize(meta[key]) | ||
meta[key] = serialize(meta[key], levels + 1) | ||
}) | ||
@@ -9,0 +11,0 @@ return meta |
@@ -10,15 +10,9 @@ 'use strict' | ||
const { | ||
TIMBER_LEVEL = 'info', | ||
} = process.env | ||
const { TIMBER_LEVEL = 'info' } = process.env | ||
assertLevel(TIMBER_LEVEL, 'TIMBER_LEVEL invalid.') | ||
const dropLineBreak = string => ( | ||
string.endsWith('\n') | ||
? string.substring(0, string.length - 1) | ||
: string | ||
) | ||
module.exports = new (winston.transports.Console)({ | ||
const dropLineBreak = string => | ||
(string.endsWith('\n') ? string.substring(0, string.length - 1) : string) | ||
module.exports = new winston.transports.Console({ | ||
name: 'timber', | ||
@@ -25,0 +19,0 @@ level: TIMBER_LEVEL, |
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
13017
2.8%16
6.67%176
-1.68%1
Infinity%