@tomjs/logger 1.0.0 → 1.1.0
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/index.d.mts +72 -75
- package/dist/index.d.ts +72 -75
- package/dist/index.js +68 -60
- package/dist/index.mjs +28 -50
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,75 +1,72 @@
|
|
|
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
|
-
export { }
|
|
1
|
+
interface LoggerOptions {
|
|
2
|
+
/**
|
|
3
|
+
* log prefix
|
|
4
|
+
*/
|
|
5
|
+
prefix?: string;
|
|
6
|
+
/**
|
|
7
|
+
* enable debug mode
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* show time in log
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
time?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* specify the log directory name
|
|
18
|
+
*/
|
|
19
|
+
directory?: string;
|
|
20
|
+
/**
|
|
21
|
+
* specify the log cleanup period
|
|
22
|
+
* @default 30
|
|
23
|
+
*/
|
|
24
|
+
cleanup?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* log tool
|
|
28
|
+
*/
|
|
29
|
+
declare class Logger {
|
|
30
|
+
private _opts;
|
|
31
|
+
private _logDir?;
|
|
32
|
+
private _debug;
|
|
33
|
+
constructor(opts?: LoggerOptions);
|
|
34
|
+
private initLogDir;
|
|
35
|
+
private format;
|
|
36
|
+
private _writeLog;
|
|
37
|
+
private _log;
|
|
38
|
+
/**
|
|
39
|
+
* set debug mode or not
|
|
40
|
+
*/
|
|
41
|
+
enableDebug(debug: boolean): void;
|
|
42
|
+
/**
|
|
43
|
+
* like console.log
|
|
44
|
+
*/
|
|
45
|
+
log(...args: any[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* write log to file
|
|
48
|
+
*/
|
|
49
|
+
write(...args: any[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* only show in debug mode
|
|
52
|
+
*/
|
|
53
|
+
debug(...args: any[]): void;
|
|
54
|
+
/**
|
|
55
|
+
* add the specified red prefix or error symbol before the log content
|
|
56
|
+
*/
|
|
57
|
+
error(...args: any[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* add the specified blue prefix or info symbol before the log content
|
|
60
|
+
*/
|
|
61
|
+
info(...args: any[]): void;
|
|
62
|
+
/**
|
|
63
|
+
* add the specified green prefix or success symbol before the log content
|
|
64
|
+
*/
|
|
65
|
+
success(...args: any[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* add the specified yellow prefix or warning symbol before the log content
|
|
68
|
+
*/
|
|
69
|
+
warning(...args: any[]): void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { Logger, type LoggerOptions, Logger as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,75 +1,72 @@
|
|
|
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
|
-
export { }
|
|
1
|
+
interface LoggerOptions {
|
|
2
|
+
/**
|
|
3
|
+
* log prefix
|
|
4
|
+
*/
|
|
5
|
+
prefix?: string;
|
|
6
|
+
/**
|
|
7
|
+
* enable debug mode
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* show time in log
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
time?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* specify the log directory name
|
|
18
|
+
*/
|
|
19
|
+
directory?: string;
|
|
20
|
+
/**
|
|
21
|
+
* specify the log cleanup period
|
|
22
|
+
* @default 30
|
|
23
|
+
*/
|
|
24
|
+
cleanup?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* log tool
|
|
28
|
+
*/
|
|
29
|
+
declare class Logger {
|
|
30
|
+
private _opts;
|
|
31
|
+
private _logDir?;
|
|
32
|
+
private _debug;
|
|
33
|
+
constructor(opts?: LoggerOptions);
|
|
34
|
+
private initLogDir;
|
|
35
|
+
private format;
|
|
36
|
+
private _writeLog;
|
|
37
|
+
private _log;
|
|
38
|
+
/**
|
|
39
|
+
* set debug mode or not
|
|
40
|
+
*/
|
|
41
|
+
enableDebug(debug: boolean): void;
|
|
42
|
+
/**
|
|
43
|
+
* like console.log
|
|
44
|
+
*/
|
|
45
|
+
log(...args: any[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* write log to file
|
|
48
|
+
*/
|
|
49
|
+
write(...args: any[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* only show in debug mode
|
|
52
|
+
*/
|
|
53
|
+
debug(...args: any[]): void;
|
|
54
|
+
/**
|
|
55
|
+
* add the specified red prefix or error symbol before the log content
|
|
56
|
+
*/
|
|
57
|
+
error(...args: any[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* add the specified blue prefix or info symbol before the log content
|
|
60
|
+
*/
|
|
61
|
+
info(...args: any[]): void;
|
|
62
|
+
/**
|
|
63
|
+
* add the specified green prefix or success symbol before the log content
|
|
64
|
+
*/
|
|
65
|
+
success(...args: any[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* add the specified yellow prefix or warning symbol before the log content
|
|
68
|
+
*/
|
|
69
|
+
warning(...args: any[]): void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { Logger, type LoggerOptions, Logger as default };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
function _interopRequireDefault(obj) {
|
|
4
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
5
|
+
}
|
|
6
|
+
function _nullishCoalesce(lhs, rhsFn) {
|
|
7
|
+
if (lhs != null) {
|
|
8
|
+
return lhs;
|
|
9
|
+
} else {
|
|
10
|
+
return rhsFn();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
var _fs = require('fs');
|
|
14
|
+
var _fs2 = _interopRequireDefault(_fs);
|
|
15
|
+
var _os = require('os');
|
|
16
|
+
var _os2 = _interopRequireDefault(_os);
|
|
17
|
+
var _path = require('path');
|
|
18
|
+
var _path2 = _interopRequireDefault(_path);
|
|
19
|
+
var _chalk = require('chalk');
|
|
20
|
+
var _chalk2 = _interopRequireDefault(_chalk);
|
|
21
|
+
var _dayjs = require('dayjs');
|
|
22
|
+
var _dayjs2 = _interopRequireDefault(_dayjs);
|
|
23
|
+
var _logsymbols = require('log-symbols');
|
|
24
|
+
var _logsymbols2 = _interopRequireDefault(_logsymbols);
|
|
25
|
+
var _stripansi = require('strip-ansi');
|
|
26
|
+
var _stripansi2 = _interopRequireDefault(_stripansi);
|
|
27
|
+
var Logger = class {
|
|
11
28
|
constructor(opts) {
|
|
12
29
|
this._opts = {};
|
|
13
30
|
this._debug = false;
|
|
@@ -19,102 +36,93 @@ class Logger {
|
|
|
19
36
|
if (!directory) {
|
|
20
37
|
return;
|
|
21
38
|
}
|
|
22
|
-
const logDir =
|
|
39
|
+
const logDir = _path2.default.join(_os2.default.homedir(), '.tomjs', directory);
|
|
23
40
|
this._logDir = logDir;
|
|
24
|
-
if (!
|
|
25
|
-
|
|
41
|
+
if (!_fs2.default.existsSync(logDir)) {
|
|
42
|
+
_fs2.default.mkdirSync(logDir, { recursive: true });
|
|
26
43
|
}
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
_fs2.default.readdirSync(logDir).forEach(s => {
|
|
45
|
+
if (
|
|
46
|
+
_dayjs2.default.call(void 0, s.substring(0, 8)).isBefore(
|
|
47
|
+
_dayjs2.default
|
|
48
|
+
.call(void 0)
|
|
49
|
+
.endOf('day')
|
|
50
|
+
.subtract(
|
|
51
|
+
Math.max(
|
|
52
|
+
1,
|
|
53
|
+
_nullishCoalesce(cleanup, () => 30),
|
|
54
|
+
),
|
|
55
|
+
'day',
|
|
56
|
+
),
|
|
57
|
+
)
|
|
58
|
+
) {
|
|
59
|
+
_fs2.default.rmSync(_path2.default.join(logDir, s), { force: true });
|
|
32
60
|
}
|
|
33
61
|
});
|
|
34
62
|
}
|
|
35
63
|
format(...args) {
|
|
36
|
-
return args.map(
|
|
64
|
+
return args.map(s => (typeof s === 'object' ? JSON.stringify(s) : s || '')).join(' ');
|
|
37
65
|
}
|
|
38
66
|
_writeLog(...args) {
|
|
39
67
|
if (!this._logDir) {
|
|
40
68
|
return;
|
|
41
69
|
}
|
|
42
|
-
const logFile =
|
|
43
|
-
|
|
70
|
+
const logFile = _path2.default.join(
|
|
71
|
+
this._logDir,
|
|
72
|
+
`${_dayjs2.default.call(void 0).format('YYYYMMDD')}.log`,
|
|
73
|
+
);
|
|
74
|
+
_fs2.default.appendFileSync(
|
|
44
75
|
logFile,
|
|
45
|
-
`${
|
|
46
|
-
|
|
76
|
+
`${_dayjs2.default.call(void 0).format('YYYY-MM-DD HH:mm:ss.SSS')} ${_stripansi2.default.call(void 0, this.format(...args))}
|
|
77
|
+
`,
|
|
47
78
|
);
|
|
48
79
|
}
|
|
49
80
|
_log(...args) {
|
|
50
81
|
this._writeLog(...args);
|
|
51
82
|
let list = [...args];
|
|
52
83
|
if (this._opts.time) {
|
|
53
|
-
list = [
|
|
84
|
+
list = [_dayjs2.default.call(void 0).format('HH:mm:ss'), ...list];
|
|
54
85
|
}
|
|
55
|
-
console.log(list.map(
|
|
86
|
+
console.log(list.map(s => (typeof s === 'object' ? '%o' : '%s')).join(' '), ...list);
|
|
56
87
|
}
|
|
57
|
-
/**
|
|
58
|
-
* set debug mode or not
|
|
59
|
-
*/
|
|
60
88
|
enableDebug(debug) {
|
|
61
|
-
this._debug = debug
|
|
89
|
+
this._debug = _nullishCoalesce(debug, () => true);
|
|
62
90
|
}
|
|
63
|
-
/**
|
|
64
|
-
* like console.log
|
|
65
|
-
*/
|
|
66
91
|
log(...args) {
|
|
67
92
|
this._log(...args);
|
|
68
93
|
}
|
|
69
|
-
/**
|
|
70
|
-
* write log to file
|
|
71
|
-
*/
|
|
72
94
|
write(...args) {
|
|
73
95
|
this._writeLog(...args);
|
|
74
96
|
}
|
|
75
|
-
/**
|
|
76
|
-
* only show in debug mode
|
|
77
|
-
*/
|
|
78
97
|
debug(...args) {
|
|
79
98
|
if (this._debug) {
|
|
80
99
|
this._log(
|
|
81
|
-
...args.map(
|
|
82
|
-
if (typeof s !==
|
|
83
|
-
return
|
|
100
|
+
...args.map(s => {
|
|
101
|
+
if (typeof s !== 'object') {
|
|
102
|
+
return _chalk2.default.gray(s);
|
|
84
103
|
}
|
|
85
104
|
return s;
|
|
86
|
-
})
|
|
105
|
+
}),
|
|
87
106
|
);
|
|
88
107
|
}
|
|
89
108
|
}
|
|
90
|
-
/**
|
|
91
|
-
* add the specified red prefix or error symbol before the log content
|
|
92
|
-
*/
|
|
93
109
|
error(...args) {
|
|
94
110
|
const { prefix } = this._opts;
|
|
95
|
-
this._log(prefix ?
|
|
111
|
+
this._log(prefix ? _chalk2.default.red(prefix) : _logsymbols2.default.error, ...args);
|
|
96
112
|
}
|
|
97
|
-
/**
|
|
98
|
-
* add the specified blue prefix or info symbol before the log content
|
|
99
|
-
*/
|
|
100
113
|
info(...args) {
|
|
101
114
|
const { prefix } = this._opts;
|
|
102
|
-
this._log(prefix ?
|
|
115
|
+
this._log(prefix ? _chalk2.default.blue(prefix) : _logsymbols2.default.info, ...args);
|
|
103
116
|
}
|
|
104
|
-
/**
|
|
105
|
-
* add the specified green prefix or success symbol before the log content
|
|
106
|
-
*/
|
|
107
117
|
success(...args) {
|
|
108
118
|
const { prefix } = this._opts;
|
|
109
|
-
this._log(prefix ?
|
|
119
|
+
this._log(prefix ? _chalk2.default.green(prefix) : _logsymbols2.default.success, ...args);
|
|
110
120
|
}
|
|
111
|
-
/**
|
|
112
|
-
* add the specified yellow prefix or warning symbol before the log content
|
|
113
|
-
*/
|
|
114
121
|
warning(...args) {
|
|
115
122
|
const { prefix } = this._opts;
|
|
116
|
-
this._log(prefix ?
|
|
123
|
+
this._log(prefix ? _chalk2.default.yellow(prefix) : _logsymbols2.default.warning, ...args);
|
|
117
124
|
}
|
|
118
|
-
}
|
|
125
|
+
};
|
|
126
|
+
var src_default = Logger;
|
|
119
127
|
exports.Logger = Logger;
|
|
120
|
-
exports.default =
|
|
128
|
+
exports.default = src_default;
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import os from
|
|
3
|
-
import path from
|
|
4
|
-
import chalk from
|
|
5
|
-
import dayjs from
|
|
6
|
-
import logSymbols from
|
|
7
|
-
import stripAnsi from
|
|
8
|
-
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import dayjs from 'dayjs';
|
|
6
|
+
import logSymbols from 'log-symbols';
|
|
7
|
+
import stripAnsi from 'strip-ansi';
|
|
8
|
+
var Logger = class {
|
|
9
9
|
constructor(opts) {
|
|
10
10
|
this._opts = {};
|
|
11
11
|
this._debug = false;
|
|
@@ -17,104 +17,82 @@ class Logger {
|
|
|
17
17
|
if (!directory) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
const logDir = path.join(os.homedir(),
|
|
20
|
+
const logDir = path.join(os.homedir(), '.tomjs', directory);
|
|
21
21
|
this._logDir = logDir;
|
|
22
22
|
if (!fs.existsSync(logDir)) {
|
|
23
23
|
fs.mkdirSync(logDir, { recursive: true });
|
|
24
24
|
}
|
|
25
|
-
fs.readdirSync(logDir).forEach(
|
|
26
|
-
if (
|
|
27
|
-
dayjs(
|
|
28
|
-
|
|
25
|
+
fs.readdirSync(logDir).forEach(s => {
|
|
26
|
+
if (
|
|
27
|
+
dayjs(s.substring(0, 8)).isBefore(
|
|
28
|
+
dayjs()
|
|
29
|
+
.endOf('day')
|
|
30
|
+
.subtract(Math.max(1, cleanup ?? 30), 'day'),
|
|
31
|
+
)
|
|
32
|
+
) {
|
|
29
33
|
fs.rmSync(path.join(logDir, s), { force: true });
|
|
30
34
|
}
|
|
31
35
|
});
|
|
32
36
|
}
|
|
33
37
|
format(...args) {
|
|
34
|
-
return args.map(
|
|
38
|
+
return args.map(s => (typeof s === 'object' ? JSON.stringify(s) : s || '')).join(' ');
|
|
35
39
|
}
|
|
36
40
|
_writeLog(...args) {
|
|
37
41
|
if (!this._logDir) {
|
|
38
42
|
return;
|
|
39
43
|
}
|
|
40
|
-
const logFile = path.join(this._logDir, `${dayjs().format(
|
|
44
|
+
const logFile = path.join(this._logDir, `${dayjs().format('YYYYMMDD')}.log`);
|
|
41
45
|
fs.appendFileSync(
|
|
42
46
|
logFile,
|
|
43
|
-
`${dayjs().format(
|
|
44
|
-
|
|
47
|
+
`${dayjs().format('YYYY-MM-DD HH:mm:ss.SSS')} ${stripAnsi(this.format(...args))}
|
|
48
|
+
`,
|
|
45
49
|
);
|
|
46
50
|
}
|
|
47
51
|
_log(...args) {
|
|
48
52
|
this._writeLog(...args);
|
|
49
53
|
let list = [...args];
|
|
50
54
|
if (this._opts.time) {
|
|
51
|
-
list = [dayjs().format(
|
|
55
|
+
list = [dayjs().format('HH:mm:ss'), ...list];
|
|
52
56
|
}
|
|
53
|
-
console.log(list.map(
|
|
57
|
+
console.log(list.map(s => (typeof s === 'object' ? '%o' : '%s')).join(' '), ...list);
|
|
54
58
|
}
|
|
55
|
-
/**
|
|
56
|
-
* set debug mode or not
|
|
57
|
-
*/
|
|
58
59
|
enableDebug(debug) {
|
|
59
60
|
this._debug = debug ?? true;
|
|
60
61
|
}
|
|
61
|
-
/**
|
|
62
|
-
* like console.log
|
|
63
|
-
*/
|
|
64
62
|
log(...args) {
|
|
65
63
|
this._log(...args);
|
|
66
64
|
}
|
|
67
|
-
/**
|
|
68
|
-
* write log to file
|
|
69
|
-
*/
|
|
70
65
|
write(...args) {
|
|
71
66
|
this._writeLog(...args);
|
|
72
67
|
}
|
|
73
|
-
/**
|
|
74
|
-
* only show in debug mode
|
|
75
|
-
*/
|
|
76
68
|
debug(...args) {
|
|
77
69
|
if (this._debug) {
|
|
78
70
|
this._log(
|
|
79
|
-
...args.map(
|
|
80
|
-
if (typeof s !==
|
|
71
|
+
...args.map(s => {
|
|
72
|
+
if (typeof s !== 'object') {
|
|
81
73
|
return chalk.gray(s);
|
|
82
74
|
}
|
|
83
75
|
return s;
|
|
84
|
-
})
|
|
76
|
+
}),
|
|
85
77
|
);
|
|
86
78
|
}
|
|
87
79
|
}
|
|
88
|
-
/**
|
|
89
|
-
* add the specified red prefix or error symbol before the log content
|
|
90
|
-
*/
|
|
91
80
|
error(...args) {
|
|
92
81
|
const { prefix } = this._opts;
|
|
93
82
|
this._log(prefix ? chalk.red(prefix) : logSymbols.error, ...args);
|
|
94
83
|
}
|
|
95
|
-
/**
|
|
96
|
-
* add the specified blue prefix or info symbol before the log content
|
|
97
|
-
*/
|
|
98
84
|
info(...args) {
|
|
99
85
|
const { prefix } = this._opts;
|
|
100
86
|
this._log(prefix ? chalk.blue(prefix) : logSymbols.info, ...args);
|
|
101
87
|
}
|
|
102
|
-
/**
|
|
103
|
-
* add the specified green prefix or success symbol before the log content
|
|
104
|
-
*/
|
|
105
88
|
success(...args) {
|
|
106
89
|
const { prefix } = this._opts;
|
|
107
90
|
this._log(prefix ? chalk.green(prefix) : logSymbols.success, ...args);
|
|
108
91
|
}
|
|
109
|
-
/**
|
|
110
|
-
* add the specified yellow prefix or warning symbol before the log content
|
|
111
|
-
*/
|
|
112
92
|
warning(...args) {
|
|
113
93
|
const { prefix } = this._opts;
|
|
114
94
|
this._log(prefix ? chalk.yellow(prefix) : logSymbols.warning, ...args);
|
|
115
95
|
}
|
|
116
|
-
}
|
|
117
|
-
export {
|
|
118
|
-
Logger,
|
|
119
|
-
Logger as default
|
|
120
96
|
};
|
|
97
|
+
var src_default = Logger;
|
|
98
|
+
export { Logger, src_default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/logger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "logger for `node.js`",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"strip-ansi": "^6.0.1"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
|
-
"build": "
|
|
51
|
+
"build": "tsup && prettier --write ./dist",
|
|
52
52
|
"test": "vitest"
|
|
53
53
|
}
|
|
54
54
|
}
|