-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated all dependencies * Added type to logger for tslog 4 * Implemented LogBuilder
- Loading branch information
1 parent
33d35ab
commit 92d8464
Showing
12 changed files
with
166 additions
and
125 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "jitar-nodejs-server", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "NodeJS server implementation for Jitar.", | ||
"author": "Masking Technology <[email protected]> (https://jitar.dev)", | ||
"license": "MIT", | ||
|
@@ -22,14 +22,14 @@ | |
"dependencies": { | ||
"@overnightjs/core": "^1.7.6", | ||
"class-transformer": "^0.5.1", | ||
"class-validator": "^0.13.2", | ||
"class-validator": "^0.14.0", | ||
"express": "^4.18.1", | ||
"express-http-proxy": "^1.6.3", | ||
"fs-extra": "^11.1.0", | ||
"glob": "^8.0.3", | ||
"glob-promise": "^5.0.0", | ||
"mime-types": "^2.1.35", | ||
"tslog": "^3.3.3", | ||
"tslog": "^4.4.4", | ||
"yargs": "^17.6.0", | ||
"jitar": "^0.2.1" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
packages/jitar-nodejs-server/src/configuration/ServerOptions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
import { Logger } from 'tslog'; | ||
|
||
export enum LogLevel | ||
{ | ||
DEBUG = 'debug', | ||
INFO = 'info', | ||
WARN = 'warn', | ||
ERROR = 'error', | ||
FATAL = 'fatal' | ||
} | ||
|
||
export default class LogBuilder | ||
{ | ||
static build(level: string): Logger<unknown> | ||
{ | ||
const logConfiguration = this.#getLogConfiguration(level); | ||
|
||
return new Logger(logConfiguration); | ||
} | ||
|
||
static #getLogConfiguration(level: string): object | ||
{ | ||
const logLevel = this.#getLogLevel(level); | ||
|
||
return { | ||
prettyLogTemplate: "{{dateIsoStr}}\t{{logLevelName}}\t", | ||
minLevel: logLevel | ||
}; | ||
} | ||
|
||
static #getLogLevel(level: string): number | ||
{ | ||
switch (level) | ||
{ | ||
case LogLevel.FATAL: | ||
return 6; | ||
case LogLevel.ERROR: | ||
return 5; | ||
case LogLevel.WARN: | ||
return 4; | ||
case LogLevel.INFO: | ||
return 3; | ||
default: | ||
return 2; | ||
} | ||
} | ||
} |