@everymundo/simple-logr
Advanced tools
Comparing version 2.0.4 to 2.1.0
23
index.js
'use strict' | ||
const pino = require('pino') | ||
const flatstr = require('flatstr') | ||
const defaultOptions = { | ||
level: process.env.LOG_LEVEL || 'info', | ||
timestamp: !process.env.LOG_NODATE, | ||
get timestamp () { | ||
if (process.env.LOG_NODATE) { | ||
return false | ||
} | ||
if (process.env.LOG_DATE_FORMAT in pino.stdTimeFunctions) { | ||
return pino.stdTimeFunctions[process.env.LOG_DATE_FORMAT] | ||
} | ||
return pino.stdTimeFunctions.epochTime | ||
}, | ||
useLevelLabels: true, | ||
@@ -12,7 +23,17 @@ base: null | ||
// Default is this | ||
// ',"pid":2365,"hostname":"daniel-XPS-15-7590"' | ||
function setRequestId (RequestId) { | ||
this[pino.symbols.chindingsSym] = flatstr(`,"RequestId":${JSON.stringify(RequestId)}`) | ||
} | ||
const createLogger = (options = {}) => { | ||
const pinoOptions = { ...defaultOptions, ...options } | ||
const mainLogr = pino(pinoOptions) | ||
mainLogr.createLogger = createLogger | ||
mainLogr.setRequestId = setRequestId | ||
mainLogr[pino.symbols.endSym] = '}\n' | ||
return mainLogr | ||
@@ -19,0 +40,0 @@ } |
{ | ||
"name": "@everymundo/simple-logr", | ||
"version": "2.0.4", | ||
"version": "2.1.0", | ||
"description": "A very simplistic logger that allows one to avoid using the console.log directly allowing stubbing and better linting.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
8105
72
5