@alwatr/logger 3.2.13 → 4.0.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/README.md CHANGED
@@ -1,35 +1,85 @@
1
- # Logger
1
+ ## Logger
2
2
 
3
- Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.
3
+ A lightweight, flexible, and colorful console logging library for TypeScript and ES modules.
4
4
 
5
- ## Example usage
5
+ ### Features
6
6
 
7
- ```ts
8
- import {createLogger} from '@alwatr/logger';
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
- const logger = createLogger('demo');
12
+ ### Installation
11
13
 
12
- function sayHello(name: string) {
13
- logger.logMethodArgs?.('sayHello', {name});
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
- ### Debug/Develope Mode (DEBUG_MODE)
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
- Many of the methods in the logger are no-ops when the debug mode is off. This is to prevent unnecessary performance impact in production.
49
+ ### Enabling Debug Mode
20
50
 
21
51
  #### Browser
22
52
 
23
- ```ts
24
- window.localStorage?.setItem('debug', '1');
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
- // Please remember to **reload** the window after changing the debug mode.
61
+ ```javascript
62
+ window.localStorage?.setItem('debug', '1');
27
63
  ```
28
64
 
29
- > Make sure the [log level](https://developer.chrome.com/docs/devtools/console/log/#browser) in set correctly.
65
+ > **Note:** Ensure the browser console's log level is set to include "Verbose" or "All" to see debug messages.
30
66
 
31
- #### CLI
67
+ #### Node.js
32
68
 
33
- ```sh
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
+ [![Exir Studio](https://avatars.githubusercontent.com/u/181194967?s=200&v=4)](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).
@@ -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,YAsD3E,CAAC"}
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 v3.2.13 */
2
- "use strict";var f=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var _=(e,o)=>{for(var n in o)f(e,n,{get:o[n],enumerable:!0})},A=(e,o,n,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of m(o))!x.call(e,c)&&c!==n&&f(e,c,{get:()=>o[c],enumerable:!(r=u(o,c))||r.enumerable});return e};var C=e=>A(f({},"__esModule",{value:!0}),e);var L={};_(L,{createLogger:()=>d,definePackage:()=>w});module.exports=C(L);var p=require("@alwatr/dedupe"),t=require("@alwatr/platform-info");(0,p.definePackage)("@alwatr/logger","3.2.13");var y=t.platformInfo.development||(t.platformInfo.isCli?process.env.DEBUG!==void 0&&process.env.DEBUG!=="":typeof localStorage<"u"&&localStorage.getItem("debug")==="1"),b=t.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=b[i];return i++,i>=b.length&&(i=0),e},s={scope:t.platformInfo.isCli?"\x1B[{{color}}m":"color: {{color}};",reset:t.platformInfo.isCli?"\x1B[0m":"color: inherit;"},l=t.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},d=(e,o=y)=>{let n=$(),r=s.scope.replace("{{color}}",n);e=h(e);let c={debugMode:o,banner:t.platformInfo.isCli?console.log.bind(console,`\x1B[1;37;45m {{{ %s }}} ${s.reset}`):console.log.bind(console,"%c%s","font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;"),accident:t.platformInfo.isCli?console.warn.bind(console,`${r}⚠️
3
- %s\x1B[33m.%s() Accident \`%s\`!${s.reset}`,e):console.warn.bind(console,"%c%s%c.%s() Accident `%s`!",r,e,s.reset),error:t.platformInfo.isCli?console.error.bind(console,`${r}❌
4
- %s\x1B[31m.%s() Error \`%s\`${s.reset}
5
- `,e):console.error.bind(console,"%c%s%c.%s() Error `%s`\n",r,e,s.reset)};return o?{...c,logProperty:console.debug.bind(console,l+".%s = %o;",r,e,s.reset),logMethod:console.debug.bind(console,l+".%s();",r,e,s.reset),logModule:console.debug.bind(console,l+"/%s.js;",r,e,s.reset),logMethodArgs:console.debug.bind(console,l+".%s(%o);",r,e,s.reset),logMethodFull:console.debug.bind(console,l+".%s(%o) => %o",r,e,s.reset),logOther:console.debug.bind(console,l,r,e,s.reset),incident:t.platformInfo.isCli?console.log.bind(console,`${r}🚸
6
- %s${s.reset}.%s() Incident \`%s\`!${s.reset}`,e):console.log.bind(console,"%c%s%c.%s() Incident `%s`!",r,e,"color: orange;"),time:g=>console.time(e+"."+g+" duration time"),timeEnd:g=>console.timeEnd(e+"."+g+" duration time")}:c};var a=require("@alwatr/dedupe");function w(e,o="v?",n){let r=d(`{${e}}`,n);return r.logMethodArgs?.("define-package",{packageName:e,version:o}),(0,a.definePackage)(e,o),r}0&&(module.exports={createLogger,definePackage});
1
+ /* @alwatr/logger v4.0.0 */
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.0");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", "../src/define-package.ts"],
4
- "sourcesContent": ["export * from './logger.js';\nexport * from './define-package.js';\nexport * from './type.js';\n", "import {definePackage} from '@alwatr/dedupe';\nimport {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\ndefinePackage('@alwatr/logger', __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 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: 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", "import {definePackage as definePackage_} from '@alwatr/dedupe';\n\nimport {createLogger} from './logger.js';\n\nimport type {AlwatrLogger} from './type.js';\n\n/**\n * Global define package for managing package versions to prevent version conflicts and return package level logger.\n * @param packageName package name including scope. e.g. `@scope/package-name`\n * @param version package version (optional)\n * @returns AlwatrLogger for the package\n *\n * @example\n * ```typescript\n * const logger = definePackage('@scope/package-name', __package_version__);\n *\n * logger.logMethodArgs?.('myMethod', {a, b});\n * ```\n */\nexport function definePackage(packageName: string, version = 'v?', debugMode?: boolean): AlwatrLogger {\n const logger = createLogger(`{${packageName}}`, debugMode);\n logger.logMethodArgs?.('define-package', {packageName, version});\n definePackage_(packageName, version);\n return logger;\n}\n"],
5
- "mappings": ";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAA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EAAO,gBAAgB,iBAAkB,CAAC,YAAAH,EAAa,QAAAC,CAAO,CAAC,KAC/D,EAAAI,eAAeL,EAAaC,CAAO,EAC5BE,CACT",
6
- "names": ["main_exports", "__export", "createLogger", "definePackage", "__toCommonJS", "import_dedupe", "import_platform_info", "defaultDebugMode", "colorList", "_colorIndex", "_getNextColor", "color", "_style", "_keySection", "_sanitizeDomain", "domain", "first", "createLogger", "debugMode", "styleScope", "requiredItems", "label", "import_dedupe", "definePackage", "packageName", "version", "debugMode", "logger", "createLogger", "definePackage_"]
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,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAA4B,kCAC5BC,EAA2B,iCAI3B,gBAAc,IAAI,iBAAkB,OAAmB,EAEvD,IAAMC,EACJ,eAAa,cACZ,eAAa,MACV,QAAQ,IAAI,QAAU,QAAa,QAAQ,IAAI,QAAU,GACzD,OAAO,aAAiB,KAAe,aAAa,QAAQ,OAAO,IAAM,KAKzEC,EAAY,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,EAEEC,EAAc,EACZC,EAAgB,IAAc,CAClC,IAAMC,EAAQH,EAAUC,CAAW,EACnC,OAAAA,IACIA,GAAeD,EAAU,SAC3BC,EAAc,GAETE,CACT,EAEMC,EAAS,CACb,MAAO,eAAa,MAAQ,kBAAoB,oBAChD,MAAO,eAAa,MAAQ,UAAY,iBAC1C,EAEMC,EAAc,eAAa,MAAQ,SAAW,SAE9CC,EAAmBC,GAA2B,CAClDA,EAASA,EAAO,KAAK,EACrB,IAAMC,EAAQD,EAAO,OAAO,CAAC,EAC7B,OAAIC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O,KAAK,EAElG,SAAU,QAAQ,MAAM,KAAK,QAASC,EAAaM,EAAYJ,EAAQH,EAAO,KAAK,EAEnF,SAAU,eAAa,MACnB,QAAQ,IAAI,KAAK,QAAS,GAAGO,CAAU;AAAA,IAASP,EAAO,KAAK,yBAAyBA,EAAO,KAAK,GAAIG,CAAM,EAC3G,QAAQ,IAAI,KAAK,QAAS,6BAA8BI,EAAYJ,EAAQ,gBAAgB,EAEhG,KAAOM,GAAkB,QAAQ,KAAKN,EAAS,IAAMM,EAAQ,gBAAgB,EAC7E,QAAUA,GAAkB,QAAQ,QAAQN,EAAS,IAAMM,EAAQ,gBAAgB,CACrF,EA1BSD,CA2BX",
6
+ "names": ["main_exports", "__export", "createLogger", "__toCommonJS", "import_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
@@ -1,4 +1,3 @@
1
1
  export * from './logger.js';
2
- export * from './define-package.js';
3
2
  export * from './type.js';
4
3
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,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 v3.2.13 */
2
- import{definePackage as b}from"@alwatr/dedupe";import{platformInfo as s}from"@alwatr/platform-info";b("@alwatr/logger","3.2.13");var p=s.development||(s.isCli?process.env.DEBUG!==void 0&&process.env.DEBUG!=="":typeof localStorage<"u"&&localStorage.getItem("debug")==="1"),f=s.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"],c=0,a=()=>{let e=f[c];return c++,c>=f.length&&(c=0),e},r={scope:s.isCli?"\x1B[{{color}}m":"color: {{color}};",reset:s.isCli?"\x1B[0m":"color: inherit;"},n=s.isCli?"%s%s%s":"%c%s%c",u=e=>{e=e.trim();let t=e.charAt(0);return t!=="["&&t!=="{"&&t!=="<"&&(e="["+e+"]"),e},d=(e,t=p)=>{let l=a(),o=r.scope.replace("{{color}}",l);e=u(e);let g={debugMode:t,banner:s.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:s.isCli?console.warn.bind(console,`${o}⚠️
3
- %s\x1B[33m.%s() Accident \`%s\`!${r.reset}`,e):console.warn.bind(console,"%c%s%c.%s() Accident `%s`!",o,e,r.reset),error:s.isCli?console.error.bind(console,`${o}❌
4
- %s\x1B[31m.%s() Error \`%s\`${r.reset}
5
- `,e):console.error.bind(console,"%c%s%c.%s() Error `%s`\n",o,e,r.reset)};return t?{...g,logProperty:console.debug.bind(console,n+".%s = %o;",o,e,r.reset),logMethod:console.debug.bind(console,n+".%s();",o,e,r.reset),logModule:console.debug.bind(console,n+"/%s.js;",o,e,r.reset),logMethodArgs:console.debug.bind(console,n+".%s(%o);",o,e,r.reset),logMethodFull:console.debug.bind(console,n+".%s(%o) => %o",o,e,r.reset),logOther:console.debug.bind(console,n,o,e,r.reset),incident:s.isCli?console.log.bind(console,`${o}🚸
6
- %s${r.reset}.%s() Incident \`%s\`!${r.reset}`,e):console.log.bind(console,"%c%s%c.%s() Incident `%s`!",o,e,"color: orange;"),time:i=>console.time(e+"."+i+" duration time"),timeEnd:i=>console.timeEnd(e+"."+i+" duration time")}:g};import{definePackage as m}from"@alwatr/dedupe";function $(e,t="v?",l){let o=d(`{${e}}`,l);return o.logMethodArgs?.("define-package",{packageName:e,version:t}),m(e,t),o}export{d as createLogger,$ as definePackage};
1
+ /* @alwatr/logger v4.0.0 */
2
+ import{packageTracer as d}from"@alwatr/package-tracer";import{platformInfo as r}from"@alwatr/platform-info";d.add("@alwatr/logger","4.0.0");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", "../src/define-package.ts"],
4
- "sourcesContent": ["import {definePackage} from '@alwatr/dedupe';\nimport {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\ndefinePackage('@alwatr/logger', __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 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: 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", "import {definePackage as definePackage_} from '@alwatr/dedupe';\n\nimport {createLogger} from './logger.js';\n\nimport type {AlwatrLogger} from './type.js';\n\n/**\n * Global define package for managing package versions to prevent version conflicts and return package level logger.\n * @param packageName package name including scope. e.g. `@scope/package-name`\n * @param version package version (optional)\n * @returns AlwatrLogger for the package\n *\n * @example\n * ```typescript\n * const logger = definePackage('@scope/package-name', __package_version__);\n *\n * logger.logMethodArgs?.('myMethod', {a, b});\n * ```\n */\nexport function definePackage(packageName: string, version = 'v?', debugMode?: boolean): AlwatrLogger {\n const logger = createLogger(`{${packageName}}`, debugMode);\n logger.logMethodArgs?.('define-package', {packageName, version});\n definePackage_(packageName, version);\n return logger;\n}\n"],
5
- "mappings": ";AAAA,OAAQ,iBAAAA,MAAoB,iBAC5B,OAAQ,gBAAAC,MAAmB,wBAI3BD,EAAc,iBAAkB,QAAmB,EAEnD,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,OAA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,QAAQ,MAAM,KAAK,QAASP,EAAc,YAAaM,EAAYJ,EAAQH,EAAO,KAAK,EAEpG,UAAW,QAAQ,MAAM,KAAK,QAASC,EAAc,SAAUM,EAAYJ,EAAQH,EAAO,KAAK,EAE/F,UAAW,QAAQ,MAAM,KAAK,QAASC,EAAc,UAAWM,EAAYJ,EAAQH,EAAO,KAAK,EAEhG,cAAe,QAAQ,MAAM,KAAK,QAASC,EAAc,WAAYM,EAAYJ,EAAQH,EAAO,KAAK,EAErG,cAAe,QAAQ,MAAM,KAAK,QAASC,EAAc,gBAAiBM,EAAYJ,EAAQH,EAAO,KAAK,EAE1G,SAAU,QAAQ,MAAM,KAAK,QAASC,EAAaM,EAAYJ,EAAQH,EAAO,KAAK,EAEnF,SAAUN,EAAa,MACnB,QAAQ,IAAI,KAAK,QAAS,GAAGa,CAAU;AAAA,IAASP,EAAO,KAAK,yBAAyBA,EAAO,KAAK,GAAIG,CAAM,EAC3G,QAAQ,IAAI,KAAK,QAAS,6BAA8BI,EAAYJ,EAAQ,gBAAgB,EAEhG,KAAOM,GAAkB,QAAQ,KAAKN,EAAS,IAAMM,EAAQ,gBAAgB,EAC7E,QAAUA,GAAkB,QAAQ,QAAQN,EAAS,IAAMM,EAAQ,gBAAgB,CACrF,EAxBSD,CAyBX,ECjIA,OAAQ,iBAAiBE,MAAqB,iBAmBvC,SAASC,EAAcC,EAAqBC,EAAU,KAAMC,EAAmC,CACpG,IAAMC,EAASC,EAAa,IAAIJ,CAAW,IAAKE,CAAS,EACzD,OAAAC,EAAO,gBAAgB,iBAAkB,CAAC,YAAAH,EAAa,QAAAC,CAAO,CAAC,EAC/DH,EAAeE,EAAaC,CAAO,EAC5BE,CACT",
6
- "names": ["definePackage", "platformInfo", "defaultDebugMode", "colorList", "_colorIndex", "_getNextColor", "color", "_style", "_keySection", "_sanitizeDomain", "domain", "first", "createLogger", "debugMode", "styleScope", "requiredItems", "label", "definePackage_", "definePackage", "packageName", "version", "debugMode", "logger", "createLogger"]
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'),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BX",
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
- * The AlwatrLogger provides methods for logging various types of information.
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
- * Debug state for current scope base on localStorage `ALWATR_LOG` pattern.
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` property change.
13
+ * Logs a property change with its new value using `console.debug`. Useful for tracking changes in application state.
12
14
  *
13
- * Example:
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?(property: string, value: unknown): void;
23
+ logProperty?(propertyName: string, value: unknown): void;
20
24
  /**
21
- * `console.debug` module name.
25
+ * Logs the file name of the current module using `console.debug`.
26
+ * Helpful for identifying the source of log messages.
22
27
  *
23
- * Example:
28
+ * @param fileName The name of the file representing the module.
24
29
  *
30
+ * @example
25
31
  * ```ts
26
- * logger.logModule?.('app');
32
+ * logger.logFileModule?.('app');
27
33
  * ```
28
34
  */
29
- logModule?(name: string): void;
35
+ logFileModule?(fileName: string): void;
30
36
  /**
31
- * `console.debug` function or method calls.
37
+ * Logs the entry into a function or method using `console.debug`.
38
+ * Provides a basic trace of program execution.
32
39
  *
33
- * Example:
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?(method: string): void;
49
+ logMethod?(methodName: string): void;
42
50
  /**
43
- * `console.debug` function or method calls with arguments.
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
- * Example:
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?(method: string, args: unknown): void;
64
+ logMethodArgs?(methodName: string, args: unknown): void;
54
65
  /**
55
- * `console.debug` function or method calls with arguments.
66
+ * Logs specific steps or milestones within a method using `console.debug`.
67
+ * Facilitates tracking progress within complex functions.
56
68
  *
57
- * Example:
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?(method: string, args: unknown, result: unknown): void;
103
+ logMethodFull?(methodName: string, args: unknown, result: unknown): void;
68
104
  /**
69
- * `console.log` an event or expected accident.
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
- * Example:
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?(method: string, code: string, ...args: unknown[]): void;
116
+ incident?(methodName: string, warningCode: string, ...args: unknown[]): void;
79
117
  /**
80
- * `console.warn` an unexpected accident or error that you handled like warning.
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
- * Example:
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(method: string, code: string, ...args: unknown[]): void;
130
+ accident(methodName: string, warningCode: string, ...args: unknown[]): void;
89
131
  /**
90
- * `console.error` an unexpected error.
132
+ * Logs an unexpected error using `console.error`. Highlights critical issues that need to be addressed.
91
133
  *
92
- * Example:
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(method: string, code: string, ...args: unknown[]): void;
148
+ error(methodName: string, errorCode: string, ...args: unknown[]): void;
104
149
  /**
105
- * Simple `console.debug` with styled scope.
150
+ * Performs a simple `console.debug` log with styled scope for general debugging purposes.
106
151
  *
107
- * Example:
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
- * Simple `console.time` with scope.
161
+ * Starts a timer with a specified label using `console.time`. Useful for measuring performance.
116
162
  *
117
- * Example:
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
- * Simple `console.timeEnd` with scope.
172
+ * Ends a timer with a specified label and logs the elapsed time using `console.timeEnd`.
126
173
  *
127
- * Example:
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
- * log big banner
183
+ * Logs a prominent banner message, typically used for displaying important announcements or version information.
136
184
  *
137
- * Example:
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
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;;;;;;OAQG;IACH,WAAW,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAErD;;;;;;;;OAQG;IACH,SAAS,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B;;;;;;;;;;OAUG;IACH,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;;;;;;;;;OAUG;IACH,aAAa,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,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AM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwatr/logger",
3
- "version": "3.2.13",
3
+ "version": "4.0.0",
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": "MIT",
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 & yarn run build:es",
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/dedupe": "^1.0.13",
70
- "@alwatr/platform-info": "^1.1.12"
69
+ "@alwatr/package-tracer": "^1.0.0",
70
+ "@alwatr/platform-info": "^1.2.0"
71
71
  },
72
72
  "devDependencies": {
73
- "@alwatr/nano-build": "^1.3.9",
74
- "@alwatr/prettier-config": "^1.0.4",
75
- "@alwatr/tsconfig-base": "^1.2.0",
76
- "@types/node": "^22.5.5",
73
+ "@alwatr/nano-build": "^1.4.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": "30b89ecac526d2549d7361843ec47f8dde056d45"
79
+ "gitHead": "cc1ea8b688232dcc60e9ebc904ec5566bc25c1ac"
80
80
  }
@@ -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"}