@alwatr/logger 0.16.0 → 0.17.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 +5 -3
- package/README.md +4 -2
- package/logger.js +16 -16
- package/logger.js.map +1 -1
- package/package.json +2 -2
- package/type.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
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.
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @alwatr/logger
|
|
6
|
+
# [0.17.0](https://github.com/AliMD/alwatr/compare/v0.16.1...v0.17.0) (2022-10-21)
|
|
9
7
|
|
|
8
|
+
### Bug Fixes
|
|
10
9
|
|
|
10
|
+
- **`logger`:** `accident` sould `console.warn` ([c210c9f](https://github.com/AliMD/alwatr/commit/c210c9f6a864692848ea0c89d6ffbdb19167732a))
|
|
11
11
|
|
|
12
|
+
# [0.16.0](https://github.com/AliMD/alwatr/compare/v0.15.0...v0.16.0) (2022-09-08)
|
|
12
13
|
|
|
14
|
+
**Note:** Version bump only for package @alwatr/logger
|
|
13
15
|
|
|
14
16
|
# [0.15.0](https://github.com/AliMD/alwatr/compare/v0.14.0...v0.15.0) (2022-09-01)
|
|
15
17
|
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ function sayHello(name: string) {
|
|
|
16
16
|
|
|
17
17
|
### Debug Mode
|
|
18
18
|
|
|
19
|
-
Many of the methods in the logger are no-ops when the debug mode is off.
|
|
19
|
+
Many of the methods in the logger are no-ops when the debug mode is off in the browser.
|
|
20
20
|
Please remember to **reload** the window after changing the debug mode.
|
|
21
21
|
|
|
22
22
|
- Debugging all scopes
|
|
@@ -37,6 +37,8 @@ Please remember to **reload** the window after changing the debug mode.
|
|
|
37
37
|
window.localStorage?.setItem('ALWATR_DEBUG', '*alwatr*');
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
> Make sure the [log level](https://developer.chrome.com/docs/devtools/console/log/#browser) in set correctly.
|
|
41
|
+
|
|
40
42
|
## API
|
|
41
43
|
|
|
42
44
|
### `createLogger(scope: string, color: string, force = boolean)`
|
|
@@ -115,7 +117,7 @@ function add(a: number, b: number): number {
|
|
|
115
117
|
|
|
116
118
|
### `logger.incident(method, code, description, ...args)`
|
|
117
119
|
|
|
118
|
-
`console.
|
|
120
|
+
`console.log` an event or expected accident. (not warn or error)
|
|
119
121
|
|
|
120
122
|
Example:
|
|
121
123
|
|
package/logger.js
CHANGED
|
@@ -12,8 +12,8 @@ alwatrRegisteredList.push({
|
|
|
12
12
|
* Color list storage for logger.
|
|
13
13
|
*/
|
|
14
14
|
let colorIndex = 0;
|
|
15
|
-
const colorList = isBrowser
|
|
16
|
-
[
|
|
15
|
+
const colorList = isBrowser
|
|
16
|
+
? [
|
|
17
17
|
'#35b997',
|
|
18
18
|
'#f05561',
|
|
19
19
|
'#ee224a',
|
|
@@ -29,8 +29,8 @@ const colorList = isBrowser ?
|
|
|
29
29
|
'#1da2dc',
|
|
30
30
|
'#f05123',
|
|
31
31
|
'#ee2524',
|
|
32
|
-
]
|
|
33
|
-
['0;36', '0;35', '0;34', '0;33', '0;32']; // red and white omitted
|
|
32
|
+
]
|
|
33
|
+
: ['0;36', '0;35', '0;34', '0;33', '0;32']; // red and white omitted
|
|
34
34
|
const getNextColor = () => {
|
|
35
35
|
const color = colorList[colorIndex];
|
|
36
36
|
colorIndex++;
|
|
@@ -39,9 +39,9 @@ const getNextColor = () => {
|
|
|
39
39
|
}
|
|
40
40
|
return color;
|
|
41
41
|
};
|
|
42
|
-
const debugString = isBrowser
|
|
43
|
-
globalThis.localStorage?.getItem('ALWATR_DEBUG')?.trim()
|
|
44
|
-
globalThis.process?.env?.ALWATR_DEBUG?.trim();
|
|
42
|
+
const debugString = isBrowser
|
|
43
|
+
? globalThis.localStorage?.getItem('ALWATR_DEBUG')?.trim()
|
|
44
|
+
: globalThis.process?.env?.ALWATR_DEBUG?.trim();
|
|
45
45
|
const getDebugState = (scope) => {
|
|
46
46
|
if (debugString == null && isBrowser === false && globalThis.process.env.NODE_ENV !== 'production') {
|
|
47
47
|
return true;
|
|
@@ -97,12 +97,12 @@ export const createLogger = (scope, color = getNextColor(), debug = getDebugStat
|
|
|
97
97
|
debug,
|
|
98
98
|
color,
|
|
99
99
|
scope,
|
|
100
|
-
accident: isBrowser
|
|
101
|
-
console.
|
|
102
|
-
console.
|
|
103
|
-
error: isBrowser
|
|
104
|
-
console.error.bind(console, '%c%s%c.%s "%s" =>', styleScope, scope, style.reset)
|
|
105
|
-
console.error.bind(console, `${styleScope}❌ %s\x1b[31m.%s "%s" =>\x1b[0;2m`, scope),
|
|
100
|
+
accident: isBrowser
|
|
101
|
+
? console.warn.bind(console, '%c%s%c.%s "%s" => Accident: "%s" (%s)!', styleScope, scope, style.reset)
|
|
102
|
+
: console.warn.bind(console, `${styleScope}⚠️ %s\x1b[33m.%s "%s" =>${style.reset}`, scope),
|
|
103
|
+
error: isBrowser
|
|
104
|
+
? console.error.bind(console, '%c%s%c.%s "%s" =>', styleScope, scope, style.reset)
|
|
105
|
+
: console.error.bind(console, `${styleScope}❌ %s\x1b[31m.%s "%s" =>\x1b[0;2m`, scope),
|
|
106
106
|
};
|
|
107
107
|
if (!debug) {
|
|
108
108
|
return {
|
|
@@ -122,9 +122,9 @@ export const createLogger = (scope, color = getNextColor(), debug = getDebugStat
|
|
|
122
122
|
logMethod: console.debug.bind(console, keySection + '.%s();', styleScope, scope, style.reset),
|
|
123
123
|
logMethodArgs: console.debug.bind(console, keySection + '.%s(%o);', styleScope, scope, style.reset),
|
|
124
124
|
logMethodFull: console.debug.bind(console, keySection + '.%s(%o); // %o', styleScope, scope, style.reset),
|
|
125
|
-
incident: isBrowser
|
|
126
|
-
console.
|
|
127
|
-
console.log.bind(console, `${styleScope}🔸 %s${style.reset}.%s() => Incident: "%s" (%s)!\x1b[0;2m`, scope),
|
|
125
|
+
incident: isBrowser
|
|
126
|
+
? console.log.bind(console, '%c%s%c.%s() => Incident: "%s" (%s)!', styleScope, scope, style.reset)
|
|
127
|
+
: console.log.bind(console, `${styleScope}🔸 %s${style.reset}.%s() => Incident: "%s" (%s)!\x1b[0;2m`, scope),
|
|
128
128
|
logOther: console.debug.bind(console, keySection, styleScope, scope, style.reset),
|
|
129
129
|
};
|
|
130
130
|
};
|
package/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAGA,MAAM,SAAS,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC,MAAM,EAAE,cAAc,IAAI,EAAE,CAAC;AAC5E,UAAU,CAAC,MAAM,KAAjB,UAAU,CAAC,MAAM,GAAK,EAAC,cAAc,EAAE,oBAAoB,EAAC,EAAC;AAE7D,oBAAoB,CAAC,IAAI,CAAC;IACxB,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,oBAAoB,EAAE,mDAAmD;CACnF,CAAC,CAAC;AAEH;;GAEG;AACH,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAGA,MAAM,SAAS,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC,MAAM,EAAE,cAAc,IAAI,EAAE,CAAC;AAC5E,UAAU,CAAC,MAAM,KAAjB,UAAU,CAAC,MAAM,GAAK,EAAC,cAAc,EAAE,oBAAoB,EAAC,EAAC;AAE7D,oBAAoB,CAAC,IAAI,CAAC;IACxB,IAAI,EAAE,gBA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AAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;QAE7F,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;QAEnG,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;QAEzG,QAAQ,EAAE,SAAS;YACjB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,qCAAqC,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;YAClG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,UAAU,QAAQ,KAAK,CAAC,KAAK,wCAAwC,EAAE,KAAK,CAAC;QAE9G,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;KAClF,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/logger",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"log",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"tslib": "^2.3.1"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "f531925ca3db1072c0eaea90cb18e00802c93247"
|
|
38
38
|
}
|
package/type.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export interface AlwatrLogger {
|
|
|
76
76
|
*/
|
|
77
77
|
logMethodFull(method: string, args: Record<string, unknown> | string | number | boolean, result: unknown): void;
|
|
78
78
|
/**
|
|
79
|
-
* `console.
|
|
79
|
+
* `console.log` an event or expected accident. (not warn or error)
|
|
80
80
|
*
|
|
81
81
|
* Example:
|
|
82
82
|
*
|