forked from fullstack-build/tslog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
84 lines (74 loc) · 2.65 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { BaseLogger, ILogObjMeta, ISettingsParam, ILogObj } from "./BaseLogger.js";
export { ISettingsParam, BaseLogger };
export class Logger<LogObj> extends BaseLogger<LogObj> {
constructor(settings?: ISettingsParam<LogObj>, logObj?: LogObj) {
super(settings, logObj, 5);
}
/**
* Logs a message with a custom log level.
* @param logLevelId - Log level ID e.g. 0
* @param logLevelName - Log level name e.g. silly
* @param args - Multiple log attributes that should be logged out.
*/
public log(logLevelId: number, logLevelName: string, ...args: unknown[]): (LogObj & ILogObjMeta & ILogObj) | undefined {
return super.log(logLevelId, logLevelName, ...args);
}
/**
* Logs a silly message.
* @param args - Multiple log attributes that should be logged out.
*/
public silly(...args: unknown[]): (LogObj & ILogObjMeta) | undefined {
return super.log(0, "SILLY", ...args);
}
/**
* Logs a trace message.
* @param args - Multiple log attributes that should be logged out.
*/
public trace(...args: unknown[]): (LogObj & ILogObjMeta) | undefined {
return super.log(1, "TRACE", ...args);
}
/**
* Logs a debug message.
* @param args - Multiple log attributes that should be logged out.
*/
public debug(...args: unknown[]): (LogObj & ILogObjMeta) | undefined {
return super.log(2, "DEBUG", ...args);
}
/**
* Logs an info message.
* @param args - Multiple log attributes that should be logged out.
*/
public info(...args: unknown[]): (LogObj & ILogObjMeta) | undefined {
return super.log(3, "INFO", ...args);
}
/**
* Logs a warn message.
* @param args - Multiple log attributes that should be logged out.
*/
public warn(...args: unknown[]): (LogObj & ILogObjMeta) | undefined {
return super.log(4, "WARN", ...args);
}
/**
* Logs an error message.
* @param args - Multiple log attributes that should be logged out.
*/
public error(...args: unknown[]): (LogObj & ILogObjMeta) | undefined {
return super.log(5, "ERROR", ...args);
}
/**
* Logs a fatal message.
* @param args - Multiple log attributes that should be logged out.
*/
public fatal(...args: unknown[]): (LogObj & ILogObjMeta) | undefined {
return super.log(6, "FATAL", ...args);
}
/**
* Returns a child logger based on the current instance with inherited settings
*
* @param settings - Overwrite settings inherited from parent logger
* @param logObj - Overwrite logObj for sub-logger
*/
public getSubLogger(settings?: ISettingsParam<LogObj>, logObj?: LogObj): Logger<LogObj> {
return super.getSubLogger(settings, logObj) as Logger<LogObj>;
}
}