@join-com/gcloud-logger
Advanced tools
Comparing version 1.4.0-alpha.1 to 1.4.0-alpha.2
@@ -10,3 +10,3 @@ export declare enum Level { | ||
private readonly logger; | ||
constructor(usePrettyPrint: boolean, logLevelStarts?: string, excludeKeys?: string[]); | ||
constructor(disablePrettyPrint: boolean, logLevelStarts?: string, excludeKeys?: string[]); | ||
debug(message: string, payload?: unknown): void; | ||
@@ -16,3 +16,3 @@ info(message: string, payload?: unknown): void; | ||
error(message: string, payload?: unknown): void; | ||
critical(message: string, payload?: unknown): void; | ||
fatal(message: string, payload?: unknown): void; | ||
reportError(err: unknown): void; | ||
@@ -19,0 +19,0 @@ private getMessage; |
@@ -32,5 +32,24 @@ "use strict"; | ||
})); | ||
const OldLogLevelToPinoLevel = new Map(Object.entries({ | ||
DEFAULT: 'info', | ||
DEBUG: 'debug', | ||
INFO: 'info', | ||
NOTICE: 'info', | ||
WARNING: 'warn', | ||
ERROR: 'error', | ||
CRITICAL: 'fatal', | ||
ALERT: 'fatal', | ||
EMERGENCY: 'fatal' | ||
})); | ||
class Logger { | ||
constructor(usePrettyPrint, logLevelStarts, excludeKeys = ['password', 'token', 'newPassword', 'oldPassword']) { | ||
const defaultPinoConf = { | ||
constructor(disablePrettyPrint, logLevelStarts, excludeKeys = ['password', 'token', 'newPassword', 'oldPassword']) { | ||
let logLevel = logLevelStarts || 'info'; | ||
if (!PinoLevelToCloudLevelLookup.has(logLevel)) { | ||
logLevel = OldLogLevelToPinoLevel.get(logLevel) || 'info'; | ||
} | ||
const pinoConfig = { | ||
base: undefined, | ||
timestamp: false, | ||
level: logLevel, | ||
redact: excludeKeys, | ||
messageKey: 'message', | ||
@@ -47,9 +66,6 @@ formatters: { | ||
}; | ||
const transport = usePrettyPrint ? { target: 'pino-pretty' } : { target: '' }; | ||
this.logger = (0, pino_1.default)({ | ||
level: logLevelStarts, | ||
redact: excludeKeys, | ||
defaultPinoConf, | ||
transport, | ||
}); | ||
if (!disablePrettyPrint) { | ||
pinoConfig['transport'] = { target: 'pino-pretty' }; | ||
} | ||
this.logger = (0, pino_1.default)(pinoConfig); | ||
} | ||
@@ -68,3 +84,3 @@ debug(message, payload) { | ||
} | ||
critical(message, payload) { | ||
fatal(message, payload) { | ||
this.logger.fatal(payload, message); | ||
@@ -71,0 +87,0 @@ } |
{ | ||
"name": "@join-com/gcloud-logger", | ||
"version": "1.4.0-alpha.1", | ||
"version": "1.4.0-alpha.2", | ||
"description": "gcloud simple logger", | ||
@@ -5,0 +5,0 @@ "author": "JOIN Solutions", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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.
Found 1 instance in 1 package
9813
133
0