@alwatr/logger 3.2.14 → 4.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/CHANGELOG.md +34 -0
- package/LICENSE +661 -21
- package/README.md +66 -16
- package/dist/logger.d.ts.map +1 -1
- package/dist/main.cjs +6 -6
- package/dist/main.cjs.map +4 -4
- package/dist/main.d.ts +0 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.mjs +6 -6
- package/dist/main.mjs.map +4 -4
- package/dist/type.d.ts +86 -37
- package/dist/type.d.ts.map +1 -1
- package/package.json +10 -10
- package/dist/define-package.d.ts +0 -16
- package/dist/define-package.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,35 +1,85 @@
|
|
|
1
|
-
|
|
1
|
+
## Logger
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A lightweight, flexible, and colorful console logging library for TypeScript and ES modules.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Features
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
* **Customizable Scopes:** Organize log messages using scopes for easy filtering and debugging.
|
|
8
|
+
* **Colorful Output:** Visually distinguish different log levels and scopes with vibrant colors.
|
|
9
|
+
* **Debug/Development Mode:** Control log verbosity to optimize performance in production environments.
|
|
10
|
+
* **Tiny Footprint:** Minimal overhead, keeping your project lean and efficient.
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
### Installation
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
```bash
|
|
15
|
+
npm install @alwatr/logger
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Usage
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { createLogger } from '@alwatr/logger';
|
|
22
|
+
|
|
23
|
+
const logger = createLogger('my-module'); // Create a logger with a specific scope
|
|
24
|
+
|
|
25
|
+
function greet(name: string) {
|
|
26
|
+
logger.logMethodArgs?.('greet', { name }); // Log the method call with its arguments
|
|
27
|
+
console.log(`Hello, ${name}!`);
|
|
14
28
|
}
|
|
29
|
+
|
|
30
|
+
greet('Ali');
|
|
15
31
|
```
|
|
16
32
|
|
|
17
|
-
###
|
|
33
|
+
### Log Levels and Methods
|
|
34
|
+
|
|
35
|
+
* **`logProperty(propertyName, value)`:** Logs a property change (useful for tracking state).
|
|
36
|
+
* **`logFileModule(fileName)`:** Logs the module's file name for easy identification.
|
|
37
|
+
* **`logMethod(methodName)`:** Logs the entry into a function or method.
|
|
38
|
+
* **`logMethodArgs(methodName, args)`:** Logs a method call with its arguments.
|
|
39
|
+
* **`logStep(methodName, stepName, props?)`:** Logs specific steps within a method.
|
|
40
|
+
* **`logMethodFull(methodName, args, result)`:** Logs a method call with arguments and result.
|
|
41
|
+
* **`incident(methodName, code, ...args)`:** Logs an event or expected incident (informational).
|
|
42
|
+
* **`accident(methodName, code, ...args)`:** Logs an unexpected incident or handled error (warning).
|
|
43
|
+
* **`error(methodName, code, ...args)`:** Logs an unexpected error (critical).
|
|
44
|
+
* **`logOther(...args)`:** General-purpose logging with styled scope.
|
|
45
|
+
* **`time(label)`:** Starts a timer.
|
|
46
|
+
* **`timeEnd(label)`:** Ends a timer and logs the elapsed time.
|
|
47
|
+
* **`banner(message)`:** Logs a large, prominent banner message.
|
|
18
48
|
|
|
19
|
-
|
|
49
|
+
### Enabling Debug Mode
|
|
20
50
|
|
|
21
51
|
#### Browser
|
|
22
52
|
|
|
23
|
-
|
|
24
|
-
|
|
53
|
+
1. Open your browser's developer tools.
|
|
54
|
+
2. Go to the "Application" or "Storage" tab.
|
|
55
|
+
3. Find "Local Storage" and locate your application's domain.
|
|
56
|
+
4. Add a new key-value pair: `debug` with the value `1`.
|
|
57
|
+
5. Reload the page.
|
|
58
|
+
|
|
59
|
+
Or use the following code snippet in the browser console:
|
|
25
60
|
|
|
26
|
-
|
|
61
|
+
```javascript
|
|
62
|
+
window.localStorage?.setItem('debug', '1');
|
|
27
63
|
```
|
|
28
64
|
|
|
29
|
-
>
|
|
65
|
+
> **Note:** Ensure the browser console's log level is set to include "Verbose" or "All" to see debug messages.
|
|
30
66
|
|
|
31
|
-
####
|
|
67
|
+
#### Node.js
|
|
32
68
|
|
|
33
|
-
```
|
|
69
|
+
```bash
|
|
34
70
|
DEBUG=1 node index.js
|
|
35
71
|
```
|
|
72
|
+
|
|
73
|
+
## Sponsors
|
|
74
|
+
|
|
75
|
+
The following companies, organizations, and individuals support Nitrobase ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.
|
|
76
|
+
|
|
77
|
+
[](https://exirstudio.com)
|
|
78
|
+
|
|
79
|
+
### Contributing
|
|
80
|
+
|
|
81
|
+
Contributions are welcome! Please read our [contribution guidelines](https://github.com/Alwatr/.github/blob/next/CONTRIBUTING.md) before submitting a pull request.
|
|
82
|
+
|
|
83
|
+
### License
|
|
84
|
+
|
|
85
|
+
This project is licensed under the [AGPL-3.0 License](LICENSE).
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AA2D5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,WAAY,MAAM,0BAAiC,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AA2D5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,WAAY,MAAM,0BAAiC,YAwD3E,CAAC"}
|
package/dist/main.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* @alwatr/logger
|
|
2
|
-
"use strict";var
|
|
3
|
-
%s\x1B[33m.%s() Accident \`%s\`!${
|
|
4
|
-
%s\x1B[31m.%s() Error \`%s\`${
|
|
5
|
-
`,e):console.error.bind(console,"%c%s%c.%s() Error `%s`\n",
|
|
6
|
-
%s${
|
|
1
|
+
/* @alwatr/logger v4.0.1 */
|
|
2
|
+
"use strict";var b=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var _=(e,o)=>{for(var l in o)b(e,l,{get:o[l],enumerable:!0})},x=(e,o,l,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of u(o))!a.call(e,t)&&t!==l&&b(e,t,{get:()=>o[t],enumerable:!(s=p(o,t))||s.enumerable});return e};var C=e=>x(b({},"__esModule",{value:!0}),e);var A={};_(A,{createLogger:()=>y});module.exports=C(A);var f=require("@alwatr/package-tracer"),c=require("@alwatr/platform-info");f.packageTracer.add("@alwatr/logger","4.0.1");var m=c.platformInfo.development||(c.platformInfo.isCli?process.env.DEBUG!==void 0&&process.env.DEBUG!=="":typeof localStorage<"u"&&localStorage.getItem("debug")==="1"),d=c.platformInfo.isCli?["0;36","0;35","0;34","0;33","0;32"]:["#35b997","#f05561","#ee224a","#91c13e","#22af4b","#f0e995","#0fe995","#0f89ca","#08b9a5","#fee851","#ee573d","#f9df30","#1da2dc","#f05123","#ee2524"],i=0,$=()=>{let e=d[i];return i++,i>=d.length&&(i=0),e},r={scope:c.platformInfo.isCli?"\x1B[{{color}}m":"color: {{color}};",reset:c.platformInfo.isCli?"\x1B[0m":"color: inherit;"},n=c.platformInfo.isCli?"%s%s%s":"%c%s%c",h=e=>{e=e.trim();let o=e.charAt(0);return o!=="["&&o!=="{"&&o!=="<"&&(e="["+e+"]"),e},y=(e,o=m)=>{let l=$(),s=r.scope.replace("{{color}}",l);e=h(e);let t={debugMode:o,banner:c.platformInfo.isCli?console.log.bind(console,`\x1B[1;37;45m {{{ %s }}} ${r.reset}`):console.log.bind(console,"%c%s","font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;"),accident:c.platformInfo.isCli?console.warn.bind(console,`${s}⚠️
|
|
3
|
+
%s\x1B[33m.%s() Accident \`%s\`!${r.reset}`,e):console.warn.bind(console,"%c%s%c.%s() Accident `%s`!",s,e,r.reset),error:c.platformInfo.isCli?console.error.bind(console,`${s}❌
|
|
4
|
+
%s\x1B[31m.%s() Error \`%s\`${r.reset}
|
|
5
|
+
`,e):console.error.bind(console,"%c%s%c.%s() Error `%s`\n",s,e,r.reset)};return o?{...t,logProperty:console.debug.bind(console,n+".%s = %o;",s,e,r.reset),logMethod:console.debug.bind(console,n+".%s();",s,e,r.reset),logFileModule:console.debug.bind(console,n+"/%s.js;",s,e,r.reset),logMethodArgs:console.debug.bind(console,n+".%s(%o);",s,e,r.reset),logMethodFull:console.debug.bind(console,n+".%s(%o) => %o",s,e,r.reset),logStep:console.debug.bind(console,n+".%s() -> %s",s,e,r.reset),logOther:console.debug.bind(console,n,s,e,r.reset),incident:c.platformInfo.isCli?console.log.bind(console,`${s}🚸
|
|
6
|
+
%s${r.reset}.%s() Incident \`%s\`!${r.reset}`,e):console.log.bind(console,"%c%s%c.%s() Incident `%s`!",s,e,"color: orange;"),time:g=>console.time(e+"."+g+" duration time"),timeEnd:g=>console.timeEnd(e+"."+g+" duration time")}:t};0&&(module.exports={createLogger});
|
|
7
7
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/main.ts", "../src/logger.ts"
|
|
4
|
-
"sourcesContent": ["export * from './logger.js';\nexport * from './
|
|
5
|
-
"mappings": ";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,
|
|
6
|
-
"names": ["main_exports", "__export", "createLogger", "
|
|
3
|
+
"sources": ["../src/main.ts", "../src/logger.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './logger.js';\nexport * from './type.js';\n", "import {packageTracer} from '@alwatr/package-tracer';\nimport {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\npackageTracer.add(__package_name__, __package_version__);\n\nconst defaultDebugMode =\n platformInfo.development ||\n (platformInfo.isCli\n ? process.env.DEBUG !== undefined && process.env.DEBUG !== ''\n : typeof localStorage !== 'undefined' && localStorage.getItem('debug') === '1');\n\n/**\n * Color list storage for logger.\n */\nconst colorList = platformInfo.isCli\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: platformInfo.isCli ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: platformInfo.isCli ? '\\x1b[0m' : 'color: inherit;',\n};\n\nconst _keySection = platformInfo.isCli ? '%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, debugMode = defaultDebugMode): AlwatrLogger => {\n const color = _getNextColor();\n const styleScope = _style.scope.replace('{{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: AlwatrLogger = {\n debugMode,\n\n banner: platformInfo.isCli\n ? console.log.bind(console, `\\x1b[1;37;45m {{{ %s }}} ${_style.reset}`)\n : console.log.bind(\n console,\n '%c%s',\n 'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;',\n ),\n\n accident: platformInfo.isCli\n ? console.warn.bind(console, `${styleScope}⚠️\\n%s\\x1b[33m.%s() Accident \\`%s\\`!${_style.reset}`, domain)\n : console.warn.bind(console, '%c%s%c.%s() Accident `%s`!', styleScope, domain, _style.reset),\n\n error: platformInfo.isCli\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 };\n\n if (!debugMode) {\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 logFileModule: 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 logStep: console.debug.bind(console, _keySection + '.%s() -> %s', styleScope, domain, _style.reset),\n\n logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset),\n\n incident: platformInfo.isCli\n ? console.log.bind(console, `${styleScope}🚸\\n%s${_style.reset}.%s() Incident \\`%s\\`!${_style.reset}`, domain)\n : console.log.bind(console, '%c%s%c.%s() Incident `%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"],
|
|
5
|
+
"mappings": ";yaAAA,IAAAA,EAA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_package_tracer", "import_platform_info", "defaultDebugMode", "colorList", "_colorIndex", "_getNextColor", "color", "_style", "_keySection", "_sanitizeDomain", "domain", "first", "createLogger", "debugMode", "styleScope", "requiredItems", "label"]
|
|
7
7
|
}
|
package/dist/main.d.ts
CHANGED
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
package/dist/main.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* @alwatr/logger
|
|
2
|
-
import{
|
|
3
|
-
%s\x1B[33m.%s() Accident \`%s\`!${
|
|
4
|
-
%s\x1B[31m.%s() Error \`%s\`${
|
|
5
|
-
`,e):console.error.bind(console,"%c%s%c.%s() Error `%s`\n",
|
|
6
|
-
%s${
|
|
1
|
+
/* @alwatr/logger v4.0.1 */
|
|
2
|
+
import{packageTracer as d}from"@alwatr/package-tracer";import{platformInfo as r}from"@alwatr/platform-info";d.add("@alwatr/logger","4.0.1");var f=r.development||(r.isCli?process.env.DEBUG!==void 0&&process.env.DEBUG!=="":typeof localStorage<"u"&&localStorage.getItem("debug")==="1"),g=r.isCli?["0;36","0;35","0;34","0;33","0;32"]:["#35b997","#f05561","#ee224a","#91c13e","#22af4b","#f0e995","#0fe995","#0f89ca","#08b9a5","#fee851","#ee573d","#f9df30","#1da2dc","#f05123","#ee2524"],n=0,p=()=>{let e=g[n];return n++,n>=g.length&&(n=0),e},o={scope:r.isCli?"\x1B[{{color}}m":"color: {{color}};",reset:r.isCli?"\x1B[0m":"color: inherit;"},c=r.isCli?"%s%s%s":"%c%s%c",u=e=>{e=e.trim();let t=e.charAt(0);return t!=="["&&t!=="{"&&t!=="<"&&(e="["+e+"]"),e},x=(e,t=f)=>{let b=p(),s=o.scope.replace("{{color}}",b);e=u(e);let i={debugMode:t,banner:r.isCli?console.log.bind(console,`\x1B[1;37;45m {{{ %s }}} ${o.reset}`):console.log.bind(console,"%c%s","font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;"),accident:r.isCli?console.warn.bind(console,`${s}⚠️
|
|
3
|
+
%s\x1B[33m.%s() Accident \`%s\`!${o.reset}`,e):console.warn.bind(console,"%c%s%c.%s() Accident `%s`!",s,e,o.reset),error:r.isCli?console.error.bind(console,`${s}❌
|
|
4
|
+
%s\x1B[31m.%s() Error \`%s\`${o.reset}
|
|
5
|
+
`,e):console.error.bind(console,"%c%s%c.%s() Error `%s`\n",s,e,o.reset)};return t?{...i,logProperty:console.debug.bind(console,c+".%s = %o;",s,e,o.reset),logMethod:console.debug.bind(console,c+".%s();",s,e,o.reset),logFileModule:console.debug.bind(console,c+"/%s.js;",s,e,o.reset),logMethodArgs:console.debug.bind(console,c+".%s(%o);",s,e,o.reset),logMethodFull:console.debug.bind(console,c+".%s(%o) => %o",s,e,o.reset),logStep:console.debug.bind(console,c+".%s() -> %s",s,e,o.reset),logOther:console.debug.bind(console,c,s,e,o.reset),incident:r.isCli?console.log.bind(console,`${s}🚸
|
|
6
|
+
%s${o.reset}.%s() Incident \`%s\`!${o.reset}`,e):console.log.bind(console,"%c%s%c.%s() Incident `%s`!",s,e,"color: orange;"),time:l=>console.time(e+"."+l+" duration time"),timeEnd:l=>console.timeEnd(e+"."+l+" duration time")}:i};export{x as createLogger};
|
|
7
7
|
//# sourceMappingURL=main.mjs.map
|
package/dist/main.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/logger.ts"
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";AAAA,OAAQ,iBAAAA,MAAoB,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../src/logger.ts"],
|
|
4
|
+
"sourcesContent": ["import {packageTracer} from '@alwatr/package-tracer';\nimport {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\npackageTracer.add(__package_name__, __package_version__);\n\nconst defaultDebugMode =\n platformInfo.development ||\n (platformInfo.isCli\n ? process.env.DEBUG !== undefined && process.env.DEBUG !== ''\n : typeof localStorage !== 'undefined' && localStorage.getItem('debug') === '1');\n\n/**\n * Color list storage for logger.\n */\nconst colorList = platformInfo.isCli\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: platformInfo.isCli ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: platformInfo.isCli ? '\\x1b[0m' : 'color: inherit;',\n};\n\nconst _keySection = platformInfo.isCli ? '%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, debugMode = defaultDebugMode): AlwatrLogger => {\n const color = _getNextColor();\n const styleScope = _style.scope.replace('{{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: AlwatrLogger = {\n debugMode,\n\n banner: platformInfo.isCli\n ? console.log.bind(console, `\\x1b[1;37;45m {{{ %s }}} ${_style.reset}`)\n : console.log.bind(\n console,\n '%c%s',\n 'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;',\n ),\n\n accident: platformInfo.isCli\n ? console.warn.bind(console, `${styleScope}⚠️\\n%s\\x1b[33m.%s() Accident \\`%s\\`!${_style.reset}`, domain)\n : console.warn.bind(console, '%c%s%c.%s() Accident `%s`!', styleScope, domain, _style.reset),\n\n error: platformInfo.isCli\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 };\n\n if (!debugMode) {\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 logFileModule: 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 logStep: console.debug.bind(console, _keySection + '.%s() -> %s', styleScope, domain, _style.reset),\n\n logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset),\n\n incident: platformInfo.isCli\n ? console.log.bind(console, `${styleScope}🚸\\n%s${_style.reset}.%s() Incident \\`%s\\`!${_style.reset}`, domain)\n : console.log.bind(console, '%c%s%c.%s() Incident `%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"],
|
|
5
|
+
"mappings": ";AAAA,OAAQ,iBAAAA,MAAoB,yBAC5B,OAAQ,gBAAAC,MAAmB,wBAI3BD,EAAc,IAAI,iBAAkB,OAAmB,EAEvD,IAAME,EACJD,EAAa,cACZA,EAAa,MACV,QAAQ,IAAI,QAAU,QAAa,QAAQ,IAAI,QAAU,GACzD,OAAO,aAAiB,KAAe,aAAa,QAAQ,OAAO,IAAM,KAKzEE,EAAYF,EAAa,MAC3B,CAAC,OAAQ,OAAQ,OAAQ,OAAQ,MAAM,EACvC,CACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,SACF,EAEEG,EAAc,EACZC,EAAgB,IAAc,CAClC,IAAMC,EAAQH,EAAUC,CAAW,EACnC,OAAAA,IACIA,GAAeD,EAAU,SAC3BC,EAAc,GAETE,CACT,EAEMC,EAAS,CACb,MAAON,EAAa,MAAQ,kBAAoB,oBAChD,MAAOA,EAAa,MAAQ,UAAY,iBAC1C,EAEMO,EAAcP,EAAa,MAAQ,SAAW,SAE9CQ,EAAmBC,GAA2B,CAClDA,EAASA,EAAO,KAAK,EACrB,IAAMC,EAAQD,EAAO,OAAO,CAAC,EAC7B,OAAIC,IAAU,KAAOA,IAAU,KAAOA,IAAU,MAC9CD,EAAS,IAAMA,EAAS,KAEnBA,CACT,EAeaE,EAAe,CAACF,EAAgBG,EAAYX,IAAmC,CAC1F,IAAMI,EAAQD,EAAc,EACtBS,EAAaP,EAAO,MAAM,QAAQ,YAAaD,CAAK,EAC1DI,EAASD,EAAgBC,CAAM,EAK/B,IAAMK,EAA8B,CAClC,UAAAF,EAEA,OAAQZ,EAAa,MACjB,QAAQ,IAAI,KAAK,QAAS,4BAA4BM,EAAO,KAAK,EAAE,EACpE,QAAQ,IAAI,KACZ,QACA,OACA,qGACF,EAEF,SA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MM,EAAQ,gBAAgB,CACrF,EA1BSD,CA2BX",
|
|
6
|
+
"names": ["packageTracer", "platformInfo", "defaultDebugMode", "colorList", "_colorIndex", "_getNextColor", "color", "_style", "_keySection", "_sanitizeDomain", "domain", "first", "createLogger", "debugMode", "styleScope", "requiredItems", "label"]
|
|
7
7
|
}
|
package/dist/type.d.ts
CHANGED
|
@@ -1,61 +1,97 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Represents the AlwatrLogger interface.
|
|
3
|
-
*
|
|
2
|
+
* Represents the AlwatrLogger interface for logging various types of information at different levels of detail.
|
|
3
|
+
* This interface allows for structured logging of events, method calls, errors, and more,
|
|
4
|
+
* aiding in debugging and understanding application behavior.
|
|
4
5
|
*/
|
|
5
6
|
export interface AlwatrLogger {
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Indicates whether debug mode is enabled for the current scope.
|
|
9
|
+
* This state is typically determined based on the `debug` pattern in localStorage.
|
|
8
10
|
*/
|
|
9
11
|
debugMode: boolean;
|
|
10
12
|
/**
|
|
11
|
-
* `console.debug
|
|
13
|
+
* Logs a property change with its new value using `console.debug`. Useful for tracking changes in application state.
|
|
12
14
|
*
|
|
13
|
-
*
|
|
15
|
+
* @param propertyName The name of the property that has changed.
|
|
16
|
+
* @param value The new value of the property.
|
|
14
17
|
*
|
|
18
|
+
* @example
|
|
15
19
|
* ```ts
|
|
16
20
|
* logger.logProperty?.('name', 'ali');
|
|
17
21
|
* ```
|
|
18
22
|
*/
|
|
19
|
-
logProperty?(
|
|
23
|
+
logProperty?(propertyName: string, value: unknown): void;
|
|
20
24
|
/**
|
|
21
|
-
* `console.debug
|
|
25
|
+
* Logs the file name of the current module using `console.debug`.
|
|
26
|
+
* Helpful for identifying the source of log messages.
|
|
22
27
|
*
|
|
23
|
-
*
|
|
28
|
+
* @param fileName The name of the file representing the module.
|
|
24
29
|
*
|
|
30
|
+
* @example
|
|
25
31
|
* ```ts
|
|
26
|
-
* logger.
|
|
32
|
+
* logger.logFileModule?.('app');
|
|
27
33
|
* ```
|
|
28
34
|
*/
|
|
29
|
-
|
|
35
|
+
logFileModule?(fileName: string): void;
|
|
30
36
|
/**
|
|
31
|
-
*
|
|
37
|
+
* Logs the entry into a function or method using `console.debug`.
|
|
38
|
+
* Provides a basic trace of program execution.
|
|
32
39
|
*
|
|
33
|
-
*
|
|
40
|
+
* @param methodName The name of the function or method being called.
|
|
34
41
|
*
|
|
42
|
+
* @example
|
|
35
43
|
* ```ts
|
|
36
44
|
* function myMethod () {
|
|
37
45
|
* logger.logMethod?.('myMethod');
|
|
38
46
|
* }
|
|
39
47
|
* ```
|
|
40
48
|
*/
|
|
41
|
-
logMethod?(
|
|
49
|
+
logMethod?(methodName: string): void;
|
|
42
50
|
/**
|
|
43
|
-
*
|
|
51
|
+
* Logs the entry into a function or method along with its arguments using `console.debug`.
|
|
52
|
+
* Aids in understanding the context of method calls.
|
|
44
53
|
*
|
|
45
|
-
*
|
|
54
|
+
* @param methodName The name of the function or method being called.
|
|
55
|
+
* @param args An object containing the arguments passed to the method.
|
|
46
56
|
*
|
|
57
|
+
* @example
|
|
47
58
|
* ```ts
|
|
48
59
|
* function myMethod (a: number, b: number) {
|
|
49
60
|
* logger.logMethodArgs?.('myMethod', {a, b});
|
|
50
61
|
* }
|
|
51
62
|
* ```
|
|
52
63
|
*/
|
|
53
|
-
logMethodArgs?(
|
|
64
|
+
logMethodArgs?(methodName: string, args: unknown): void;
|
|
54
65
|
/**
|
|
55
|
-
*
|
|
66
|
+
* Logs specific steps or milestones within a method using `console.debug`.
|
|
67
|
+
* Facilitates tracking progress within complex functions.
|
|
56
68
|
*
|
|
57
|
-
*
|
|
69
|
+
* @param methodName The name of the method where the step occurs.
|
|
70
|
+
* @param stepName The name or identifier of the specific step.
|
|
71
|
+
* @param props (Optional) Additional properties or data related to the step.
|
|
58
72
|
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* function myMethod () {
|
|
76
|
+
* logger.logMethod?.('myMethod');
|
|
77
|
+
* ...
|
|
78
|
+
* logger.logStep?.('myMethod', 'step1');
|
|
79
|
+
* ...
|
|
80
|
+
* logger.logStep?.('myMethod', 'step2');
|
|
81
|
+
* ...
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
logStep?(methodName: string, stepName: string, props?: unknown): void;
|
|
86
|
+
/**
|
|
87
|
+
* Logs a complete method call, including its arguments and result, using `console.debug`.
|
|
88
|
+
* Useful for debugging and understanding the output of functions.
|
|
89
|
+
*
|
|
90
|
+
* @param methodName The name of the function or method being called.
|
|
91
|
+
* @param args An object containing the arguments passed to the method.
|
|
92
|
+
* @param result The result returned by the method.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
59
95
|
* ```ts
|
|
60
96
|
* function add (a: number, b: number): number {
|
|
61
97
|
* const result = a + b;
|
|
@@ -64,33 +100,42 @@ export interface AlwatrLogger {
|
|
|
64
100
|
* }
|
|
65
101
|
* ```
|
|
66
102
|
*/
|
|
67
|
-
logMethodFull?(
|
|
103
|
+
logMethodFull?(methodName: string, args: unknown, result: unknown): void;
|
|
68
104
|
/**
|
|
69
|
-
* `console.log
|
|
70
|
-
* not warn or error just important information.
|
|
105
|
+
* Logs an event or expected incident using `console.log`. Intended for noteworthy information that doesn't represent an error or warning.
|
|
71
106
|
*
|
|
72
|
-
*
|
|
107
|
+
* @param methodName The name or context of the event or incident.
|
|
108
|
+
* @param warningCode A code or identifier for the specific type of event or incident.
|
|
109
|
+
* @param args Additional details or context related to the event or incident.
|
|
73
110
|
*
|
|
111
|
+
* @example
|
|
74
112
|
* ```ts
|
|
75
113
|
* logger.incident?.('fetch', 'abort_signal', {url: '/test.json'});
|
|
76
114
|
* ```
|
|
77
115
|
*/
|
|
78
|
-
incident?(
|
|
116
|
+
incident?(methodName: string, warningCode: string, ...args: unknown[]): void;
|
|
79
117
|
/**
|
|
80
|
-
*
|
|
118
|
+
* Logs an unexpected incident or handled error as a warning using `console.warn`.
|
|
119
|
+
* Indicates a potential issue that has been addressed but warrants attention.
|
|
81
120
|
*
|
|
82
|
-
*
|
|
121
|
+
* @param methodName The name or context of the incident or error.
|
|
122
|
+
* @param warningCode A code or identifier for the specific type of incident or error.
|
|
123
|
+
* @param args Additional details or context related to the incident or error.
|
|
83
124
|
*
|
|
125
|
+
* @example
|
|
84
126
|
* ```ts
|
|
85
127
|
* logger.accident('fetch', 'file_not_found', {url: '/test.json'});
|
|
86
128
|
* ```
|
|
87
129
|
*/
|
|
88
|
-
accident(
|
|
130
|
+
accident(methodName: string, warningCode: string, ...args: unknown[]): void;
|
|
89
131
|
/**
|
|
90
|
-
* `console.error
|
|
132
|
+
* Logs an unexpected error using `console.error`. Highlights critical issues that need to be addressed.
|
|
91
133
|
*
|
|
92
|
-
*
|
|
134
|
+
* @param methodName The name or context where the error occurred.
|
|
135
|
+
* @param errorCode A code or identifier for the specific type of error.
|
|
136
|
+
* @param args Additional details or context related to the error, including the error object itself.
|
|
93
137
|
*
|
|
138
|
+
* @example
|
|
94
139
|
* ```ts
|
|
95
140
|
* try {
|
|
96
141
|
* ...
|
|
@@ -100,42 +145,46 @@ export interface AlwatrLogger {
|
|
|
100
145
|
* }
|
|
101
146
|
* ```
|
|
102
147
|
*/
|
|
103
|
-
error(
|
|
148
|
+
error(methodName: string, errorCode: string, ...args: unknown[]): void;
|
|
104
149
|
/**
|
|
105
|
-
*
|
|
150
|
+
* Performs a simple `console.debug` log with styled scope for general debugging purposes.
|
|
106
151
|
*
|
|
107
|
-
*
|
|
152
|
+
* @param args Any number of arguments to be logged.
|
|
108
153
|
*
|
|
154
|
+
* @example
|
|
109
155
|
* ```ts
|
|
110
156
|
* logger.logOther?.('foo:', 'bar', {a: 1});
|
|
111
157
|
* ```
|
|
112
158
|
*/
|
|
113
159
|
logOther?(...args: unknown[]): void;
|
|
114
160
|
/**
|
|
115
|
-
*
|
|
161
|
+
* Starts a timer with a specified label using `console.time`. Useful for measuring performance.
|
|
116
162
|
*
|
|
117
|
-
*
|
|
163
|
+
* @param label The label for the timer.
|
|
118
164
|
*
|
|
165
|
+
* @example
|
|
119
166
|
* ```ts
|
|
120
167
|
* logger.time?.('foo');
|
|
121
168
|
* ```
|
|
122
169
|
*/
|
|
123
170
|
time?(label: string): void;
|
|
124
171
|
/**
|
|
125
|
-
*
|
|
172
|
+
* Ends a timer with a specified label and logs the elapsed time using `console.timeEnd`.
|
|
126
173
|
*
|
|
127
|
-
*
|
|
174
|
+
* @param label The label for the timer.
|
|
128
175
|
*
|
|
176
|
+
* @example
|
|
129
177
|
* ```ts
|
|
130
178
|
* logger.timeEnd?.('foo');
|
|
131
179
|
* ```
|
|
132
180
|
*/
|
|
133
181
|
timeEnd?(label: string): void;
|
|
134
182
|
/**
|
|
135
|
-
*
|
|
183
|
+
* Logs a prominent banner message, typically used for displaying important announcements or version information.
|
|
136
184
|
*
|
|
137
|
-
*
|
|
185
|
+
* @param message The message to be displayed in the banner.
|
|
138
186
|
*
|
|
187
|
+
* @example
|
|
139
188
|
* ```ts
|
|
140
189
|
* logger.banner('Alwatr PWA v2');
|
|
141
190
|
* ```
|
package/dist/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,WAAW,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAEzD;;;;;;;;;;OAUG;IACH,aAAa,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvC;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM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|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/logger",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.",
|
|
5
5
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
6
|
"keywords": [
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"require": "./dist/main.cjs"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
-
"license": "
|
|
36
|
+
"license": "AGPL-3.0-only",
|
|
37
37
|
"files": [
|
|
38
38
|
"**/*.{js,mjs,cjs,map,d.ts,html,md}",
|
|
39
39
|
"!demo/**/*"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"c": "yarn run clean",
|
|
58
58
|
"cb": "yarn run clean && yarn run build",
|
|
59
59
|
"d": "yarn run build:es && yarn node --enable-source-maps --trace-warnings",
|
|
60
|
-
"build": "yarn run build:ts
|
|
60
|
+
"build": "yarn run build:ts && yarn run build:es",
|
|
61
61
|
"build:es": "nano-build --preset=module",
|
|
62
62
|
"build:ts": "tsc --build",
|
|
63
63
|
"watch": "yarn run watch:ts & yarn run watch:es",
|
|
@@ -66,15 +66,15 @@
|
|
|
66
66
|
"clean": "rm -rfv dist *.tsbuildinfo"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@alwatr/
|
|
70
|
-
"@alwatr/platform-info": "^1.1
|
|
69
|
+
"@alwatr/package-tracer": "^1.0.1",
|
|
70
|
+
"@alwatr/platform-info": "^1.2.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@alwatr/nano-build": "^1.
|
|
74
|
-
"@alwatr/prettier-config": "^1.0.
|
|
75
|
-
"@alwatr/tsconfig-base": "^1.
|
|
76
|
-
"@types/node": "^22.
|
|
73
|
+
"@alwatr/nano-build": "^1.5.0",
|
|
74
|
+
"@alwatr/prettier-config": "^1.0.5",
|
|
75
|
+
"@alwatr/tsconfig-base": "^1.3.0",
|
|
76
|
+
"@types/node": "^22.7.4",
|
|
77
77
|
"typescript": "^5.6.2"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "41bd9f5a9ffe1f7306b24e63684b1895428f44b0"
|
|
80
80
|
}
|
package/dist/define-package.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { AlwatrLogger } from './type.js';
|
|
2
|
-
/**
|
|
3
|
-
* Global define package for managing package versions to prevent version conflicts and return package level logger.
|
|
4
|
-
* @param packageName package name including scope. e.g. `@scope/package-name`
|
|
5
|
-
* @param version package version (optional)
|
|
6
|
-
* @returns AlwatrLogger for the package
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const logger = definePackage('@scope/package-name', __package_version__);
|
|
11
|
-
*
|
|
12
|
-
* logger.logMethodArgs?.('myMethod', {a, b});
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare function definePackage(packageName: string, version?: string, debugMode?: boolean): AlwatrLogger;
|
|
16
|
-
//# sourceMappingURL=define-package.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-package.d.ts","sourceRoot":"","sources":["../src/define-package.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,SAAO,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,YAAY,CAKpG"}
|