forked from unjs/consola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.ts
129 lines (111 loc) · 2.29 KB
/
constants.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { LogObject } from "./types";
/**
* Defines the level of logs as specific numbers or special number types.
*
* @type {0 | 1 | 2 | 3 | 4 | 5 | (number & {})} LogLevel - Represents the log level.
* @default 0 - Represents the default log level.
*/
export type LogLevel = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
/**
* A mapping of `LogType` to its corresponding numeric log level.
*
* @type {Record<LogType, number>} LogLevels - key-value pairs of log types to their numeric levels. See {@link LogType}.
*/
export const LogLevels: Record<LogType, number> = {
silent: Number.NEGATIVE_INFINITY,
fatal: 0,
error: 0,
warn: 1,
log: 2,
info: 3,
success: 3,
fail: 3,
ready: 3,
start: 3,
box: 3,
debug: 4,
trace: 5,
verbose: Number.POSITIVE_INFINITY,
};
/**
* Lists the types of log messages supported by the system.
*
* @type {"silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose"} LogType - Represents the specific type of log message.
*/
export type LogType =
// 0
| "silent"
| "fatal"
| "error"
// 1
| "warn"
// 2
| "log"
// 3
| "info"
| "success"
| "fail"
| "ready"
| "start"
| "box"
// Verbose
| "debug"
| "trace"
| "verbose";
/**
* Maps `LogType` to a `Partial<LogObject>`, primarily defining the log level.
*
* @type {Record<LogType, Partial<LogObject>>} LogTypes - key-value pairs of log types to partial log objects, specifying log levels. See {@link LogType} and {@link LogObject}.
*/
export const LogTypes: Record<LogType, Partial<LogObject>> = {
// Silent
silent: {
level: -1,
},
// Level 0
fatal: {
level: LogLevels.fatal,
},
error: {
level: LogLevels.error,
},
// Level 1
warn: {
level: LogLevels.warn,
},
// Level 2
log: {
level: LogLevels.log,
},
// Level 3
info: {
level: LogLevels.info,
},
success: {
level: LogLevels.success,
},
fail: {
level: LogLevels.fail,
},
ready: {
level: LogLevels.info,
},
start: {
level: LogLevels.info,
},
box: {
level: LogLevels.info,
},
// Level 4
debug: {
level: LogLevels.debug,
},
// Level 5
trace: {
level: LogLevels.trace,
},
// Verbose
verbose: {
level: LogLevels.verbose,
},
};