pn-lambda-logger
Advanced tools
Comparing version
@@ -59,3 +59,3 @@ import { LogInput } from './types/LogInput'; | ||
*/ | ||
debug(logInput: LogInput): void; | ||
debug(logInput: LogInput | string): void; | ||
/** | ||
@@ -65,3 +65,3 @@ * Prints an enriched log as JSON to stdout with newline. | ||
*/ | ||
info(logInput: LogInput): void; | ||
info(logInput: LogInput | string): void; | ||
/** | ||
@@ -71,3 +71,3 @@ * Prints an enriched log as JSON to stdout with newline. | ||
*/ | ||
warn(logInput: LogInput): void; | ||
warn(logInput: LogInput | string): void; | ||
/** | ||
@@ -82,7 +82,8 @@ * Prints an enriched log as JSON to stdout with newline. | ||
*/ | ||
error(logInput: LogInputError): void; | ||
error(logInput: LogInputError | string): void; | ||
/** | ||
* Set initial log level from environment param PN_LOG_LEVEL, with fallback to INFO. | ||
*/ | ||
setInitialLogLevel(): LogLevels; | ||
private setInitialLogLevel; | ||
private stringToLogInput; | ||
private createLogJson; | ||
@@ -89,0 +90,0 @@ /** |
@@ -35,2 +35,5 @@ "use strict"; | ||
debug(logInput) { | ||
if (typeof logInput === 'string') { | ||
logInput = this.stringToLogInput(logInput); | ||
} | ||
let debugLevel = logLevels_1.LogLevels.DEBUG; | ||
@@ -47,2 +50,5 @@ if (debugLevel >= this.level) { | ||
info(logInput) { | ||
if (typeof logInput === 'string') { | ||
logInput = this.stringToLogInput(logInput); | ||
} | ||
let infoLevel = logLevels_1.LogLevels.INFO; | ||
@@ -59,2 +65,5 @@ if (infoLevel >= this.level) { | ||
warn(logInput) { | ||
if (typeof logInput === 'string') { | ||
logInput = this.stringToLogInput(logInput); | ||
} | ||
let warnLevel = logLevels_1.LogLevels.WARN; | ||
@@ -76,2 +85,5 @@ if (warnLevel >= this.level) { | ||
error(logInput) { | ||
if (typeof logInput === 'string') { | ||
logInput = this.stringToLogInput(logInput); | ||
} | ||
let errorLevel = logLevels_1.LogLevels.ERROR; | ||
@@ -106,2 +118,5 @@ if (errorLevel >= this.level) { | ||
} | ||
stringToLogInput(message) { | ||
return { message }; | ||
} | ||
createLogJson(logInput, level) { | ||
@@ -108,0 +123,0 @@ // @ts-ignore |
{ | ||
"name": "pn-lambda-logger", | ||
"version": "0.9.5", | ||
"version": "0.10.0", | ||
"description": "Logger for AWS Lambda nodejs.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -17,3 +17,3 @@ # A nodejs logger for AWS Lambda | ||
// A standard INFO log message | ||
log.info({ message: 'Message' }); | ||
log.info('My message'); | ||
@@ -27,3 +27,3 @@ } | ||
"level": "INFO", | ||
"message": "Message" | ||
"message": "My message" | ||
} | ||
@@ -30,0 +30,0 @@ ``` |
Sorry, the diff of this file is not supported yet
26963
3.84%432
3.85%