@skax/logger 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -13,9 +13,36 @@ import Logger from '@skax/logger';
13
13
 
14
14
  const logger = new Logger();
15
15
 
16
- logger.d('console.log print'); // debug
16
+ logger.d('console.debug print'); // debug
17
17
  logger.v('console.log print'); // log
18
- logger.i('console.log print'); // info
19
- logger.w('console.log print'); // warn
20
- logger.e('console.log print'); // error
18
+ logger.i('console.info print'); // info
19
+ logger.w('console.warn print'); // warn
20
+ logger.e('console.error print'); // error
21
+ ```
22
+
23
+ ### umd
24
+
25
+ ```html
26
+ <script src="./index.umd.js"></script>
27
+ <script>
28
+ (function () {
29
+ const logger = new Logger();
30
+
31
+ logger.v(logger.version());
32
+
33
+ logger.d('1234132');
34
+ logger.v('1234132');
35
+ logger.i('1234132');
36
+ logger.w('1234132');
37
+ logger.e('1234132');
38
+
39
+ logger.setOptions({ level: 'WARN' });
40
+
41
+ logger.d('2-1234132');
42
+ logger.v('2-1234132');
43
+ logger.i('2-1234132');
44
+ logger.w('2-1234132');
45
+ logger.e('2-1234132');
46
+ })();
47
+ </script>
21
48
  ```
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  *
3
- * @skax/logger.js v1.0.0
4
- * Copyright (c) 2023-9-19 ShineShao <xiaoshaoqq@gmail.com>
3
+ * @skax/logger.js v1.0.1
4
+ * Copyright (c) 2023-9-30 ShineShao <xiaoshaoqq@gmail.com>
5
5
  * Released under the MIT License.
6
6
  *
7
7
  */
@@ -21,7 +21,7 @@ var Logger = /** @class */ (function () {
21
21
  this._levelNum = 0;
22
22
  /**
23
23
  * @description Method used to print error logs
24
- * @static
24
+ * @method
25
25
  *
26
26
  * @example
27
27
  * logger.e("error message") // error message
@@ -32,7 +32,7 @@ var Logger = /** @class */ (function () {
32
32
  this.e = this._loggerFactory('error', this._levelNum <= 4);
33
33
  /**
34
34
  * @description Method used to print warn logs
35
- * @static
35
+ * @method
36
36
  *
37
37
  * @example
38
38
  * logger.w("warn message") // warn message
@@ -43,7 +43,7 @@ var Logger = /** @class */ (function () {
43
43
  this.w = this._loggerFactory('warn', this._levelNum <= 3);
44
44
  /**
45
45
  * @description Method used to print info logs
46
- * @static
46
+ * @method
47
47
  *
48
48
  * @example
49
49
  * logger.i("info message") // info message
@@ -54,7 +54,7 @@ var Logger = /** @class */ (function () {
54
54
  this.i = this._loggerFactory('info', this._levelNum <= 2);
55
55
  /**
56
56
  * @description Method used to print verbose logs
57
- * @static
57
+ * @method
58
58
  *
59
59
  * @example
60
60
  * logger.v("verbose message") // verbose message
@@ -65,7 +65,7 @@ var Logger = /** @class */ (function () {
65
65
  this.v = this._loggerFactory('log', this._levelNum <= 1);
66
66
  /**
67
67
  * @description Method used to print debug logs
68
- * @static
68
+ * @method
69
69
  *
70
70
  * @example
71
71
  * logger.d("debug message") // debug message
@@ -78,7 +78,6 @@ var Logger = /** @class */ (function () {
78
78
  }
79
79
  /**
80
80
  * @description Method used to set logger option and change logger level
81
- * @static
82
81
  *
83
82
  * @example
84
83
  * logger.setOptions({level: 'INFO'}) // set logger level
@@ -93,13 +92,12 @@ var Logger = /** @class */ (function () {
93
92
  this.e = this._loggerFactory('error', this._levelNum <= 4);
94
93
  this.w = this._loggerFactory('warn', this._levelNum <= 3);
95
94
  this.i = this._loggerFactory('info', this._levelNum <= 2);
96
- this.v = this._loggerFactory('warn', this._levelNum <= 1);
95
+ this.v = this._loggerFactory('log', this._levelNum <= 1);
97
96
  this.d = this._loggerFactory('warn', this._levelNum < 1);
98
97
  }
99
98
  };
100
99
  /**
101
100
  * @description Private method used to match logger level
102
- * @static
103
101
  * @private
104
102
  *
105
103
  * @example
@@ -132,8 +130,8 @@ var Logger = /** @class */ (function () {
132
130
  /**
133
131
  * @private
134
132
  * @description Logger factory
135
- * @param type
136
- * @param bool
133
+ * @param {ConsoleKey} type
134
+ * @param {boolean} bool
137
135
  * @returns
138
136
  */
139
137
  Logger.prototype._loggerFactory = function (type, bool) {
@@ -155,7 +153,7 @@ var Logger = /** @class */ (function () {
155
153
  * @returns {string}
156
154
  */
157
155
  Logger.prototype.version = function () {
158
- return '1.0.0';
156
+ return '1.0.1';
159
157
  };
160
158
  Logger.noop = function () { };
161
159
  return Logger;
package/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  *
3
- * @skax/logger.js v1.0.0
4
- * Copyright (c) 2023-9-19 ShineShao <xiaoshaoqq@gmail.com>
3
+ * @skax/logger.js v1.0.1
4
+ * Copyright (c) 2023-9-30 ShineShao <xiaoshaoqq@gmail.com>
5
5
  * Released under the MIT License.
6
6
  *
7
7
  */
@@ -25,7 +25,7 @@
25
25
  this._levelNum = 0;
26
26
  /**
27
27
  * @description Method used to print error logs
28
- * @static
28
+ * @method
29
29
  *
30
30
  * @example
31
31
  * logger.e("error message") // error message
@@ -36,7 +36,7 @@
36
36
  this.e = this._loggerFactory('error', this._levelNum <= 4);
37
37
  /**
38
38
  * @description Method used to print warn logs
39
- * @static
39
+ * @method
40
40
  *
41
41
  * @example
42
42
  * logger.w("warn message") // warn message
@@ -47,7 +47,7 @@
47
47
  this.w = this._loggerFactory('warn', this._levelNum <= 3);
48
48
  /**
49
49
  * @description Method used to print info logs
50
- * @static
50
+ * @method
51
51
  *
52
52
  * @example
53
53
  * logger.i("info message") // info message
@@ -58,7 +58,7 @@
58
58
  this.i = this._loggerFactory('info', this._levelNum <= 2);
59
59
  /**
60
60
  * @description Method used to print verbose logs
61
- * @static
61
+ * @method
62
62
  *
63
63
  * @example
64
64
  * logger.v("verbose message") // verbose message
@@ -69,7 +69,7 @@
69
69
  this.v = this._loggerFactory('log', this._levelNum <= 1);
70
70
  /**
71
71
  * @description Method used to print debug logs
72
- * @static
72
+ * @method
73
73
  *
74
74
  * @example
75
75
  * logger.d("debug message") // debug message
@@ -82,7 +82,6 @@
82
82
  }
83
83
  /**
84
84
  * @description Method used to set logger option and change logger level
85
- * @static
86
85
  *
87
86
  * @example
88
87
  * logger.setOptions({level: 'INFO'}) // set logger level
@@ -97,13 +96,12 @@
97
96
  this.e = this._loggerFactory('error', this._levelNum <= 4);
98
97
  this.w = this._loggerFactory('warn', this._levelNum <= 3);
99
98
  this.i = this._loggerFactory('info', this._levelNum <= 2);
100
- this.v = this._loggerFactory('warn', this._levelNum <= 1);
99
+ this.v = this._loggerFactory('log', this._levelNum <= 1);
101
100
  this.d = this._loggerFactory('warn', this._levelNum < 1);
102
101
  }
103
102
  };
104
103
  /**
105
104
  * @description Private method used to match logger level
106
- * @static
107
105
  * @private
108
106
  *
109
107
  * @example
@@ -136,8 +134,8 @@
136
134
  /**
137
135
  * @private
138
136
  * @description Logger factory
139
- * @param type
140
- * @param bool
137
+ * @param {ConsoleKey} type
138
+ * @param {boolean} bool
141
139
  * @returns
142
140
  */
143
141
  Logger.prototype._loggerFactory = function (type, bool) {
@@ -159,7 +157,7 @@
159
157
  * @returns {string}
160
158
  */
161
159
  Logger.prototype.version = function () {
162
- return '1.0.0';
160
+ return '1.0.1';
163
161
  };
164
162
  Logger.noop = function () { };
165
163
  return Logger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skax/logger",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "console logger",
5
5
  "main": "index.js",
6
6
  "umd": "index.umd.js",
package/types/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export interface LoggerOptions {
5
5
  /** logger level */
6
6
  level?: LoggerLevel;
7
7
  }
8
+ export type LoggerFunc = (...data: any[]) => void;
8
9
  /**
9
10
  * @class Logger
10
11
  * @classdesc Provide multiple log printing methods
@@ -19,7 +20,7 @@ declare class Logger {
19
20
  constructor(options?: LoggerOptions);
20
21
  /**
21
22
  * @description Method used to print error logs
22
- * @static
23
+ * @method
23
24
  *
24
25
  * @example
25
26
  * logger.e("error message") // error message
@@ -27,10 +28,10 @@ declare class Logger {
27
28
  * @param {...any[]} args error messages
28
29
  * @returns {void}
29
30
  */
30
- e: any;
31
+ e: LoggerFunc;
31
32
  /**
32
33
  * @description Method used to print warn logs
33
- * @static
34
+ * @method
34
35
  *
35
36
  * @example
36
37
  * logger.w("warn message") // warn message
@@ -38,10 +39,10 @@ declare class Logger {
38
39
  * @param {...any[]} args warn messages
39
40
  * @returns {void}
40
41
  */
41
- w: any;
42
+ w: LoggerFunc;
42
43
  /**
43
44
  * @description Method used to print info logs
44
- * @static
45
+ * @method
45
46
  *
46
47
  * @example
47
48
  * logger.i("info message") // info message
@@ -49,10 +50,10 @@ declare class Logger {
49
50
  * @param {...any[]} args info messages
50
51
  * @returns {void}
51
52
  */
52
- i: any;
53
+ i: LoggerFunc;
53
54
  /**
54
55
  * @description Method used to print verbose logs
55
- * @static
56
+ * @method
56
57
  *
57
58
  * @example
58
59
  * logger.v("verbose message") // verbose message
@@ -60,10 +61,10 @@ declare class Logger {
60
61
  * @param {...any[]} args verbose messages
61
62
  * @returns {void}
62
63
  */
63
- v: any;
64
+ v: LoggerFunc;
64
65
  /**
65
66
  * @description Method used to print debug logs
66
- * @static
67
+ * @method
67
68
  *
68
69
  * @example
69
70
  * logger.d("debug message") // debug message
@@ -71,10 +72,9 @@ declare class Logger {
71
72
  * @param {...any[]} msg debug messages
72
73
  * @returns {void}
73
74
  */
74
- d: any;
75
+ d: LoggerFunc;
75
76
  /**
76
77
  * @description Method used to set logger option and change logger level
77
- * @static
78
78
  *
79
79
  * @example
80
80
  * logger.setOptions({level: 'INFO'}) // set logger level
@@ -85,7 +85,6 @@ declare class Logger {
85
85
  setOptions(options: Partial<LoggerOptions>): void;
86
86
  /**
87
87
  * @description Private method used to match logger level
88
- * @static
89
88
  * @private
90
89
  *
91
90
  * @example
@@ -98,8 +97,8 @@ declare class Logger {
98
97
  /**
99
98
  * @private
100
99
  * @description Logger factory
101
- * @param type
102
- * @param bool
100
+ * @param {ConsoleKey} type
101
+ * @param {boolean} bool
103
102
  * @returns
104
103
  */
105
104
  private _loggerFactory;