forked from SmartThingsCommunity/smartthings-core-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.ts
73 lines (66 loc) · 1.62 KB
/
logger.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
/**
* A generic logger interface that is compatible with log4js. Using this keeps
* dependencies on an external logger out when users don't want to include one.
*/
export interface Logger {
level: string
/* eslint-disable @typescript-eslint/no-explicit-any */
trace(message: any, ...args: any[]): void
debug(message: any, ...args: any[]): void
info(message: any, ...args: any[]): void
warn(message: any, ...args: any[]): void
error(message: any, ...args: any[]): void
fatal(message: any, ...args: any[]): void
/* eslint-enable */
isTraceEnabled(): boolean
isDebugEnabled(): boolean
isInfoEnabled(): boolean
isWarnEnabled(): boolean
isErrorEnabled(): boolean
isFatalEnabled(): boolean
}
/**
* A simple implementation of the Logger interface that does not log anything.
*/
export class NoLogLogger implements Logger {
public level = 'off'
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars */
trace(message: any, ...args: any[]): void {
// no-op
}
debug(message: any, ...args: any[]): void {
// no-op
}
info(message: any, ...args: any[]): void {
// no-op
}
warn(message: any, ...args: any[]): void {
// no-op
}
error(message: any, ...args: any[]): void {
// no-op
}
fatal(message: any, ...args: any[]): void {
// no-op
}
/* eslint-enable */
isTraceEnabled(): boolean {
return false
}
isDebugEnabled(): boolean {
return false
}
isInfoEnabled(): boolean {
return false
}
isWarnEnabled(): boolean {
return false
}
isErrorEnabled(): boolean {
return false
}
isFatalEnabled(): boolean {
return false
}
}
export const noLogLogger = new NoLogLogger()