@tomjs/logger 1.1.4 → 1.2.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 +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +8 -6
- package/dist/index.mjs +8 -6
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -29,8 +29,7 @@ interface LoggerOptions {
|
|
|
29
29
|
declare class Logger {
|
|
30
30
|
private _opts;
|
|
31
31
|
private _logDir?;
|
|
32
|
-
|
|
33
|
-
constructor(opts?: LoggerOptions);
|
|
32
|
+
constructor(options?: LoggerOptions);
|
|
34
33
|
private initLogDir;
|
|
35
34
|
private format;
|
|
36
35
|
private _writeLog;
|
|
@@ -39,6 +38,10 @@ declare class Logger {
|
|
|
39
38
|
* set debug mode or not
|
|
40
39
|
*/
|
|
41
40
|
enableDebug(debug: boolean): void;
|
|
41
|
+
/**
|
|
42
|
+
* set debug mode or not
|
|
43
|
+
*/
|
|
44
|
+
setOptions(options: LoggerOptions): void;
|
|
42
45
|
/**
|
|
43
46
|
* like console.log
|
|
44
47
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -29,8 +29,7 @@ interface LoggerOptions {
|
|
|
29
29
|
declare class Logger {
|
|
30
30
|
private _opts;
|
|
31
31
|
private _logDir?;
|
|
32
|
-
|
|
33
|
-
constructor(opts?: LoggerOptions);
|
|
32
|
+
constructor(options?: LoggerOptions);
|
|
34
33
|
private initLogDir;
|
|
35
34
|
private format;
|
|
36
35
|
private _writeLog;
|
|
@@ -39,6 +38,10 @@ declare class Logger {
|
|
|
39
38
|
* set debug mode or not
|
|
40
39
|
*/
|
|
41
40
|
enableDebug(debug: boolean): void;
|
|
41
|
+
/**
|
|
42
|
+
* set debug mode or not
|
|
43
|
+
*/
|
|
44
|
+
setOptions(options: LoggerOptions): void;
|
|
42
45
|
/**
|
|
43
46
|
* like console.log
|
|
44
47
|
*/
|
package/dist/index.js
CHANGED
|
@@ -25,11 +25,9 @@ var _logsymbols2 = _interopRequireDefault(_logsymbols);
|
|
|
25
25
|
var _stripansi = require('strip-ansi');
|
|
26
26
|
var _stripansi2 = _interopRequireDefault(_stripansi);
|
|
27
27
|
var Logger = class {
|
|
28
|
-
constructor(
|
|
28
|
+
constructor(options) {
|
|
29
29
|
this._opts = {};
|
|
30
|
-
this.
|
|
31
|
-
this._opts = Object.assign({}, opts);
|
|
32
|
-
this.initLogDir();
|
|
30
|
+
this.setOptions(Object.assign({}, options));
|
|
33
31
|
}
|
|
34
32
|
initLogDir() {
|
|
35
33
|
const { directory, cleanup } = this._opts;
|
|
@@ -86,7 +84,11 @@ var Logger = class {
|
|
|
86
84
|
console.log(list.map(s => (typeof s === 'object' ? '%o' : '%s')).join(' '), ...list);
|
|
87
85
|
}
|
|
88
86
|
enableDebug(debug) {
|
|
89
|
-
this.
|
|
87
|
+
this._opts.debug = !!debug;
|
|
88
|
+
}
|
|
89
|
+
setOptions(options) {
|
|
90
|
+
this._opts = Object.assign({}, options);
|
|
91
|
+
this.initLogDir();
|
|
90
92
|
}
|
|
91
93
|
log(...args) {
|
|
92
94
|
this._log(...args);
|
|
@@ -95,7 +97,7 @@ var Logger = class {
|
|
|
95
97
|
this._writeLog(...args);
|
|
96
98
|
}
|
|
97
99
|
debug(...args) {
|
|
98
|
-
if (this.
|
|
100
|
+
if (this._opts.debug) {
|
|
99
101
|
this._log(
|
|
100
102
|
...args.map(s => {
|
|
101
103
|
if (typeof s !== 'object') {
|
package/dist/index.mjs
CHANGED
|
@@ -6,11 +6,9 @@ import dayjs from 'dayjs';
|
|
|
6
6
|
import logSymbols from 'log-symbols';
|
|
7
7
|
import stripAnsi from 'strip-ansi';
|
|
8
8
|
var Logger = class {
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(options) {
|
|
10
10
|
this._opts = {};
|
|
11
|
-
this.
|
|
12
|
-
this._opts = Object.assign({}, opts);
|
|
13
|
-
this.initLogDir();
|
|
11
|
+
this.setOptions(Object.assign({}, options));
|
|
14
12
|
}
|
|
15
13
|
initLogDir() {
|
|
16
14
|
const { directory, cleanup } = this._opts;
|
|
@@ -57,7 +55,11 @@ var Logger = class {
|
|
|
57
55
|
console.log(list.map(s => (typeof s === 'object' ? '%o' : '%s')).join(' '), ...list);
|
|
58
56
|
}
|
|
59
57
|
enableDebug(debug) {
|
|
60
|
-
this.
|
|
58
|
+
this._opts.debug = !!debug;
|
|
59
|
+
}
|
|
60
|
+
setOptions(options) {
|
|
61
|
+
this._opts = Object.assign({}, options);
|
|
62
|
+
this.initLogDir();
|
|
61
63
|
}
|
|
62
64
|
log(...args) {
|
|
63
65
|
this._log(...args);
|
|
@@ -66,7 +68,7 @@ var Logger = class {
|
|
|
66
68
|
this._writeLog(...args);
|
|
67
69
|
}
|
|
68
70
|
debug(...args) {
|
|
69
|
-
if (this.
|
|
71
|
+
if (this._opts.debug) {
|
|
70
72
|
this._log(
|
|
71
73
|
...args.map(s => {
|
|
72
74
|
if (typeof s !== 'object') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/logger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "logger for `node.js`",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"chalk": "^4.1.2",
|
|
46
|
-
"dayjs": "^1.11.
|
|
46
|
+
"dayjs": "^1.11.13",
|
|
47
47
|
"log-symbols": "^4.1.0",
|
|
48
48
|
"strip-ansi": "^6.0.1"
|
|
49
49
|
},
|