jet-logger 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/jetLogger.js +58 -58
- package/dist/esm/jetLogger.js +58 -58
- package/dist/types/jetLogger.d.ts +17 -17
- package/package.json +1 -1
package/dist/cjs/jetLogger.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import util from 'util';
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const Modes = {
|
|
5
|
+
CONSOLE: 'console',
|
|
6
|
+
FILE: 'file',
|
|
7
|
+
CUSTOM: 'custom',
|
|
8
|
+
OFF: 'off',
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const Formats = {
|
|
11
|
+
LINE: 'line',
|
|
12
|
+
JSON: 'json',
|
|
13
13
|
};
|
|
14
|
-
const
|
|
14
|
+
const Levels = {
|
|
15
15
|
Info: {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
COLOR: 'green',
|
|
17
|
+
PREFIX: 'INFO',
|
|
18
18
|
},
|
|
19
19
|
Important: {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
COLOR: 'magenta',
|
|
21
|
+
PREFIX: 'IMPORTANT',
|
|
22
22
|
},
|
|
23
23
|
Warning: {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
COLOR: 'yellow',
|
|
25
|
+
PREFIX: 'WARNING',
|
|
26
26
|
},
|
|
27
27
|
Error: {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
COLOR: 'red',
|
|
29
|
+
PREFIX: 'ERROR',
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
const Defaults = {
|
|
33
|
+
MODE: Modes.CONSOLE,
|
|
34
|
+
FILE_PATH: 'jet-logger.log',
|
|
35
|
+
TIMESTAMP: true,
|
|
36
|
+
FORMAT: Formats.LINE,
|
|
37
|
+
CUSTOM_LOGGER_FUNCTION: () => ({}),
|
|
38
38
|
};
|
|
39
39
|
const Errors = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'"
|
|
40
|
+
CUSTOM_LOGGER: 'Custom logger mode set to true, but no custom logger was provided.',
|
|
41
|
+
MODE: 'The correct logger mode was not specified: Must be "custom", "file", ' +
|
|
42
|
+
'"off", or "console".',
|
|
43
43
|
};
|
|
44
44
|
export const JetLogger = {
|
|
45
|
-
Modes
|
|
46
|
-
Formats
|
|
45
|
+
Modes,
|
|
46
|
+
Formats,
|
|
47
47
|
};
|
|
48
48
|
export function jetLogger(options) {
|
|
49
|
-
let mode =
|
|
49
|
+
let mode = Defaults.MODE, filePath = Defaults.FILE_PATH, timestamp = Defaults.TIMESTAMP, format = Defaults.FORMAT, customLogFn = Defaults.CUSTOM_LOGGER_FUNCTION;
|
|
50
50
|
if (options?.mode !== undefined) {
|
|
51
51
|
mode = options.mode;
|
|
52
52
|
}
|
|
53
53
|
else if (!!process.env.JET_LOGGER_MODE) {
|
|
54
|
-
mode = process.env.JET_LOGGER_MODE.
|
|
54
|
+
mode = process.env.JET_LOGGER_MODE.toLowerCase();
|
|
55
55
|
}
|
|
56
|
-
if (mode ===
|
|
56
|
+
if (mode === Modes.OFF) {
|
|
57
57
|
return {
|
|
58
58
|
info: (_, __) => ({}),
|
|
59
59
|
imp: (_, __) => ({}),
|
|
@@ -61,18 +61,18 @@ export function jetLogger(options) {
|
|
|
61
61
|
err: (_, __) => ({}),
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
if (mode ===
|
|
64
|
+
if (mode === Modes.CUSTOM) {
|
|
65
65
|
if (options?.customLogger !== undefined) {
|
|
66
66
|
customLogFn = options.customLogger;
|
|
67
67
|
}
|
|
68
68
|
if (!customLogFn) {
|
|
69
|
-
throw Error(Errors.
|
|
69
|
+
throw Error(Errors.CUSTOM_LOGGER);
|
|
70
70
|
}
|
|
71
71
|
return {
|
|
72
|
-
info: setupPrintWithCustomLogger(
|
|
73
|
-
imp: setupPrintWithCustomLogger(
|
|
74
|
-
warn: setupPrintWithCustomLogger(
|
|
75
|
-
err: setupPrintWithCustomLogger(
|
|
72
|
+
info: setupPrintWithCustomLogger(Levels.Info, customLogFn),
|
|
73
|
+
imp: setupPrintWithCustomLogger(Levels.Important, customLogFn),
|
|
74
|
+
warn: setupPrintWithCustomLogger(Levels.Warning, customLogFn),
|
|
75
|
+
err: setupPrintWithCustomLogger(Levels.Error, customLogFn),
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
if (options?.filepath !== undefined) {
|
|
@@ -86,45 +86,45 @@ export function jetLogger(options) {
|
|
|
86
86
|
}
|
|
87
87
|
else if (!!process.env.JET_LOGGER_TIMESTAMP) {
|
|
88
88
|
const envVar = process.env.JET_LOGGER_TIMESTAMP;
|
|
89
|
-
timestamp = envVar.
|
|
89
|
+
timestamp = envVar.toLowerCase() === 'true';
|
|
90
90
|
}
|
|
91
91
|
if (options?.format !== undefined) {
|
|
92
92
|
format = options.format;
|
|
93
93
|
}
|
|
94
94
|
else if (!!process.env.JET_LOGGER_FORMAT) {
|
|
95
|
-
format = process.env.JET_LOGGER_FORMAT.
|
|
95
|
+
format = process.env.JET_LOGGER_FORMAT.toLowerCase();
|
|
96
96
|
}
|
|
97
97
|
let formatter = () => '';
|
|
98
|
-
if (format ===
|
|
98
|
+
if (format === Formats.LINE) {
|
|
99
99
|
formatter = setupLineFormatter(timestamp);
|
|
100
100
|
}
|
|
101
|
-
else if (format ===
|
|
101
|
+
else if (format === Formats.JSON) {
|
|
102
102
|
formatter = setupJsonFormatter(timestamp);
|
|
103
103
|
}
|
|
104
|
-
if (mode ===
|
|
104
|
+
if (mode === Modes.FILE) {
|
|
105
105
|
let filePathDatetime = true;
|
|
106
106
|
if (options?.filepathDatetimeParam !== undefined) {
|
|
107
107
|
filePathDatetime = options.filepathDatetimeParam;
|
|
108
108
|
}
|
|
109
109
|
else if (!!process.env.JET_LOGGER_FILEPATH_DATETIME) {
|
|
110
110
|
const envVar = process.env.JET_LOGGER_FILEPATH_DATETIME;
|
|
111
|
-
filePathDatetime = envVar.
|
|
111
|
+
filePathDatetime = envVar.toLowerCase() === 'true';
|
|
112
112
|
}
|
|
113
113
|
if (filePathDatetime) {
|
|
114
114
|
filePath = addDatetimeToFileName(filePath);
|
|
115
115
|
}
|
|
116
116
|
return {
|
|
117
|
-
info: setupPrintToFile(
|
|
118
|
-
imp: setupPrintToFile(
|
|
119
|
-
warn: setupPrintToFile(
|
|
120
|
-
err: setupPrintToFile(
|
|
117
|
+
info: setupPrintToFile(Levels.Info, formatter, filePath),
|
|
118
|
+
imp: setupPrintToFile(Levels.Important, formatter, filePath),
|
|
119
|
+
warn: setupPrintToFile(Levels.Warning, formatter, filePath),
|
|
120
|
+
err: setupPrintToFile(Levels.Error, formatter, filePath),
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
return {
|
|
124
|
-
info: setupPrintToConsole(
|
|
125
|
-
imp: setupPrintToConsole(
|
|
126
|
-
warn: setupPrintToConsole(
|
|
127
|
-
err: setupPrintToConsole(
|
|
124
|
+
info: setupPrintToConsole(Levels.Info, formatter),
|
|
125
|
+
imp: setupPrintToConsole(Levels.Important, formatter),
|
|
126
|
+
warn: setupPrintToConsole(Levels.Warning, formatter),
|
|
127
|
+
err: setupPrintToConsole(Levels.Error, formatter),
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
function setupPrintWithCustomLogger(level, customLogFn) {
|
|
@@ -136,19 +136,19 @@ function setupPrintWithCustomLogger(level, customLogFn) {
|
|
|
136
136
|
else {
|
|
137
137
|
contentNew = String(content);
|
|
138
138
|
}
|
|
139
|
-
return customLogFn(new Date(), level.
|
|
139
|
+
return customLogFn(new Date(), level.PREFIX, contentNew);
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
function setupLineFormatter(timestamp) {
|
|
143
143
|
if (timestamp) {
|
|
144
144
|
return (content, level) => {
|
|
145
|
-
const contentNew = level.
|
|
145
|
+
const contentNew = level.PREFIX + ': ' + content, time = '[' + new Date().toISOString() + '] ';
|
|
146
146
|
return time + contentNew;
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
else {
|
|
150
150
|
return (content, level) => {
|
|
151
|
-
return level.
|
|
151
|
+
return level.PREFIX + ': ' + content;
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -156,7 +156,7 @@ function setupJsonFormatter(timestamp) {
|
|
|
156
156
|
if (timestamp) {
|
|
157
157
|
return (content, level) => {
|
|
158
158
|
const json = {
|
|
159
|
-
level: level.
|
|
159
|
+
level: level.PREFIX,
|
|
160
160
|
message: content,
|
|
161
161
|
};
|
|
162
162
|
json.timestamp = new Date().toISOString();
|
|
@@ -166,7 +166,7 @@ function setupJsonFormatter(timestamp) {
|
|
|
166
166
|
else {
|
|
167
167
|
return (content, level) => {
|
|
168
168
|
const json = {
|
|
169
|
-
level: level.
|
|
169
|
+
level: level.PREFIX,
|
|
170
170
|
message: content,
|
|
171
171
|
};
|
|
172
172
|
return JSON.stringify(json);
|
|
@@ -183,7 +183,7 @@ function setupPrintToFile(level, formatter, filePath) {
|
|
|
183
183
|
contentNew = String(content);
|
|
184
184
|
}
|
|
185
185
|
contentNew = formatter(contentNew, level);
|
|
186
|
-
fs.appendFile(filePath, contentNew, (err) => {
|
|
186
|
+
fs.appendFile(filePath, contentNew + '\n', (err) => {
|
|
187
187
|
if (!!err) {
|
|
188
188
|
console.error(err);
|
|
189
189
|
}
|
|
@@ -199,7 +199,7 @@ function setupPrintToConsole(level, formatter) {
|
|
|
199
199
|
else {
|
|
200
200
|
contentNew = String(content);
|
|
201
201
|
}
|
|
202
|
-
const colorFn = colors[level.
|
|
202
|
+
const colorFn = colors[level.COLOR];
|
|
203
203
|
contentNew = formatter(contentNew, level);
|
|
204
204
|
console.log(colorFn(contentNew));
|
|
205
205
|
};
|
package/dist/esm/jetLogger.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import util from 'util';
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const Modes = {
|
|
5
|
+
CONSOLE: 'console',
|
|
6
|
+
FILE: 'file',
|
|
7
|
+
CUSTOM: 'custom',
|
|
8
|
+
OFF: 'off',
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const Formats = {
|
|
11
|
+
LINE: 'line',
|
|
12
|
+
JSON: 'json',
|
|
13
13
|
};
|
|
14
|
-
const
|
|
14
|
+
const Levels = {
|
|
15
15
|
Info: {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
COLOR: 'green',
|
|
17
|
+
PREFIX: 'INFO',
|
|
18
18
|
},
|
|
19
19
|
Important: {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
COLOR: 'magenta',
|
|
21
|
+
PREFIX: 'IMPORTANT',
|
|
22
22
|
},
|
|
23
23
|
Warning: {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
COLOR: 'yellow',
|
|
25
|
+
PREFIX: 'WARNING',
|
|
26
26
|
},
|
|
27
27
|
Error: {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
COLOR: 'red',
|
|
29
|
+
PREFIX: 'ERROR',
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
const Defaults = {
|
|
33
|
+
MODE: Modes.CONSOLE,
|
|
34
|
+
FILE_PATH: 'jet-logger.log',
|
|
35
|
+
TIMESTAMP: true,
|
|
36
|
+
FORMAT: Formats.LINE,
|
|
37
|
+
CUSTOM_LOGGER_FUNCTION: () => ({}),
|
|
38
38
|
};
|
|
39
39
|
const Errors = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'"
|
|
40
|
+
CUSTOM_LOGGER: 'Custom logger mode set to true, but no custom logger was provided.',
|
|
41
|
+
MODE: 'The correct logger mode was not specified: Must be "custom", "file", ' +
|
|
42
|
+
'"off", or "console".',
|
|
43
43
|
};
|
|
44
44
|
export const JetLogger = {
|
|
45
|
-
Modes
|
|
46
|
-
Formats
|
|
45
|
+
Modes,
|
|
46
|
+
Formats,
|
|
47
47
|
};
|
|
48
48
|
export function jetLogger(options) {
|
|
49
|
-
let mode =
|
|
49
|
+
let mode = Defaults.MODE, filePath = Defaults.FILE_PATH, timestamp = Defaults.TIMESTAMP, format = Defaults.FORMAT, customLogFn = Defaults.CUSTOM_LOGGER_FUNCTION;
|
|
50
50
|
if (options?.mode !== undefined) {
|
|
51
51
|
mode = options.mode;
|
|
52
52
|
}
|
|
53
53
|
else if (!!process.env.JET_LOGGER_MODE) {
|
|
54
|
-
mode = process.env.JET_LOGGER_MODE.
|
|
54
|
+
mode = process.env.JET_LOGGER_MODE.toLowerCase();
|
|
55
55
|
}
|
|
56
|
-
if (mode ===
|
|
56
|
+
if (mode === Modes.OFF) {
|
|
57
57
|
return {
|
|
58
58
|
info: (_, __) => ({}),
|
|
59
59
|
imp: (_, __) => ({}),
|
|
@@ -61,18 +61,18 @@ export function jetLogger(options) {
|
|
|
61
61
|
err: (_, __) => ({}),
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
if (mode ===
|
|
64
|
+
if (mode === Modes.CUSTOM) {
|
|
65
65
|
if (options?.customLogger !== undefined) {
|
|
66
66
|
customLogFn = options.customLogger;
|
|
67
67
|
}
|
|
68
68
|
if (!customLogFn) {
|
|
69
|
-
throw Error(Errors.
|
|
69
|
+
throw Error(Errors.CUSTOM_LOGGER);
|
|
70
70
|
}
|
|
71
71
|
return {
|
|
72
|
-
info: setupPrintWithCustomLogger(
|
|
73
|
-
imp: setupPrintWithCustomLogger(
|
|
74
|
-
warn: setupPrintWithCustomLogger(
|
|
75
|
-
err: setupPrintWithCustomLogger(
|
|
72
|
+
info: setupPrintWithCustomLogger(Levels.Info, customLogFn),
|
|
73
|
+
imp: setupPrintWithCustomLogger(Levels.Important, customLogFn),
|
|
74
|
+
warn: setupPrintWithCustomLogger(Levels.Warning, customLogFn),
|
|
75
|
+
err: setupPrintWithCustomLogger(Levels.Error, customLogFn),
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
if (options?.filepath !== undefined) {
|
|
@@ -86,45 +86,45 @@ export function jetLogger(options) {
|
|
|
86
86
|
}
|
|
87
87
|
else if (!!process.env.JET_LOGGER_TIMESTAMP) {
|
|
88
88
|
const envVar = process.env.JET_LOGGER_TIMESTAMP;
|
|
89
|
-
timestamp = envVar.
|
|
89
|
+
timestamp = envVar.toLowerCase() === 'true';
|
|
90
90
|
}
|
|
91
91
|
if (options?.format !== undefined) {
|
|
92
92
|
format = options.format;
|
|
93
93
|
}
|
|
94
94
|
else if (!!process.env.JET_LOGGER_FORMAT) {
|
|
95
|
-
format = process.env.JET_LOGGER_FORMAT.
|
|
95
|
+
format = process.env.JET_LOGGER_FORMAT.toLowerCase();
|
|
96
96
|
}
|
|
97
97
|
let formatter = () => '';
|
|
98
|
-
if (format ===
|
|
98
|
+
if (format === Formats.LINE) {
|
|
99
99
|
formatter = setupLineFormatter(timestamp);
|
|
100
100
|
}
|
|
101
|
-
else if (format ===
|
|
101
|
+
else if (format === Formats.JSON) {
|
|
102
102
|
formatter = setupJsonFormatter(timestamp);
|
|
103
103
|
}
|
|
104
|
-
if (mode ===
|
|
104
|
+
if (mode === Modes.FILE) {
|
|
105
105
|
let filePathDatetime = true;
|
|
106
106
|
if (options?.filepathDatetimeParam !== undefined) {
|
|
107
107
|
filePathDatetime = options.filepathDatetimeParam;
|
|
108
108
|
}
|
|
109
109
|
else if (!!process.env.JET_LOGGER_FILEPATH_DATETIME) {
|
|
110
110
|
const envVar = process.env.JET_LOGGER_FILEPATH_DATETIME;
|
|
111
|
-
filePathDatetime = envVar.
|
|
111
|
+
filePathDatetime = envVar.toLowerCase() === 'true';
|
|
112
112
|
}
|
|
113
113
|
if (filePathDatetime) {
|
|
114
114
|
filePath = addDatetimeToFileName(filePath);
|
|
115
115
|
}
|
|
116
116
|
return {
|
|
117
|
-
info: setupPrintToFile(
|
|
118
|
-
imp: setupPrintToFile(
|
|
119
|
-
warn: setupPrintToFile(
|
|
120
|
-
err: setupPrintToFile(
|
|
117
|
+
info: setupPrintToFile(Levels.Info, formatter, filePath),
|
|
118
|
+
imp: setupPrintToFile(Levels.Important, formatter, filePath),
|
|
119
|
+
warn: setupPrintToFile(Levels.Warning, formatter, filePath),
|
|
120
|
+
err: setupPrintToFile(Levels.Error, formatter, filePath),
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
return {
|
|
124
|
-
info: setupPrintToConsole(
|
|
125
|
-
imp: setupPrintToConsole(
|
|
126
|
-
warn: setupPrintToConsole(
|
|
127
|
-
err: setupPrintToConsole(
|
|
124
|
+
info: setupPrintToConsole(Levels.Info, formatter),
|
|
125
|
+
imp: setupPrintToConsole(Levels.Important, formatter),
|
|
126
|
+
warn: setupPrintToConsole(Levels.Warning, formatter),
|
|
127
|
+
err: setupPrintToConsole(Levels.Error, formatter),
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
function setupPrintWithCustomLogger(level, customLogFn) {
|
|
@@ -136,19 +136,19 @@ function setupPrintWithCustomLogger(level, customLogFn) {
|
|
|
136
136
|
else {
|
|
137
137
|
contentNew = String(content);
|
|
138
138
|
}
|
|
139
|
-
return customLogFn(new Date(), level.
|
|
139
|
+
return customLogFn(new Date(), level.PREFIX, contentNew);
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
function setupLineFormatter(timestamp) {
|
|
143
143
|
if (timestamp) {
|
|
144
144
|
return (content, level) => {
|
|
145
|
-
const contentNew = level.
|
|
145
|
+
const contentNew = level.PREFIX + ': ' + content, time = '[' + new Date().toISOString() + '] ';
|
|
146
146
|
return time + contentNew;
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
else {
|
|
150
150
|
return (content, level) => {
|
|
151
|
-
return level.
|
|
151
|
+
return level.PREFIX + ': ' + content;
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -156,7 +156,7 @@ function setupJsonFormatter(timestamp) {
|
|
|
156
156
|
if (timestamp) {
|
|
157
157
|
return (content, level) => {
|
|
158
158
|
const json = {
|
|
159
|
-
level: level.
|
|
159
|
+
level: level.PREFIX,
|
|
160
160
|
message: content,
|
|
161
161
|
};
|
|
162
162
|
json.timestamp = new Date().toISOString();
|
|
@@ -166,7 +166,7 @@ function setupJsonFormatter(timestamp) {
|
|
|
166
166
|
else {
|
|
167
167
|
return (content, level) => {
|
|
168
168
|
const json = {
|
|
169
|
-
level: level.
|
|
169
|
+
level: level.PREFIX,
|
|
170
170
|
message: content,
|
|
171
171
|
};
|
|
172
172
|
return JSON.stringify(json);
|
|
@@ -183,7 +183,7 @@ function setupPrintToFile(level, formatter, filePath) {
|
|
|
183
183
|
contentNew = String(content);
|
|
184
184
|
}
|
|
185
185
|
contentNew = formatter(contentNew, level);
|
|
186
|
-
fs.appendFile(filePath, contentNew, (err) => {
|
|
186
|
+
fs.appendFile(filePath, contentNew + '\n', (err) => {
|
|
187
187
|
if (!!err) {
|
|
188
188
|
console.error(err);
|
|
189
189
|
}
|
|
@@ -199,7 +199,7 @@ function setupPrintToConsole(level, formatter) {
|
|
|
199
199
|
else {
|
|
200
200
|
contentNew = String(content);
|
|
201
201
|
}
|
|
202
|
-
const colorFn = colors[level.
|
|
202
|
+
const colorFn = colors[level.COLOR];
|
|
203
203
|
contentNew = formatter(contentNew, level);
|
|
204
204
|
console.log(colorFn(contentNew));
|
|
205
205
|
};
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
/******************************************************************************
|
|
2
2
|
Constants
|
|
3
3
|
******************************************************************************/
|
|
4
|
-
declare const
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
4
|
+
declare const Modes: {
|
|
5
|
+
readonly CONSOLE: "console";
|
|
6
|
+
readonly FILE: "file";
|
|
7
|
+
readonly CUSTOM: "custom";
|
|
8
|
+
readonly OFF: "off";
|
|
9
9
|
};
|
|
10
|
-
declare const
|
|
11
|
-
readonly
|
|
12
|
-
readonly
|
|
10
|
+
declare const Formats: {
|
|
11
|
+
readonly LINE: "line";
|
|
12
|
+
readonly JSON: "json";
|
|
13
13
|
};
|
|
14
14
|
export declare const JetLogger: {
|
|
15
15
|
readonly Modes: {
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
16
|
+
readonly CONSOLE: "console";
|
|
17
|
+
readonly FILE: "file";
|
|
18
|
+
readonly CUSTOM: "custom";
|
|
19
|
+
readonly OFF: "off";
|
|
20
20
|
};
|
|
21
21
|
readonly Formats: {
|
|
22
|
-
readonly
|
|
23
|
-
readonly
|
|
22
|
+
readonly LINE: "line";
|
|
23
|
+
readonly JSON: "json";
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
/******************************************************************************
|
|
27
27
|
Types
|
|
28
28
|
******************************************************************************/
|
|
29
|
-
type
|
|
30
|
-
type Formats = (typeof
|
|
29
|
+
type Modes = (typeof Modes)[keyof typeof Modes];
|
|
30
|
+
type Formats = (typeof Formats)[keyof typeof Formats];
|
|
31
31
|
type LogFunction = (content: unknown, printFull?: boolean) => void;
|
|
32
32
|
export type CustomLogger = (timestamp: Date, prefix: string, content: unknown) => void;
|
|
33
33
|
interface Options {
|
|
34
|
-
mode?:
|
|
34
|
+
mode?: Modes;
|
|
35
35
|
filepath?: string;
|
|
36
36
|
filepathDatetimeParam?: boolean;
|
|
37
37
|
timestamp?: boolean;
|