@@ -7,10 +7,42 @@ const forcedDebug = process.env['NODE_ENV'] === 'debug';
77
88if ( forcedDebug === true ) {
99 console . log (
10- 'NODE_ENV environmental variable is set to debug, forcing all logs to print'
10+ 'NODE_ENV environmental variable is set to debug, forcing all logs to print'
1111 ) ;
1212}
1313
14+ export type LoggerFunction = ( ...args : ( string | number ) [ ] ) => void ;
15+
16+ export interface ILogger {
17+ silly : LoggerFunction ;
18+ debug : LoggerFunction ;
19+ verbose : LoggerFunction ;
20+ info : LoggerFunction ;
21+ warn : LoggerFunction ;
22+ error : LoggerFunction ;
23+ }
24+
25+ export const createLoggerWrapper = ( TAG : string ) : ILogger => ( {
26+ silly : ( ...args : ( string | number ) [ ] ) => {
27+ Logger . silly ( TAG , ...args ) ;
28+ } ,
29+ debug : ( ...args : ( string | number ) [ ] ) => {
30+ Logger . debug ( TAG , ...args ) ;
31+ } ,
32+ verbose : ( ...args : ( string | number ) [ ] ) => {
33+ Logger . verbose ( TAG , ...args ) ;
34+ } ,
35+ info : ( ...args : ( string | number ) [ ] ) => {
36+ Logger . info ( TAG , ...args ) ;
37+ } ,
38+ warn : ( ...args : ( string | number ) [ ] ) => {
39+ Logger . warn ( TAG , ...args ) ;
40+ } ,
41+ error : ( ...args : ( string | number ) [ ] ) => {
42+ Logger . error ( TAG , ...args ) ;
43+ }
44+ } ) ;
45+
1446export class Logger {
1547 public static silly ( ...args : ( string | number ) [ ] ) : void {
1648 if ( ! forcedDebug && Config . Server . Log . level < LogLevel . silly ) {
@@ -55,10 +87,10 @@ export class Logger {
5587 const date = new Date ( ) . toLocaleString ( ) ;
5688 let LOG_TAG = '' ;
5789 if (
58- args . length > 0 &&
59- typeof args [ 0 ] === 'string' &&
60- args [ 0 ] . startsWith ( '[' ) &&
61- args [ 0 ] . endsWith ( ']' )
90+ args . length > 0 &&
91+ typeof args [ 0 ] === 'string' &&
92+ args [ 0 ] . startsWith ( '[' ) &&
93+ args [ 0 ] . endsWith ( ']' )
6294 ) {
6395 LOG_TAG = args [ 0 ] ;
6496 args . shift ( ) ;
0 commit comments