@skax/logger 0.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/LICENSE +21 -0
- package/README.md +15 -0
- package/index.js +190 -0
- package/index.umd.js +196 -0
- package/package.json +25 -0
- package/types/index.d.ts +98 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Shine Shao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## @skax/logger
|
|
2
|
+
|
|
3
|
+
   
|
|
4
|
+
|
|
5
|
+
### Usage
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
yarn add @skax/logger
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import Logger from '@skax/logger';
|
|
13
|
+
|
|
14
|
+
Logger.v('console.log print');
|
|
15
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* @skax/logger.js v0.1.0
|
|
4
|
+
* Copyright (c) 2023-7-15 ShineShao <xiaoshaoqq@gmail.com>
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
function __spreadArray(to, from, pack) {
|
|
11
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
12
|
+
if (ar || !(i in from)) {
|
|
13
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
14
|
+
ar[i] = from[i];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18
|
+
}
|
|
19
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
20
|
+
var e = new Error(message);
|
|
21
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @class Logger class
|
|
26
|
+
* @classdesc Provide multiple log printing methods
|
|
27
|
+
*/
|
|
28
|
+
var Logger = /** @class */ (function () {
|
|
29
|
+
function Logger() {
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @description Static method used to print error logs
|
|
33
|
+
* @static
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* Logger.e("error message") // [LOGGER ERROR] > error message
|
|
37
|
+
*
|
|
38
|
+
* @param {...any[]} args error messages
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
41
|
+
Logger.e = function () {
|
|
42
|
+
var arguments$1 = arguments;
|
|
43
|
+
|
|
44
|
+
var args = [];
|
|
45
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
46
|
+
args[_i] = arguments$1[_i];
|
|
47
|
+
}
|
|
48
|
+
if (Logger.LOGGER_LEVEL <= 4)
|
|
49
|
+
{ Logger.HIDE_TAG
|
|
50
|
+
? console.error.apply(console, args) : console.error.apply(console, __spreadArray(["%c[".concat(Logger.TAG, " ERROR]"), 'background: red; color: #fff'], args, false)); }
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* @description Static method used to print warn logs
|
|
54
|
+
* @static
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* Logger.w("warn message") // [LOGGER WARN] > warn message
|
|
58
|
+
*
|
|
59
|
+
* @param {...any[]} args warn messages
|
|
60
|
+
* @returns {void}
|
|
61
|
+
*/
|
|
62
|
+
Logger.w = function () {
|
|
63
|
+
var arguments$1 = arguments;
|
|
64
|
+
|
|
65
|
+
var args = [];
|
|
66
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
67
|
+
args[_i] = arguments$1[_i];
|
|
68
|
+
}
|
|
69
|
+
if (Logger.LOGGER_LEVEL <= 3)
|
|
70
|
+
{ Logger.HIDE_TAG
|
|
71
|
+
? console.warn.apply(console, args) : console.warn.apply(console, __spreadArray(["%c[".concat(Logger.TAG, " WARN]"), 'background: #faad14; color: #fff'], args, false)); }
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* @description Static method used to print info logs
|
|
75
|
+
* @static
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* Logger.i("info message") // [LOGGER INFO] > info message
|
|
79
|
+
*
|
|
80
|
+
* @param {...any[]} args info messages
|
|
81
|
+
* @returns {void}
|
|
82
|
+
*/
|
|
83
|
+
Logger.i = function () {
|
|
84
|
+
var arguments$1 = arguments;
|
|
85
|
+
|
|
86
|
+
var args = [];
|
|
87
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
88
|
+
args[_i] = arguments$1[_i];
|
|
89
|
+
}
|
|
90
|
+
if (Logger.LOGGER_LEVEL <= 2)
|
|
91
|
+
{ Logger.HIDE_TAG
|
|
92
|
+
? console.info.apply(console, args) : console.info.apply(console, __spreadArray(["%c[".concat(Logger.TAG, " INFO]"), 'background: #ffe58f; color: #fff'], args, false)); }
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* @description Static method used to print verbose logs
|
|
96
|
+
* @static
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* Logger.v("verbose message") // [LOGGER VERBOSE] > verbose message
|
|
100
|
+
*
|
|
101
|
+
* @param {...any[]} args verbose messages
|
|
102
|
+
* @returns {void}
|
|
103
|
+
*/
|
|
104
|
+
Logger.v = function () {
|
|
105
|
+
var arguments$1 = arguments;
|
|
106
|
+
|
|
107
|
+
var args = [];
|
|
108
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
109
|
+
args[_i] = arguments$1[_i];
|
|
110
|
+
}
|
|
111
|
+
if (Logger.LOGGER_LEVEL <= 1)
|
|
112
|
+
{ Logger.HIDE_TAG ? console.log.apply(console, args) : console.log.apply(console, __spreadArray(["[".concat(Logger.TAG, " VERBOSE]")], args, false)); }
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* @description Static method used to print debug logs
|
|
116
|
+
* @static
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* Logger.d("debug message") // [LOGGER DEBUG] > debug message
|
|
120
|
+
* Logger.d("debug message", "DEBUG") // [DEBUG] > debug message
|
|
121
|
+
*
|
|
122
|
+
* @param {...any[]} msg debug messages
|
|
123
|
+
* @returns {void}
|
|
124
|
+
*/
|
|
125
|
+
Logger.d = function () {
|
|
126
|
+
var arguments$1 = arguments;
|
|
127
|
+
|
|
128
|
+
var args = [];
|
|
129
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
130
|
+
args[_i] = arguments$1[_i];
|
|
131
|
+
}
|
|
132
|
+
if (Logger.LOGGER_LEVEL < 1) {
|
|
133
|
+
Logger.HIDE_TAG
|
|
134
|
+
? console.log.apply(console, args) : console.log.apply(console, __spreadArray(["%c[".concat(Logger.TAG, " DEBUG]"), 'background: #1677ff; color: #fff'], args, false));
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* @description Static method used to set logger option
|
|
139
|
+
* @static
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* Logger.setOptions({level: 'INFO'}) // set logger level
|
|
143
|
+
*
|
|
144
|
+
* @param {LoggerOptions} options logger options
|
|
145
|
+
* @return {void}
|
|
146
|
+
*/
|
|
147
|
+
Logger.setOptions = function (options) {
|
|
148
|
+
Logger.LOGGER_LEVEL = Logger._matchLevel(options.level);
|
|
149
|
+
Logger.HIDE_TAG = !!options.hideTag;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* @description Static method used to match logger level
|
|
153
|
+
* @static
|
|
154
|
+
* @private
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* Logger._matchLevel("DEBUG") // 0
|
|
158
|
+
*
|
|
159
|
+
* @param {LoggerLevel} level logger level
|
|
160
|
+
* @return {number}
|
|
161
|
+
*/
|
|
162
|
+
Logger._matchLevel = function (level) {
|
|
163
|
+
var logLevel = 0;
|
|
164
|
+
switch (level) {
|
|
165
|
+
case 'DEBUG':
|
|
166
|
+
logLevel = 0;
|
|
167
|
+
break;
|
|
168
|
+
case 'VERBOSE':
|
|
169
|
+
logLevel = 1;
|
|
170
|
+
break;
|
|
171
|
+
case 'INFO':
|
|
172
|
+
logLevel = 2;
|
|
173
|
+
break;
|
|
174
|
+
case 'WARN':
|
|
175
|
+
logLevel = 3;
|
|
176
|
+
break;
|
|
177
|
+
case 'ERROR':
|
|
178
|
+
logLevel = 4;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
return logLevel;
|
|
182
|
+
};
|
|
183
|
+
Logger.TAG = 'LOGGER';
|
|
184
|
+
// log level default 0,
|
|
185
|
+
Logger.LOGGER_LEVEL = 0;
|
|
186
|
+
Logger.HIDE_TAG = false;
|
|
187
|
+
return Logger;
|
|
188
|
+
}());
|
|
189
|
+
|
|
190
|
+
module.exports = Logger;
|
package/index.umd.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* @skax/logger.js v0.1.0
|
|
4
|
+
* Copyright (c) 2023-7-15 ShineShao <xiaoshaoqq@gmail.com>
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
(function (global, factory) {
|
|
9
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
10
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
11
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Logger = factory());
|
|
12
|
+
})(this, (function () { 'use strict';
|
|
13
|
+
|
|
14
|
+
function __spreadArray(to, from, pack) {
|
|
15
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
16
|
+
if (ar || !(i in from)) {
|
|
17
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
18
|
+
ar[i] = from[i];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
22
|
+
}
|
|
23
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
24
|
+
var e = new Error(message);
|
|
25
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @class Logger class
|
|
30
|
+
* @classdesc Provide multiple log printing methods
|
|
31
|
+
*/
|
|
32
|
+
var Logger = /** @class */ (function () {
|
|
33
|
+
function Logger() {
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @description Static method used to print error logs
|
|
37
|
+
* @static
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* Logger.e("error message") // [LOGGER ERROR] > error message
|
|
41
|
+
*
|
|
42
|
+
* @param {...any[]} args error messages
|
|
43
|
+
* @returns {void}
|
|
44
|
+
*/
|
|
45
|
+
Logger.e = function () {
|
|
46
|
+
var arguments$1 = arguments;
|
|
47
|
+
|
|
48
|
+
var args = [];
|
|
49
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
50
|
+
args[_i] = arguments$1[_i];
|
|
51
|
+
}
|
|
52
|
+
if (Logger.LOGGER_LEVEL <= 4)
|
|
53
|
+
{ Logger.HIDE_TAG
|
|
54
|
+
? console.error.apply(console, args) : console.error.apply(console, __spreadArray(["%c[".concat(Logger.TAG, " ERROR]"), 'background: red; color: #fff'], args, false)); }
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* @description Static method used to print warn logs
|
|
58
|
+
* @static
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* Logger.w("warn message") // [LOGGER WARN] > warn message
|
|
62
|
+
*
|
|
63
|
+
* @param {...any[]} args warn messages
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*/
|
|
66
|
+
Logger.w = function () {
|
|
67
|
+
var arguments$1 = arguments;
|
|
68
|
+
|
|
69
|
+
var args = [];
|
|
70
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
71
|
+
args[_i] = arguments$1[_i];
|
|
72
|
+
}
|
|
73
|
+
if (Logger.LOGGER_LEVEL <= 3)
|
|
74
|
+
{ Logger.HIDE_TAG
|
|
75
|
+
? console.warn.apply(console, args) : console.warn.apply(console, __spreadArray(["%c[".concat(Logger.TAG, " WARN]"), 'background: #faad14; color: #fff'], args, false)); }
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @description Static method used to print info logs
|
|
79
|
+
* @static
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* Logger.i("info message") // [LOGGER INFO] > info message
|
|
83
|
+
*
|
|
84
|
+
* @param {...any[]} args info messages
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
Logger.i = function () {
|
|
88
|
+
var arguments$1 = arguments;
|
|
89
|
+
|
|
90
|
+
var args = [];
|
|
91
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
92
|
+
args[_i] = arguments$1[_i];
|
|
93
|
+
}
|
|
94
|
+
if (Logger.LOGGER_LEVEL <= 2)
|
|
95
|
+
{ Logger.HIDE_TAG
|
|
96
|
+
? console.info.apply(console, args) : console.info.apply(console, __spreadArray(["%c[".concat(Logger.TAG, " INFO]"), 'background: #ffe58f; color: #fff'], args, false)); }
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* @description Static method used to print verbose logs
|
|
100
|
+
* @static
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* Logger.v("verbose message") // [LOGGER VERBOSE] > verbose message
|
|
104
|
+
*
|
|
105
|
+
* @param {...any[]} args verbose messages
|
|
106
|
+
* @returns {void}
|
|
107
|
+
*/
|
|
108
|
+
Logger.v = function () {
|
|
109
|
+
var arguments$1 = arguments;
|
|
110
|
+
|
|
111
|
+
var args = [];
|
|
112
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
113
|
+
args[_i] = arguments$1[_i];
|
|
114
|
+
}
|
|
115
|
+
if (Logger.LOGGER_LEVEL <= 1)
|
|
116
|
+
{ Logger.HIDE_TAG ? console.log.apply(console, args) : console.log.apply(console, __spreadArray(["[".concat(Logger.TAG, " VERBOSE]")], args, false)); }
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* @description Static method used to print debug logs
|
|
120
|
+
* @static
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* Logger.d("debug message") // [LOGGER DEBUG] > debug message
|
|
124
|
+
* Logger.d("debug message", "DEBUG") // [DEBUG] > debug message
|
|
125
|
+
*
|
|
126
|
+
* @param {...any[]} msg debug messages
|
|
127
|
+
* @returns {void}
|
|
128
|
+
*/
|
|
129
|
+
Logger.d = function () {
|
|
130
|
+
var arguments$1 = arguments;
|
|
131
|
+
|
|
132
|
+
var args = [];
|
|
133
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
134
|
+
args[_i] = arguments$1[_i];
|
|
135
|
+
}
|
|
136
|
+
if (Logger.LOGGER_LEVEL < 1) {
|
|
137
|
+
Logger.HIDE_TAG
|
|
138
|
+
? console.log.apply(console, args) : console.log.apply(console, __spreadArray(["%c[".concat(Logger.TAG, " DEBUG]"), 'background: #1677ff; color: #fff'], args, false));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* @description Static method used to set logger option
|
|
143
|
+
* @static
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* Logger.setOptions({level: 'INFO'}) // set logger level
|
|
147
|
+
*
|
|
148
|
+
* @param {LoggerOptions} options logger options
|
|
149
|
+
* @return {void}
|
|
150
|
+
*/
|
|
151
|
+
Logger.setOptions = function (options) {
|
|
152
|
+
Logger.LOGGER_LEVEL = Logger._matchLevel(options.level);
|
|
153
|
+
Logger.HIDE_TAG = !!options.hideTag;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* @description Static method used to match logger level
|
|
157
|
+
* @static
|
|
158
|
+
* @private
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* Logger._matchLevel("DEBUG") // 0
|
|
162
|
+
*
|
|
163
|
+
* @param {LoggerLevel} level logger level
|
|
164
|
+
* @return {number}
|
|
165
|
+
*/
|
|
166
|
+
Logger._matchLevel = function (level) {
|
|
167
|
+
var logLevel = 0;
|
|
168
|
+
switch (level) {
|
|
169
|
+
case 'DEBUG':
|
|
170
|
+
logLevel = 0;
|
|
171
|
+
break;
|
|
172
|
+
case 'VERBOSE':
|
|
173
|
+
logLevel = 1;
|
|
174
|
+
break;
|
|
175
|
+
case 'INFO':
|
|
176
|
+
logLevel = 2;
|
|
177
|
+
break;
|
|
178
|
+
case 'WARN':
|
|
179
|
+
logLevel = 3;
|
|
180
|
+
break;
|
|
181
|
+
case 'ERROR':
|
|
182
|
+
logLevel = 4;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
return logLevel;
|
|
186
|
+
};
|
|
187
|
+
Logger.TAG = 'LOGGER';
|
|
188
|
+
// log level default 0,
|
|
189
|
+
Logger.LOGGER_LEVEL = 0;
|
|
190
|
+
Logger.HIDE_TAG = false;
|
|
191
|
+
return Logger;
|
|
192
|
+
}());
|
|
193
|
+
|
|
194
|
+
return Logger;
|
|
195
|
+
|
|
196
|
+
}));
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skax/logger",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "console logger",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"umd": "dist/index.umd.js",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/freeshineit/skax-logger.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"logger",
|
|
14
|
+
"console"
|
|
15
|
+
],
|
|
16
|
+
"author": "ShineShao <xiaoshaoqq@gmail.com>",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/freeshineit/skax-logger/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/freeshineit/skax-logger#readme",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=14"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/** logger level */
|
|
2
|
+
export type LoggerLevel = 'DEBUG' | 'VERBOSE' | 'INFO' | 'WARN' | 'ERROR';
|
|
3
|
+
/** logger options */
|
|
4
|
+
export interface LoggerOptions {
|
|
5
|
+
/** logger level */
|
|
6
|
+
level?: LoggerLevel;
|
|
7
|
+
/** hidden tag prefix */
|
|
8
|
+
hideTag?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @class Logger class
|
|
12
|
+
* @classdesc Provide multiple log printing methods
|
|
13
|
+
*/
|
|
14
|
+
declare class Logger {
|
|
15
|
+
private static readonly TAG;
|
|
16
|
+
private static LOGGER_LEVEL;
|
|
17
|
+
private static HIDE_TAG;
|
|
18
|
+
/**
|
|
19
|
+
* @description Static method used to print error logs
|
|
20
|
+
* @static
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* Logger.e("error message") // [LOGGER ERROR] > error message
|
|
24
|
+
*
|
|
25
|
+
* @param {...any[]} args error messages
|
|
26
|
+
* @returns {void}
|
|
27
|
+
*/
|
|
28
|
+
static e(...args: any[]): void;
|
|
29
|
+
/**
|
|
30
|
+
* @description Static method used to print warn logs
|
|
31
|
+
* @static
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* Logger.w("warn message") // [LOGGER WARN] > warn message
|
|
35
|
+
*
|
|
36
|
+
* @param {...any[]} args warn messages
|
|
37
|
+
* @returns {void}
|
|
38
|
+
*/
|
|
39
|
+
static w(...args: any[]): void;
|
|
40
|
+
/**
|
|
41
|
+
* @description Static method used to print info logs
|
|
42
|
+
* @static
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* Logger.i("info message") // [LOGGER INFO] > info message
|
|
46
|
+
*
|
|
47
|
+
* @param {...any[]} args info messages
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
static i(...args: any[]): void;
|
|
51
|
+
/**
|
|
52
|
+
* @description Static method used to print verbose logs
|
|
53
|
+
* @static
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* Logger.v("verbose message") // [LOGGER VERBOSE] > verbose message
|
|
57
|
+
*
|
|
58
|
+
* @param {...any[]} args verbose messages
|
|
59
|
+
* @returns {void}
|
|
60
|
+
*/
|
|
61
|
+
static v(...args: any[]): void;
|
|
62
|
+
/**
|
|
63
|
+
* @description Static method used to print debug logs
|
|
64
|
+
* @static
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* Logger.d("debug message") // [LOGGER DEBUG] > debug message
|
|
68
|
+
* Logger.d("debug message", "DEBUG") // [DEBUG] > debug message
|
|
69
|
+
*
|
|
70
|
+
* @param {...any[]} msg debug messages
|
|
71
|
+
* @returns {void}
|
|
72
|
+
*/
|
|
73
|
+
static d(...args: any[]): void;
|
|
74
|
+
/**
|
|
75
|
+
* @description Static method used to set logger option
|
|
76
|
+
* @static
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* Logger.setOptions({level: 'INFO'}) // set logger level
|
|
80
|
+
*
|
|
81
|
+
* @param {LoggerOptions} options logger options
|
|
82
|
+
* @return {void}
|
|
83
|
+
*/
|
|
84
|
+
static setOptions(options: LoggerOptions): void;
|
|
85
|
+
/**
|
|
86
|
+
* @description Static method used to match logger level
|
|
87
|
+
* @static
|
|
88
|
+
* @private
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* Logger._matchLevel("DEBUG") // 0
|
|
92
|
+
*
|
|
93
|
+
* @param {LoggerLevel} level logger level
|
|
94
|
+
* @return {number}
|
|
95
|
+
*/
|
|
96
|
+
private static _matchLevel;
|
|
97
|
+
}
|
|
98
|
+
export default Logger;
|