Add convenience method for parsing LogLevel values form string.
This commit is contained in:
parent
e42549773d
commit
6562948acb
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@jdbernard/logging",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "Simple Javascript logging service.",
|
||||
"main": "src/index.ts",
|
||||
"module": "dist/index.js",
|
||||
@ -9,7 +9,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.jdb-labs.com/jdb/js-logging.git"
|
||||
"url": "https://git.jdb-software.com/jdb/js-logging.git"
|
||||
},
|
||||
"keywords": [
|
||||
"log",
|
||||
|
@ -9,6 +9,17 @@ export enum LogLevel {
|
||||
FATAL
|
||||
}
|
||||
|
||||
const kv = 'WARN';
|
||||
const TEST = LogLevel[kv];
|
||||
|
||||
export function parseLogLevel(str: string, defaultLevel = LogLevel.INFO): LogLevel {
|
||||
if (Object.prototype.hasOwnProperty.call(LogLevel, str)) {
|
||||
return LogLevel[<any>str] as unknown as LogLevel;
|
||||
} else {
|
||||
return defaultLevel;
|
||||
}
|
||||
}
|
||||
|
||||
export interface LogMessage {
|
||||
scope: string;
|
||||
level: LogLevel;
|
||||
|
Loading…
Reference in New Issue
Block a user