@alwatr/logger 0.7.0 → 0.9.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/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.9.0](https://github.com/AliMD/alwatr/compare/v0.8.0...v0.9.0) (2022-03-22)
7
+
8
+ **Note:** Version bump only for package @alwatr/logger
9
+
10
+
11
+
12
+
13
+
14
+ # [0.8.0](https://github.com/AliMD/alwatr/compare/v0.7.2...v0.8.0) (2022-03-14)
15
+
16
+ **Note:** Version bump only for package @alwatr/logger
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.7.2](https://github.com/AliMD/alwatr/compare/v0.7.1...v0.7.2) (2022-03-12)
23
+
24
+
25
+ ### Features
26
+
27
+ * **logger:** add debug and improve documents ([8f83d29](https://github.com/AliMD/alwatr/commit/8f83d2956e521f016fe530322f657c343f1a0b80))
28
+
29
+
30
+
31
+
32
+
6
33
  # [0.7.0](https://github.com/AliMD/alwatr/compare/v0.6.1...v0.7.0) (2022-03-12)
7
34
 
8
35
  **Note:** Version bump only for package @alwatr/logger
package/README.md CHANGED
@@ -39,14 +39,33 @@ Please remember to **reload** the window after changing the debug mode.
39
39
 
40
40
  ### API
41
41
 
42
- ### Prepare the logger
42
+ ### `createLogger(scope: string, color: string, force = boolean)`
43
+
44
+ Create a logger function for fancy console debug with custom scope.
45
+
46
+ - **color** is optional and automatically select from internal fancy color list.
47
+ - **force** is optional and default to false.
48
+
49
+ Example:
43
50
 
44
51
  ```ts
45
52
  import {createLogger} from 'https://esm.run/@alwatr/logger';
46
- const logger = createLogger('logger/demo', 'green');
53
+ const logger = createLogger('logger/demo');
47
54
  ```
48
55
 
49
- ### `logProperty(property, value)`
56
+ ### `logger.debug: boolean`
57
+
58
+ Debug state for current scope base on localStorage `ALWATR_LOG` pattern.
59
+
60
+ ### `logger.color: string`
61
+
62
+ Debug state for current scope base on localStorage `ALWATR_LOG` pattern.
63
+
64
+ ### `logger.scope: string`
65
+
66
+ Debug state for current scope base on localStorage `ALWATR_LOG` pattern.
67
+
68
+ ### `logger.logProperty(property, value)`
50
69
 
51
70
  `console.debug` property change.
52
71
 
@@ -56,7 +75,7 @@ Example:
56
75
  logger.logProperty('name', 'ali');
57
76
  ```
58
77
 
59
- ### `logMethod(method)`
78
+ ### `logger.logMethod(method)`
60
79
 
61
80
  `console.debug` function or method calls.
62
81
 
@@ -68,7 +87,7 @@ function myMethod () {
68
87
  }
69
88
  ```
70
89
 
71
- ### `logMethodArgs(method, args)`
90
+ ### `logger.logMethodArgs(method, args)`
72
91
 
73
92
  `console.debug` function or method calls with arguments.
74
93
 
@@ -80,7 +99,7 @@ function myMethod (a: number, b: number) {
80
99
  }
81
100
  ```
82
101
 
83
- ### `logMethodFull(method, args, result)`
102
+ ### `logger.logMethodFull(method, args, result)`
84
103
 
85
104
  `console.debug` function or method calls with arguments.
86
105
 
@@ -94,7 +113,7 @@ function add (a: number, b: number): number {
94
113
  }
95
114
  ```
96
115
 
97
- ### `incident(method, code, description, ...args)`
116
+ ### `logger.incident(method, code, description, ...args)`
98
117
 
99
118
  `console.trace` an event or expected accident. (not warn or error)
100
119
 
@@ -104,7 +123,7 @@ Example:
104
123
  logger.incident('fetch', 'abort_signal', 'aborted signal received', {url: '/test.json'});
105
124
  ```
106
125
 
107
- ### `accident(method, code, description, ...args)`
126
+ ### `logger.accident(method, code, description, ...args)`
108
127
 
109
128
  `console.warn` an unexpected accident or error that you handled.
110
129
 
@@ -114,7 +133,7 @@ Example:
114
133
  logger.accident('fetch', 'file_not_found', 'url requested return 404 not found', {url: '/test.json'});
115
134
  ```
116
135
 
117
- ### `error(method, code, errorStack, ...args)`
136
+ ### `logger.error(method, code, errorStack, ...args)`
118
137
 
119
138
  `console.error` an unexpected error.
120
139
 
@@ -129,7 +148,7 @@ catch (err) {
129
148
  }
130
149
  ```
131
150
 
132
- ### `logOther(...args)`
151
+ ### `logger.logOther(...args)`
133
152
 
134
153
  Simple `console.debug` with styled scope.
135
154
 
@@ -138,3 +157,28 @@ Example:
138
157
  ```ts
139
158
  logger.logOther('foo:', 'bar', {a: 1});
140
159
  ```
160
+
161
+ ### How to handle promises?
162
+
163
+ For example with a promise function with error:
164
+
165
+ ```ts
166
+ const failPromiseTest = (): Promise<never> => new Promise((_, reject) => reject(new Error('my_error_code')));
167
+ ```
168
+
169
+ Best practices to catch the error and log it:
170
+
171
+ ```ts
172
+ // Unhandled promise rejection (just log it)
173
+ failPromiseTest()
174
+ .catch((err) => logger.error('myMethod', (err as Error).message || 'error_code', (err as Error).stack || err));
175
+
176
+ // Handled promise rejection
177
+ try {
178
+ await failPromiseTest();
179
+ } catch (err) {
180
+ logger.accident('myMethod', 'error_code', 'failPromiseTest failed!, ' + (err as Error).message,
181
+ (err as Error).stack || err);
182
+ // do something to handle the error...
183
+ }
184
+ ```
package/logger.d.ts CHANGED
@@ -13,11 +13,15 @@ export declare const style: {
13
13
  /**
14
14
  * Create a logger function for fancy console debug with custom scope.
15
15
  *
16
- * @example
17
- * const logger = createLogger('demo');
18
- * function sayHello (name: string) {
19
- * logger.logMethodArgs('sayHello', {name});
20
- * }
16
+ * - **color** is optional and automatically select from internal fancy color list.
17
+ * - **force** is optional and default to false.
18
+ *
19
+ * Example:
20
+ *
21
+ * ```ts
22
+ * import {createLogger} from 'https://esm.run/@alwatr/logger';
23
+ * const logger = createLogger('logger/demo');
24
+ * ```
21
25
  */
22
26
  export declare const createLogger: (scope: string, color?: string, force?: boolean) => Logger;
23
27
  //# sourceMappingURL=logger.d.ts.map
package/logger.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;GAAsC,CAAC;AAoExE,eAAO,MAAM,KAAK;;;CAGjB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,UACd,MAAM,UACN,MAAM,sBAEd,MAsGF,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;GAAsC,CAAC;AAoExE,eAAO,MAAM,KAAK;;;CAGjB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,UACd,MAAM,UACN,MAAM,sBAEd,MAuGF,CAAC"}
package/logger.js CHANGED
@@ -62,11 +62,15 @@ export const style = {
62
62
  /**
63
63
  * Create a logger function for fancy console debug with custom scope.
64
64
  *
65
- * @example
66
- * const logger = createLogger('demo');
67
- * function sayHello (name: string) {
68
- * logger.logMethodArgs('sayHello', {name});
69
- * }
65
+ * - **color** is optional and automatically select from internal fancy color list.
66
+ * - **force** is optional and default to false.
67
+ *
68
+ * Example:
69
+ *
70
+ * ```ts
71
+ * import {createLogger} from 'https://esm.run/@alwatr/logger';
72
+ * const logger = createLogger('logger/demo');
73
+ * ```
70
74
  */
71
75
  export const createLogger = (scope, color = getNextColor(), force = false) => {
72
76
  scope = scope.trim();
@@ -82,6 +86,7 @@ export const createLogger = (scope, color = getNextColor(), force = false) => {
82
86
  * Required logger object, accident, error always reported even when the debug is false.
83
87
  */
84
88
  const requiredItems = {
89
+ debug,
85
90
  color,
86
91
  scope,
87
92
  accident: console.warn.bind(console, '%c%s%c.%s => Accident: "%s" (%s)!', styleScope, scope, style.reset),
package/logger.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAA,MA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AK,CACd;QAED,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CACrB,OAAO,EACP,mBAAmB,EACnB,UAAU,EACV,KAAK,EACL,KAAK,CAAC,KAAK,CACd;KACF,CAAC;IAEF,IAAI,CAAC,KAAK,EAAE;QACV,OAAO;YACL,GAAG,aAAa;YAChB,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,KAAK;YAChB,aAAa,EAAE,KAAK;YACpB,aAAa,EAAE,KAAK;YACpB,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IAED,uCAAuC;IACvC,OAAO;QACL,GAAG,aAAa;QAEhB,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAC3B,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,KAAK,EACL,KAAK,CAAC,KAAK,CACd;QAED,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CACzB,OAAO,EACP,cAAc,EACd,UAAU,EACV,KAAK,EACL,KAAK,CAAC,KAAK,CACd;QAED,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAC7B,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,KAAK,CAAC,KAAK,CACd;QAED,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAC7B,OAAO,EACP,sBAAsB,EACtB,UAAU,EACV,KAAK,EACL,KAAK,CAAC,KAAK,CACd;QAED,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CACxB,OAAO,EACP,qCAAqC,EACrC,UAAU,EACV,KAAK,EACL,KAAK,CAAC,KAAK,CACd;QAED,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CACxB,OAAO,EACP,MAAM,EACN,UAAU,EACV,KAAK,CACR;KACF,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,M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6 @@
1
1
  {
2
2
  "name": "@alwatr/logger",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.",
5
5
  "keywords": [
6
6
  "log",
@@ -38,5 +38,5 @@
38
38
  "dependencies": {
39
39
  "tslib": "^2.3.1"
40
40
  },
41
- "gitHead": "5eca110493087213c2c01695b9738a5f9fd8edf7"
41
+ "gitHead": "1f94c6a09874971a0f28b6ef91b7582837e043d0"
42
42
  }
package/type.d.ts CHANGED
@@ -15,7 +15,17 @@ declare global {
15
15
  }
16
16
  }
17
17
  export interface Logger {
18
+ /**
19
+ * Debug state for current scope base on localStorage `ALWATR_LOG` pattern.
20
+ */
21
+ readonly debug: boolean;
22
+ /**
23
+ * Color picked for current scope.
24
+ */
18
25
  readonly color: string;
26
+ /**
27
+ * Scope defined for this logger.
28
+ */
19
29
  readonly scope: string;
20
30
  /**
21
31
  * `console.debug` property change.
package/type.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,CAAC,EAAE;YACP,cAAc,CAAC,EAAE,KAAK,CAAC;gBACrB,IAAI,EAAE,MAAM,CAAC;gBACb,OAAO,EAAE,MAAM,CAAC;aACjB,CAAC,CAAC;SACJ,CAAA;KACF;IAED;;OAEG;IACH,UAAU,gBAAgB;QACxB,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EAC/C,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,E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