@alwatr/logger 1.1.1 → 1.1.2
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 +6 -0
- package/README.md +1 -1
- package/logger.d.ts.map +1 -1
- package/logger.js +1 -1
- package/logger.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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
|
+
## [1.1.2](https://github.com/AliMD/alwatr/compare/@alwatr/logger@1.1.1...@alwatr/logger@1.1.2) (2023-09-12)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **logger:** change localStorage debug key to `alwatrDebug` ([66542ea](https://github.com/AliMD/alwatr/commit/66542ea22a9a515db4a15dc966624b3029f517ed)) by @AliMD
|
|
11
|
+
|
|
6
12
|
## [1.1.1](https://github.com/AliMD/alwatr/compare/@alwatr/logger@1.1.0...@alwatr/logger@1.1.1) (2023-09-12)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @alwatr/logger
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Many of the methods in the logger are no-ops when the debug mode is off in the b
|
|
|
20
20
|
Please remember to **reload** the window after changing the debug mode.
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
|
-
window.localStorage?.setItem('
|
|
23
|
+
window.localStorage?.setItem('alwatrDebug', '1');
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
> Make sure the [log level](https://developer.chrome.com/docs/devtools/console/log/#browser) in set correctly.
|
package/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAC,KAAK,YAAY,EAAE,YAAY,EAAC,CAAC;AAOzC,eAAO,MAAM,SAAS,SAAiC,CAAC;AACxD,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAC,KAAK,YAAY,EAAE,YAAY,EAAC,CAAC;AAOzC,eAAO,MAAM,SAAS,SAAiC,CAAC;AACxD,eAAO,MAAM,QAAQ,SAEsC,CAAC;AAmD5D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,WAAY,MAAM,wBAAuB,YA+CjE,CAAC"}
|
package/logger.js
CHANGED
|
@@ -7,7 +7,7 @@ globalAlwatr.registeredList.push({
|
|
|
7
7
|
export const NODE_MODE = typeof process !== 'undefined';
|
|
8
8
|
export const DEV_MODE = NODE_MODE
|
|
9
9
|
? process.env.ALWATR_DEBUG === '1'
|
|
10
|
-
: globalThis.localStorage?.getItem('
|
|
10
|
+
: globalThis.localStorage?.getItem('alwatrDebug') === '1';
|
|
11
11
|
/**
|
|
12
12
|
* Color list storage for logger.
|
|
13
13
|
*/
|
package/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAoB,YAAY,EAAC,CAAC;AAEzC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC;IAC/B,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,gBAAgB;CAC1B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO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E,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;QAEpF,QAAQ,EAAE,SAAS;YACjB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,UAAU,SAAS,MAAM,CAAC,KAAK,4BAA4B,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC;YACjH,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,+BAA+B,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC;QAEpG,IAAI,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,gBAAgB,CAAC;QAC9E,OAAO,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,gBAAgB,CAAC;KAC5E,CAAC;AACb,CAAC,CAAC","sourcesContent":["import {globalAlwatr} from './global-alwatr.js';\n\nimport type {AlwatrLogger} from './type.js';\n\nexport {type AlwatrLogger, globalAlwatr};\n\nglobalAlwatr.registeredList.push({\n name: '@alwatr/logger',\n version: _ALWATR_VERSION_,\n});\n\nexport const NODE_MODE = typeof process !== 'undefined';\nexport const DEV_MODE = NODE_MODE\n ? process.env.ALWATR_DEBUG === '1'\n : globalThis.localStorage?.getItem('alwatrDebug') === '1';\n\n/**\n * Color list storage for logger.\n */\nconst colorList = NODE_MODE\n ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // red and white omitted\n : [\n '#35b997',\n '#f05561',\n '#ee224a',\n '#91c13e',\n '#22af4b',\n '#f0e995',\n '#0fe995',\n '#0f89ca',\n '#08b9a5',\n '#fee851',\n '#ee573d',\n '#f9df30',\n '#1da2dc',\n '#f05123',\n '#ee2524',\n ];\n\nlet _colorIndex = 0;\nconst _getNextColor = (): string => {\n const color = colorList[_colorIndex];\n _colorIndex++;\n if (_colorIndex >= colorList.length) {\n _colorIndex = 0;\n }\n return color;\n};\n\nconst _style = {\n scope: NODE_MODE ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: NODE_MODE ? '\\x1b[0m' : 'color: inherit;',\n};\n\nconst _keySection = NODE_MODE ? '%s%s%s' : '%c%s%c';\n\nconst _sanitizeDomain = (domain: string): string => {\n domain = domain.trim();\n const first = domain.charAt(0);\n if (first !== '[' && first !== '{' && first !== '<') {\n domain = '[' + domain + ']';\n }\n return domain;\n};\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - **color** is optional and automatically select from internal fancy color list.\n * - **debug** is optional and automatically detect from localStorage `ALWATR_DEBUG` item or `process.env.ALWATR_DEBUG`\n *\n * Example:\n *\n * ```ts\n * import {createLogger} from 'https://esm.run/@alwatr/logger';\n * const logger = createLogger('logger/demo');\n * ```\n */\nexport const createLogger = (domain: string, devMode = DEV_MODE): AlwatrLogger => {\n const color = _getNextColor();\n const styleScope = _style.scope.replaceAll('{{color}}', color);\n domain = _sanitizeDomain(domain);\n\n /**\n * Required logger object, accident, error always reported even when the devMode is false.\n */\n const requiredItems = {\n devMode,\n domain,\n\n accident: NODE_MODE\n ? console.warn.bind(console, `${styleScope}⚠️\\n%s\\x1b[33m.%s() Accident \\`%s\\` %s!${_style.reset}`, domain)\n : console.warn.bind(console, '%c%s%c.%s() Accident `%s` %s!', styleScope, domain, _style.reset),\n\n error: NODE_MODE\n ? console.error.bind(console, `${styleScope}❌\\n%s\\x1b[31m.%s() Error \\`%s\\`${_style.reset}\\n`, domain)\n : console.error.bind(console, '%c%s%c.%s() Error `%s`\\n', styleScope, domain, _style.reset),\n } as const;\n\n if (!devMode) {\n return requiredItems;\n }\n // else\n return {\n ...requiredItems,\n\n logProperty: console.debug.bind(console, _keySection + '.%s = %o;', styleScope, domain, _style.reset),\n\n logMethod: console.debug.bind(console, _keySection + '.%s();', styleScope, domain, _style.reset),\n\n logModule: console.debug.bind(console, _keySection + '/%s.js;', styleScope, domain, _style.reset),\n\n logMethodArgs: console.debug.bind(console, _keySection + '.%s(%o);', styleScope, domain, _style.reset),\n\n logMethodFull: console.debug.bind(console, _keySection + '.%s(%o) => %o', styleScope, domain, _style.reset),\n\n logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset),\n\n incident: NODE_MODE\n ? console.log.bind(console, `${styleScope}🚸\\n%s${_style.reset}.%s() Incident \\`%s\\` %s!${_style.reset}`, domain)\n : console.log.bind(console, '%c%s%c.%s() Incident `%s` %s!', styleScope, domain, 'color: orange;'),\n\n time: (label: string) => console.time(domain + '.' + label + ' duration time'),\n timeEnd: (label: string) => console.timeEnd(domain + '.' + label + ' duration time'),\n } as const;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/logger",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"log",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"@alwatr/type": "^1.1.1",
|
|
36
36
|
"tslib": "^2.6.2"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "16036de8a6d781116e8c463ba41a2cb8cdc34edc"
|
|
39
39
|
}
|