@alwatr/logger 6.0.18 → 7.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/dist/main.js ADDED
@@ -0,0 +1,9 @@
1
+ /* 📦 @alwatr/logger v7.0.1 */
2
+ import{getGlobalThis as X}from"@alwatr/global-this";import{platformInfo as F}from"@alwatr/platform-info";var j=X().console,Y=(()=>{if(F.development)if(F.isCli)return process.env.ALWATR_DEBUG!=="0";else return typeof localStorage<"u"&&localStorage.getItem("ALWATR_DEBUG")!=="0";return F.isCli?Boolean(process.env.DEBUG):typeof localStorage<"u"&&localStorage.getItem("ALWATR_DEBUG")==="1"})(),R=(()=>F.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"])(),B=(()=>({scope:F.isCli?"\x1B[{{color}}m":"color: {{color}};",reset:F.isCli?"\x1B[0m":"color: inherit;"}))(),J=(()=>F.isCli?"%s%s%s":"%c%s%c")(),O=0;function Z(){let H=R[O];return O=(O+1)%R.length,H}function $(H){if(H=H.trim(),!/^[[{<]/.test(H))H=`{${H}}`;return H}function G(H,P=Y){let W=Z(),E=B.scope.replace("{{color}}",W),A=$(H),Q={debugMode:P,banner:F.isCli?j.log.bind(j,`\x1B[1;37;45m {{{ %s }}} ${B.reset}`):j.log.bind(j,"%c%s","font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;"),accident:F.isCli?j.warn.bind(j,`${E}⚠️
3
+ %s\x1B[33m.%s() Accident \`%s\`!${B.reset}`,A):j.warn.bind(j,"%c%s%c.%s() Accident `%s`!",E,A,B.reset),error:F.isCli?j.error.bind(j,`${E}❌
4
+ %s\x1B[31m.%s() Error \`%s\`${B.reset}
5
+ `,A):j.error.bind(j,"%c%s%c.%s() Error `%s`\n",E,A,B.reset)};if(!P)return Q;return{...Q,logProperty:j.debug.bind(j,J+".%s = %o;",E,A,B.reset),logMethod:j.debug.bind(j,J+".%s();",E,A,B.reset),logFileModule:j.debug.bind(j,J+"/%s.js;",E,A,B.reset),logMethodArgs:j.debug.bind(j,J+".%s(%o);",E,A,B.reset),logMethodFull:j.debug.bind(j,J+".%s(%o) => %o",E,A,B.reset),logStep:j.debug.bind(j,J+".%s() -> %s",E,A,B.reset),logOther:j.debug.bind(j,J,E,A,B.reset),logTable:j.table.bind(j),incident:F.isCli?j.log.bind(j,`${E}\uD83D\uDEB8
6
+ %s${B.reset}.%s() Incident \`%s\`!${B.reset}`,A):j.log.bind(j,"%c%s%c.%s() Incident `%s`!",E,A,"color: orange;"),time:(K)=>j.time(A+"."+K),timeEnd:(K)=>j.timeEnd(A+"."+K)}}export{G as createLogger};
7
+
8
+ //# debugId=490BAF9DEDB7F14264756E2164756E21
9
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/logger.ts"],
4
+ "sourcesContent": [
5
+ "import {getGlobalThis} from '@alwatr/global-this';\nimport {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\nconst console_ = getGlobalThis().console;\n\n/**\n * Default debug mode state, determined by environment variables or localStorage.\n */\nconst defaultDebugMode = (() => {\n if (platformInfo.development) {\n if (platformInfo.isCli) {\n return process.env.ALWATR_DEBUG !== '0';\n }\n else {\n return typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') !== '0';\n }\n }\n // else\n return platformInfo.isCli\n ? Boolean(process.env.DEBUG)\n : typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') === '1';\n})();\n\n/**\n * A list of aesthetically pleasing colors for console logging, adapted for CLI and browser environments.\n */\nconst colorList = (() =>\n platformInfo.isCli\n ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // CLI-safe colors\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\n/**\n * Platform-specific styling templates for logger output.\n */\nconst style_ = (() => ({\n scope: platformInfo.isCli ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: platformInfo.isCli ? '\\x1b[0m' : 'color: inherit;',\n}))();\n\n/**\n * Platform-specific format for displaying the logger's scope.\n */\nconst keySection_ = (() => (platformInfo.isCli ? '%s%s%s' : '%c%s%c'))();\n\n// --- Utility Functions ---\n\nlet colorIndex_ = 0;\n/**\n * Cycles through the `colorList` to provide a new color for each logger instance.\n */\nfunction getNextColor_(): string {\n const color = colorList[colorIndex_];\n colorIndex_ = (colorIndex_ + 1) % colorList.length;\n return color;\n}\n\n/**\n * Sanitizes and formats the logger domain string by wrapping it in brackets if not already.\n */\nfunction sanitizeDomain_(domain: string): string {\n domain = domain.trim();\n if (!/^[[{<]/.test(domain)) {\n domain = `{${domain}}`;\n }\n return domain;\n}\n\n// --- Core Factory ---\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - `color` is optional and automatically selected from an internal list.\n * - `debug` is optional and automatically detected from `ALWATR_DEBUG` in localStorage or `process.env.DEBUG`.\n *\n * @example\n * ```ts\n * import {createLogger} from '@alwatr/logger';\n * const logger = createLogger('my-module');\n *\n * logger.logMethodArgs?.('myMethod', {a: 1}); // This line is ignored if debugMode is false.\n * ```\n */\nexport function createLogger(domain: string, debugMode = defaultDebugMode): AlwatrLogger {\n const color = getNextColor_();\n const styleScope = style_.scope.replace('{{color}}', color);\n const sanitizedDomain = sanitizeDomain_(domain);\n\n /**\n * Logger methods that are always available, regardless of debugMode.\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}`, sanitizedDomain)\n : console_.warn.bind(console_, '%c%s%c.%s() Accident `%s`!', styleScope, sanitizedDomain, style_.reset),\n\n error: platformInfo.isCli\n ? console_.error.bind(console_, `${styleScope}❌\\n%s\\x1b[31m.%s() Error \\`%s\\`${style_.reset}\\n`, sanitizedDomain)\n : console_.error.bind(console_, '%c%s%c.%s() Error `%s`\\n', styleScope, sanitizedDomain, style_.reset),\n };\n\n if (!debugMode) {\n return requiredItems;\n }\n\n /**\n * Logger methods available only when debugMode is true.\n * Using `console.debug` which is often filtered by default in browsers unless \"Verbose\" logs are enabled.\n */\n return {\n ...requiredItems,\n\n logProperty: console_.debug.bind(console_, keySection_ + '.%s = %o;', styleScope, sanitizedDomain, style_.reset),\n\n logMethod: console_.debug.bind(console_, keySection_ + '.%s();', styleScope, sanitizedDomain, style_.reset),\n\n logFileModule: console_.debug.bind(console_, keySection_ + '/%s.js;', styleScope, sanitizedDomain, style_.reset),\n\n logMethodArgs: console_.debug.bind(console_, keySection_ + '.%s(%o);', styleScope, sanitizedDomain, style_.reset),\n\n logMethodFull: console_.debug.bind(console_, keySection_ + '.%s(%o) => %o', styleScope, sanitizedDomain, style_.reset),\n\n logStep: console_.debug.bind(console_, keySection_ + '.%s() -> %s', styleScope, sanitizedDomain, style_.reset),\n\n logOther: console_.debug.bind(console_, keySection_, styleScope, sanitizedDomain, style_.reset),\n\n logTable: console_.table.bind(console_),\n\n incident: platformInfo.isCli\n ? console_.log.bind(console_, `${styleScope}🚸\\n%s${style_.reset}.%s() Incident \\`%s\\`!${style_.reset}`, sanitizedDomain)\n : console_.log.bind(console_, '%c%s%c.%s() Incident `%s`!', styleScope, sanitizedDomain, 'color: orange;'),\n\n time: (label: string) => console_.time(sanitizedDomain + '.' + label),\n timeEnd: (label: string) => console_.timeEnd(sanitizedDomain + '.' + label),\n } as const;\n}\n"
6
+ ],
7
+ "mappings": ";AAAA,wBAAQ,4BACR,uBAAQ,8BAIR,IAAM,EAAW,EAAc,EAAE,QAK3B,GAAoB,IAAM,CAC9B,GAAI,EAAa,YACf,GAAI,EAAa,MACf,OAAO,QAAQ,IAAI,eAAiB,IAGpC,YAAO,OAAO,aAAiB,KAAe,aAAa,QAAQ,cAAc,IAAM,IAI3F,OAAO,EAAa,MAChB,QAAQ,QAAQ,IAAI,KAAK,EACzB,OAAO,aAAiB,KAAe,aAAa,QAAQ,cAAc,IAAM,MACnF,EAKG,GAAa,IACjB,EAAa,MACT,CAAC,OAAQ,OAAQ,OAAQ,OAAQ,MAAM,EACvC,CACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,SACF,GAAG,EAKD,GAAU,KAAO,CACrB,MAAO,EAAa,MAAQ,kBAAoB,oBAChD,MAAO,EAAa,MAAQ,UAAY,iBAC1C,IAAI,EAKE,GAAe,IAAO,EAAa,MAAQ,SAAW,UAAW,EAInE,EAAc,EAIlB,SAAS,CAAa,EAAW,CAC/B,IAAM,EAAQ,EAAU,GAExB,OADA,GAAe,EAAc,GAAK,EAAU,OACrC,EAMT,SAAS,CAAe,CAAC,EAAwB,CAE/C,GADA,EAAS,EAAO,KAAK,EACjB,CAAC,SAAS,KAAK,CAAM,EACvB,EAAS,IAAI,KAEf,OAAO,EAmBF,SAAS,CAAY,CAAC,EAAgB,EAAY,EAAgC,CACvF,IAAM,EAAQ,EAAc,EACtB,EAAa,EAAO,MAAM,QAAQ,YAAa,CAAK,EACpD,EAAkB,EAAgB,CAAM,EAKxC,EAA8B,CAClC,YAEA,OAAQ,EAAa,MACjB,EAAS,IAAI,KAAK,EAAU,4BAA4B,EAAO,OAAO,EACtE,EAAS,IAAI,KACb,EACA,OACA,qGACF,EAEF,SAAU,EAAa,MACnB,EAAS,KAAK,KAAK,EAAU,GAAG;AAAA,kCAAgD,EAAO,QAAS,CAAe,EAC/G,EAAS,KAAK,KAAK,EAAU,6BAA8B,EAAY,EAAiB,EAAO,KAAK,EAExG,MAAO,EAAa,MAChB,EAAS,MAAM,KAAK,EAAU,GAAG;AAAA,8BAA2C,EAAO;AAAA,EAAW,CAAe,EAC7G,EAAS,MAAM,KAAK,EAAU,2BAA4B,EAAY,EAAiB,EAAO,KAAK,CACzG,EAEA,GAAI,CAAC,EACH,OAAO,EAOT,MAAO,IACF,EAEH,YAAa,EAAS,MAAM,KAAK,EAAU,EAAc,YAAa,EAAY,EAAiB,EAAO,KAAK,EAE/G,UAAW,EAAS,MAAM,KAAK,EAAU,EAAc,SAAU,EAAY,EAAiB,EAAO,KAAK,EAE1G,cAAe,EAAS,MAAM,KAAK,EAAU,EAAc,UAAW,EAAY,EAAiB,EAAO,KAAK,EAE/G,cAAe,EAAS,MAAM,KAAK,EAAU,EAAc,WAAY,EAAY,EAAiB,EAAO,KAAK,EAEhH,cAAe,EAAS,MAAM,KAAK,EAAU,EAAc,gBAAiB,EAAY,EAAiB,EAAO,KAAK,EAErH,QAAS,EAAS,MAAM,KAAK,EAAU,EAAc,cAAe,EAAY,EAAiB,EAAO,KAAK,EAE7G,SAAU,EAAS,MAAM,KAAK,EAAU,EAAa,EAAY,EAAiB,EAAO,KAAK,EAE9F,SAAU,EAAS,MAAM,KAAK,CAAQ,EAEtC,SAAU,EAAa,MACnB,EAAS,IAAI,KAAK,EAAU,GAAG;AAAA,IAAkB,EAAO,8BAA8B,EAAO,QAAS,CAAe,EACrH,EAAS,IAAI,KAAK,EAAU,6BAA8B,EAAY,EAAiB,gBAAgB,EAE3G,KAAM,CAAC,IAAkB,EAAS,KAAK,EAAkB,IAAM,CAAK,EACpE,QAAS,CAAC,IAAkB,EAAS,QAAQ,EAAkB,IAAM,CAAK,CAC5E",
8
+ "debugId": "490BAF9DEDB7F14264756E2164756E21",
9
+ "names": []
10
+ }
package/package.json CHANGED
@@ -1,34 +1,59 @@
1
1
  {
2
2
  "name": "@alwatr/logger",
3
+ "version": "7.0.1",
3
4
  "description": "Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.",
4
- "version": "6.0.18",
5
+ "license": "MPL-2.0",
5
6
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
7
+ "type": "module",
8
+ "repository": {
9
+ "directory": "packages/logger",
10
+ "type": "git",
11
+ "url": "https://github.com/Alwatr/nanolib"
12
+ },
13
+ "homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/logger#readme",
6
14
  "bugs": "https://github.com/Alwatr/nanolib/issues",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/main.d.ts",
18
+ "default": "./dist/main.js"
19
+ }
20
+ },
21
+ "sideEffects": false,
7
22
  "dependencies": {
8
- "@alwatr/global-this": "5.6.10",
9
- "@alwatr/platform-info": "5.5.29"
23
+ "@alwatr/global-this": "6.0.1",
24
+ "@alwatr/platform-info": "6.0.1"
10
25
  },
11
26
  "devDependencies": {
12
- "@alwatr/nano-build": "6.4.2",
13
- "@alwatr/prettier-config": "6.0.2",
14
- "@alwatr/tsconfig-base": "6.0.4",
27
+ "@alwatr/nano-build": "7.0.1",
28
+ "@alwatr/prettier-config": "7.0.1",
29
+ "@alwatr/tsconfig-base": "8.0.0",
15
30
  "@types/node": "^24.12.0",
16
31
  "typescript": "^5.9.3"
17
32
  },
18
- "exports": {
19
- ".": {
20
- "types": "./dist/main.d.ts",
21
- "import": "./dist/main.mjs",
22
- "require": "./dist/main.cjs"
23
- }
33
+ "scripts": {
34
+ "b": "bun run build",
35
+ "build": "bun run build:ts && bun run build:es",
36
+ "build:es": "nano-build --preset=module src/main.ts",
37
+ "build:ts": "tsc --build",
38
+ "c": "bun run clean",
39
+ "cb": "bun run clean && bun run build",
40
+ "clean": "rm -rfv dist *.tsbuildinfo",
41
+ "d": "bun run build:es && bun",
42
+ "w": "bun run watch",
43
+ "watch": "bun run watch:ts & bun run watch:es",
44
+ "watch:es": "bun run build:es --watch",
45
+ "watch:ts": "bun run build:ts --watch --preserveWatchOutput"
24
46
  },
25
47
  "files": [
26
- "**/*.{js,mjs,cjs,map,d.ts,html,md,LEGAL.txt}",
48
+ "**/*.{js,mjs,cjs,ts,map,d.ts,html,LEGAL.txt}",
49
+ "README.md",
27
50
  "LICENSE",
28
51
  "!demo/**/*",
29
52
  "!**/*.test.js"
30
53
  ],
31
- "homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/logger#readme",
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
32
57
  "keywords": [
33
58
  "alwatr",
34
59
  "console",
@@ -48,34 +73,6 @@
48
73
  "utility",
49
74
  "utils"
50
75
  ],
51
- "license": "MPL-2.0",
52
- "main": "./dist/main.cjs",
53
- "module": "./dist/main.mjs",
54
76
  "prettier": "@alwatr/prettier-config",
55
- "publishConfig": {
56
- "access": "public"
57
- },
58
- "repository": {
59
- "type": "git",
60
- "url": "https://github.com/Alwatr/nanolib",
61
- "directory": "packages/logger"
62
- },
63
- "scripts": {
64
- "b": "bun run build",
65
- "build": "bun run build:ts && bun run build:es",
66
- "build:es": "nano-build --preset=module",
67
- "build:ts": "tsc --build",
68
- "c": "bun run clean",
69
- "cb": "bun run clean && bun run build",
70
- "clean": "rm -rfv dist *.tsbuildinfo",
71
- "d": "bun run build:es && bun --enable-source-maps --trace-warnings",
72
- "w": "bun run watch",
73
- "watch": "bun run watch:ts & bun run watch:es",
74
- "watch:es": "bun run build:es --watch",
75
- "watch:ts": "bun run build:ts --watch --preserveWatchOutput"
76
- },
77
- "sideEffects": false,
78
- "type": "module",
79
- "types": "./dist/main.d.ts",
80
- "gitHead": "c3889e3756b0a0f9b935a1b702a1373ac52cb379"
77
+ "gitHead": "f843742e94d6ebed3921d57b624d9deb35c2c102"
81
78
  }
package/src/logger.ts ADDED
@@ -0,0 +1,164 @@
1
+ import {getGlobalThis} from '@alwatr/global-this';
2
+ import {platformInfo} from '@alwatr/platform-info';
3
+
4
+ import type {AlwatrLogger} from './type.js';
5
+
6
+ const console_ = getGlobalThis().console;
7
+
8
+ /**
9
+ * Default debug mode state, determined by environment variables or localStorage.
10
+ */
11
+ const defaultDebugMode = (() => {
12
+ if (platformInfo.development) {
13
+ if (platformInfo.isCli) {
14
+ return process.env.ALWATR_DEBUG !== '0';
15
+ }
16
+ else {
17
+ return typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') !== '0';
18
+ }
19
+ }
20
+ // else
21
+ return platformInfo.isCli
22
+ ? Boolean(process.env.DEBUG)
23
+ : typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') === '1';
24
+ })();
25
+
26
+ /**
27
+ * A list of aesthetically pleasing colors for console logging, adapted for CLI and browser environments.
28
+ */
29
+ const colorList = (() =>
30
+ platformInfo.isCli
31
+ ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // CLI-safe colors
32
+ : [
33
+ '#35b997',
34
+ '#f05561',
35
+ '#ee224a',
36
+ '#91c13e',
37
+ '#22af4b',
38
+ '#f0e995',
39
+ '#0fe995',
40
+ '#0f89ca',
41
+ '#08b9a5',
42
+ '#fee851',
43
+ '#ee573d',
44
+ '#f9df30',
45
+ '#1da2dc',
46
+ '#f05123',
47
+ '#ee2524',
48
+ ])();
49
+
50
+ /**
51
+ * Platform-specific styling templates for logger output.
52
+ */
53
+ const style_ = (() => ({
54
+ scope: platformInfo.isCli ? '\x1b[{{color}}m' : 'color: {{color}};',
55
+ reset: platformInfo.isCli ? '\x1b[0m' : 'color: inherit;',
56
+ }))();
57
+
58
+ /**
59
+ * Platform-specific format for displaying the logger's scope.
60
+ */
61
+ const keySection_ = (() => (platformInfo.isCli ? '%s%s%s' : '%c%s%c'))();
62
+
63
+ // --- Utility Functions ---
64
+
65
+ let colorIndex_ = 0;
66
+ /**
67
+ * Cycles through the `colorList` to provide a new color for each logger instance.
68
+ */
69
+ function getNextColor_(): string {
70
+ const color = colorList[colorIndex_];
71
+ colorIndex_ = (colorIndex_ + 1) % colorList.length;
72
+ return color;
73
+ }
74
+
75
+ /**
76
+ * Sanitizes and formats the logger domain string by wrapping it in brackets if not already.
77
+ */
78
+ function sanitizeDomain_(domain: string): string {
79
+ domain = domain.trim();
80
+ if (!/^[[{<]/.test(domain)) {
81
+ domain = `{${domain}}`;
82
+ }
83
+ return domain;
84
+ }
85
+
86
+ // --- Core Factory ---
87
+
88
+ /**
89
+ * Create a logger function for fancy console debug with custom scope.
90
+ *
91
+ * - `color` is optional and automatically selected from an internal list.
92
+ * - `debug` is optional and automatically detected from `ALWATR_DEBUG` in localStorage or `process.env.DEBUG`.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import {createLogger} from '@alwatr/logger';
97
+ * const logger = createLogger('my-module');
98
+ *
99
+ * logger.logMethodArgs?.('myMethod', {a: 1}); // This line is ignored if debugMode is false.
100
+ * ```
101
+ */
102
+ export function createLogger(domain: string, debugMode = defaultDebugMode): AlwatrLogger {
103
+ const color = getNextColor_();
104
+ const styleScope = style_.scope.replace('{{color}}', color);
105
+ const sanitizedDomain = sanitizeDomain_(domain);
106
+
107
+ /**
108
+ * Logger methods that are always available, regardless of debugMode.
109
+ */
110
+ const requiredItems: AlwatrLogger = {
111
+ debugMode,
112
+
113
+ banner: platformInfo.isCli
114
+ ? console_.log.bind(console_, `\x1b[1;37;45m {{{ %s }}} ${style_.reset}`)
115
+ : console_.log.bind(
116
+ console_,
117
+ '%c%s',
118
+ 'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;',
119
+ ),
120
+
121
+ accident: platformInfo.isCli
122
+ ? console_.warn.bind(console_, `${styleScope}⚠️\n%s\x1b[33m.%s() Accident \`%s\`!${style_.reset}`, sanitizedDomain)
123
+ : console_.warn.bind(console_, '%c%s%c.%s() Accident `%s`!', styleScope, sanitizedDomain, style_.reset),
124
+
125
+ error: platformInfo.isCli
126
+ ? console_.error.bind(console_, `${styleScope}❌\n%s\x1b[31m.%s() Error \`%s\`${style_.reset}\n`, sanitizedDomain)
127
+ : console_.error.bind(console_, '%c%s%c.%s() Error `%s`\n', styleScope, sanitizedDomain, style_.reset),
128
+ };
129
+
130
+ if (!debugMode) {
131
+ return requiredItems;
132
+ }
133
+
134
+ /**
135
+ * Logger methods available only when debugMode is true.
136
+ * Using `console.debug` which is often filtered by default in browsers unless "Verbose" logs are enabled.
137
+ */
138
+ return {
139
+ ...requiredItems,
140
+
141
+ logProperty: console_.debug.bind(console_, keySection_ + '.%s = %o;', styleScope, sanitizedDomain, style_.reset),
142
+
143
+ logMethod: console_.debug.bind(console_, keySection_ + '.%s();', styleScope, sanitizedDomain, style_.reset),
144
+
145
+ logFileModule: console_.debug.bind(console_, keySection_ + '/%s.js;', styleScope, sanitizedDomain, style_.reset),
146
+
147
+ logMethodArgs: console_.debug.bind(console_, keySection_ + '.%s(%o);', styleScope, sanitizedDomain, style_.reset),
148
+
149
+ logMethodFull: console_.debug.bind(console_, keySection_ + '.%s(%o) => %o', styleScope, sanitizedDomain, style_.reset),
150
+
151
+ logStep: console_.debug.bind(console_, keySection_ + '.%s() -> %s', styleScope, sanitizedDomain, style_.reset),
152
+
153
+ logOther: console_.debug.bind(console_, keySection_, styleScope, sanitizedDomain, style_.reset),
154
+
155
+ logTable: console_.table.bind(console_),
156
+
157
+ incident: platformInfo.isCli
158
+ ? console_.log.bind(console_, `${styleScope}🚸\n%s${style_.reset}.%s() Incident \`%s\`!${style_.reset}`, sanitizedDomain)
159
+ : console_.log.bind(console_, '%c%s%c.%s() Incident `%s`!', styleScope, sanitizedDomain, 'color: orange;'),
160
+
161
+ time: (label: string) => console_.time(sanitizedDomain + '.' + label),
162
+ timeEnd: (label: string) => console_.timeEnd(sanitizedDomain + '.' + label),
163
+ } as const;
164
+ }
package/src/main.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './logger.js';
2
+ export * from './type.js';
package/src/type.ts ADDED
@@ -0,0 +1,226 @@
1
+ /**
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.
5
+ *
6
+ * @example
7
+ * import {createLogger} from '@alwatr/logger';
8
+ * const logger = createLogger('my-module'); // Create a logger with a specific scope
9
+ *
10
+ * function greet(name: string) {
11
+ * logger.logMethodArgs?.('greet', {name}); // Log the method call with its arguments
12
+ * // ...
13
+ * }
14
+ *
15
+ * greet('Ali');
16
+ */
17
+ export interface AlwatrLogger {
18
+ /**
19
+ * Indicates whether debug mode is enabled for the current scope.
20
+ * This state is typically determined based on the `debug` pattern in localStorage.
21
+ */
22
+ debugMode: boolean;
23
+
24
+ /**
25
+ * Logs a property change with its new value using `console.debug`. Useful for tracking changes in application state.
26
+ *
27
+ * @param propertyName The name of the property that has changed.
28
+ * @param value The new value of the property.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * logger.logProperty?.('name', 'ali');
33
+ * ```
34
+ */
35
+ logProperty?(propertyName: string, value: unknown): void;
36
+
37
+ /**
38
+ * Logs the file name of the current module using `console.debug`.
39
+ * Helpful for identifying the source of log messages.
40
+ *
41
+ * @param fileName The name of the file representing the module.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * logger.logFileModule?.('app');
46
+ * ```
47
+ */
48
+ logFileModule?(fileName: string): void;
49
+
50
+ /**
51
+ * Logs the entry into a function or method using `console.debug`.
52
+ * Provides a basic trace of program execution.
53
+ *
54
+ * @param methodName The name of the function or method being called.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * function myMethod () {
59
+ * logger.logMethod?.('myMethod');
60
+ * }
61
+ * ```
62
+ */
63
+ logMethod?(methodName: string): void;
64
+
65
+ /**
66
+ * Logs the entry into a function or method along with its arguments using `console.debug`.
67
+ * Aids in understanding the context of method calls.
68
+ *
69
+ * @param methodName The name of the function or method being called.
70
+ * @param args An object containing the arguments passed to the method.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * function myMethod (a: number, b: number) {
75
+ * logger.logMethodArgs?.('myMethod', {a, b});
76
+ * }
77
+ * ```
78
+ */
79
+ logMethodArgs?(methodName: string, args: unknown): void;
80
+
81
+ /**
82
+ * Logs specific steps or milestones within a method using `console.debug`.
83
+ * Facilitates tracking progress within complex functions.
84
+ *
85
+ * @param methodName The name of the method where the step occurs.
86
+ * @param stepName The name or identifier of the specific step.
87
+ * @param props (Optional) Additional properties or data related to the step.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * function myMethod () {
92
+ * logger.logMethod?.('myMethod');
93
+ * ...
94
+ * logger.logStep?.('myMethod', 'step1');
95
+ * ...
96
+ * logger.logStep?.('myMethod', 'step2');
97
+ * ...
98
+ * }
99
+ * ```
100
+ */
101
+ logStep?(methodName: string, stepName: string, props?: unknown): void;
102
+
103
+ /**
104
+ * Logs a complete method call, including its arguments and result, using `console.debug`.
105
+ * Useful for debugging and understanding the output of functions.
106
+ *
107
+ * @param methodName The name of the function or method being called.
108
+ * @param args An object containing the arguments passed to the method.
109
+ * @param result The result returned by the method.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * function add (a: number, b: number): number {
114
+ * const result = a + b;
115
+ * logger.logMethodFull?.('add', {a, b}, result);
116
+ * return result;
117
+ * }
118
+ * ```
119
+ */
120
+ logMethodFull?(methodName: string, args: unknown, result: unknown): void;
121
+
122
+ /**
123
+ * Logs an event or expected incident using `console.log`. Intended for noteworthy information that doesn't represent an error or warning.
124
+ *
125
+ * @param methodName The name or context of the event or incident.
126
+ * @param warningCode A code or identifier for the specific type of event or incident.
127
+ * @param args Additional details or context related to the event or incident.
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * logger.incident?.('fetch', 'abort_signal', {url: '/test.json'});
132
+ * ```
133
+ */
134
+ incident?(methodName: string, warningCode: string, ...args: unknown[]): void;
135
+
136
+ /**
137
+ * Logs an unexpected incident or handled error as a warning using `console.warn`.
138
+ * Indicates a potential issue that has been addressed but warrants attention.
139
+ *
140
+ * @param methodName The name or context of the incident or error.
141
+ * @param warningCode A code or identifier for the specific type of incident or error.
142
+ * @param args Additional details or context related to the incident or error.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * logger.accident('fetch', 'file_not_found', {url: '/test.json'});
147
+ * ```
148
+ */
149
+ accident(methodName: string, warningCode: string, ...args: unknown[]): void;
150
+
151
+ /**
152
+ * Logs an unexpected error using `console.error`. Highlights critical issues that need to be addressed.
153
+ *
154
+ * @param methodName The name or context where the error occurred.
155
+ * @param errorCode A code or identifier for the specific type of error.
156
+ * @param args Additional details or context related to the error, including the error object itself.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * try {
161
+ * ...
162
+ * }
163
+ * catch (err) {
164
+ * logger.error('myMethod', 'error_code', err, {a: 1, b: 2});
165
+ * }
166
+ * ```
167
+ */
168
+ error(methodName: string, errorCode: string, ...args: unknown[]): void;
169
+
170
+ /**
171
+ * Performs a simple `console.debug` log with styled scope for general debugging purposes.
172
+ *
173
+ * @param args Any number of arguments to be logged.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * logger.logOther?.('foo:', 'bar', {a: 1});
178
+ * ```
179
+ */
180
+ logOther?(...args: unknown[]): void;
181
+
182
+ /**
183
+ * Try to construct a table with the columns of the properties of `tabularData` (or use `properties`)
184
+ * and rows of `tabularData` and log it.
185
+ * Falls back to just logging the argument if it can't be parsed as tabular.
186
+ * @param tabularData Any data that can be represented in tabular form.
187
+ * @param properties Alternate properties for constructing the table.
188
+ */
189
+ logTable?(tabularData: unknown, properties?: readonly string[]): void;
190
+
191
+ /**
192
+ * Starts a timer with a specified label using `console.time`. Useful for measuring performance.
193
+ *
194
+ * @param label The label for the timer.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * logger.time?.('foo');
199
+ * ```
200
+ */
201
+ time?(label: string): void;
202
+
203
+ /**
204
+ * Ends a timer with a specified label and logs the elapsed time using `console.timeEnd`.
205
+ *
206
+ * @param label The label for the timer.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * logger.timeEnd?.('foo');
211
+ * ```
212
+ */
213
+ timeEnd?(label: string): void;
214
+
215
+ /**
216
+ * Logs a prominent banner message, typically used for displaying important announcements or version information.
217
+ *
218
+ * @param message The message to be displayed in the banner.
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * logger.banner('Alwatr PWA v2');
223
+ * ```
224
+ */
225
+ banner(message: string): void;
226
+ }
package/CHANGELOG.md DELETED
@@ -1,536 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [6.0.18](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.17...@alwatr/logger@6.0.18) (2026-03-16)
7
-
8
- ### 🔨 Code Refactoring
9
-
10
- * migrate build scripts from yarn to bun across multiple packages ([d90e962](https://github.com/Alwatr/nanolib/commit/d90e962f15e5c951e191d5f02341279b6472abc3))
11
-
12
- ### 🔗 Dependencies update
13
-
14
- * bump the npm-dependencies group with 10 updates ([c48d9ba](https://github.com/Alwatr/nanolib/commit/c48d9baa1cd7c2dc144b3e01e0fda60bf87c074c))
15
-
16
- ## [6.0.17](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.16...@alwatr/logger@6.0.17) (2026-02-18)
17
-
18
- ### 🔗 Dependencies update
19
-
20
- * update @types/node to version 24.10.13 across multiple packages ([4c6d2a3](https://github.com/Alwatr/nanolib/commit/4c6d2a37ab26b1c86812b2aa38b2eca4ee097cb6))
21
-
22
- ## [6.0.16](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.15...@alwatr/logger@6.0.16) (2025-12-23)
23
-
24
- ### 🔗 Dependencies update
25
-
26
- * upgrade @types/node to version 24.10.4 and update related dependencies ([acf04df](https://github.com/Alwatr/nanolib/commit/acf04df71647f5a401ef5e6bbfffcc478e4326d2))
27
-
28
- ## [6.0.15](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.14...@alwatr/logger@6.0.15) (2025-12-13)
29
-
30
- ### 🔗 Dependencies update
31
-
32
- * update `@types/node` and `[@lerna-lite](https://github.com/lerna-lite)` dependencies. ([8daa8fd](https://github.com/Alwatr/nanolib/commit/8daa8fd023d5414c9f95feb4319353c6ea34be31))
33
-
34
- ## [6.0.14](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.13...@alwatr/logger@6.0.14) (2025-12-10)
35
-
36
- ### 🔗 Dependencies update
37
-
38
- * Upgrade lerna-lite, prettier, types/node, and yarn dependencies. ([42a7fca](https://github.com/Alwatr/nanolib/commit/42a7fca15430aca2ac1eaa19496c2a2ebfc8c470))
39
-
40
- ## [6.0.13](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.12...@alwatr/logger@6.0.13) (2025-11-18)
41
-
42
- ### 🔨 Code Refactoring
43
-
44
- * remove unnecessary type declarations from tsconfig.json files ([89bcc7d](https://github.com/Alwatr/nanolib/commit/89bcc7db839807110b80f8ba34414ea9734d9c75))
45
-
46
- ## [6.0.12](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.11...@alwatr/logger@6.0.12) (2025-11-15)
47
-
48
- ### 🔗 Dependencies update
49
-
50
- * bump the npm-dependencies group with 2 updates ([a80b84d](https://github.com/Alwatr/nanolib/commit/a80b84dada6c09b5e5621e7487c8ec13fff3c23a))
51
-
52
- ## [6.0.11](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.10...@alwatr/logger@6.0.11) (2025-11-15)
53
-
54
- **Note:** Version bump only for package @alwatr/logger
55
-
56
- ## [6.0.10](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.9...@alwatr/logger@6.0.10) (2025-11-04)
57
-
58
- ### 🔗 Dependencies update
59
-
60
- * bump the npm-dependencies group across 1 directory with 9 updates ([fdf29d5](https://github.com/Alwatr/nanolib/commit/fdf29d5aa89983cb06f79d42650a364521f5c4b9))
61
- * update @types/node from ^22.18.12 to ^24.10.0 across multiple packages ([1169a86](https://github.com/Alwatr/nanolib/commit/1169a86001da2abfbe99a7da33c8e92183f553f6))
62
-
63
- ## [6.0.9](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.8...@alwatr/logger@6.0.9) (2025-10-06)
64
-
65
- ### 🔗 Dependencies update
66
-
67
- * bump the npm-dependencies group with 4 updates ([9825815](https://github.com/Alwatr/nanolib/commit/982581552bbb4b97dca52af5e93a80937f0c3109))
68
-
69
- ## [6.0.8](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.7...@alwatr/logger@6.0.8) (2025-09-27)
70
-
71
- ### 🧹 Miscellaneous Chores
72
-
73
- * exclude test files from package distribution ([86f4f2f](https://github.com/Alwatr/nanolib/commit/86f4f2f5985845c5cf3a3a9398de7b2f98ce53e7))
74
-
75
- ## [6.0.7](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.6...@alwatr/logger@6.0.7) (2025-09-22)
76
-
77
- **Note:** Version bump only for package @alwatr/logger
78
-
79
- ## [6.0.6](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.5...@alwatr/logger@6.0.6) (2025-09-22)
80
-
81
- **Note:** Version bump only for package @alwatr/logger
82
-
83
- ## [6.0.5](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.4...@alwatr/logger@6.0.5) (2025-09-21)
84
-
85
- **Note:** Version bump only for package @alwatr/logger
86
-
87
- ## [6.0.4](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.3...@alwatr/logger@6.0.4) (2025-09-20)
88
-
89
- ### 🐛 Bug Fixes
90
-
91
- * add sideEffects property to package.json files for better tree-shaking ([c7b9e74](https://github.com/Alwatr/nanolib/commit/c7b9e74e1920c8e35b438742de61883ca62da58c))
92
- * add sideEffects property to package.json files for better tree-shaking ([e8402c4](https://github.com/Alwatr/nanolib/commit/e8402c481a14a1f807a37aaa862a936713d26176))
93
- * remove unnecessary pure annotations ([adeb916](https://github.com/Alwatr/nanolib/commit/adeb9166f8e911f59269032b76c36cb1888332cf))
94
- * update console_ declaration and change createLogger to a function declaration ([2252855](https://github.com/Alwatr/nanolib/commit/22528553e1bb4393ad7fc5583ef7391cd8b0f045))
95
-
96
- ### 🧹 Miscellaneous Chores
97
-
98
- * remove duplicate sideEffects property from multiple package.json files ([b123f86](https://github.com/Alwatr/nanolib/commit/b123f86be81481de2314aae9bb2eeb629743d24c))
99
-
100
- ## [6.0.3](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.2...@alwatr/logger@6.0.3) (2025-09-19)
101
-
102
- **Note:** Version bump only for package @alwatr/logger
103
-
104
- ## [6.0.2](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.1...@alwatr/logger@6.0.2) (2025-09-19)
105
-
106
- ### 🐛 Bug Fixes
107
-
108
- * improve default debug mode logic for CLI and browser environments ([2b339bc](https://github.com/Alwatr/nanolib/commit/2b339bc80dc8ce82e49ec8d83f690230f543c930))
109
-
110
- ## [6.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@6.0.0...@alwatr/logger@6.0.1) (2025-09-15)
111
-
112
- **Note:** Version bump only for package @alwatr/logger
113
-
114
- ## [6.0.0](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.6.2...@alwatr/logger@6.0.0) (2025-09-14)
115
-
116
- ### ⚠ BREAKING CHANGES
117
-
118
- * Internal logger config keys renamed and Color API now returns normalized values; callers must update config and run tests.
119
-
120
- با توکل بر خدا آپدیت کنید طوری نمیشه ان‌شاالله
121
-
122
- ### ✨ Features
123
-
124
- * add logTable method to AlwatrLogger interface and implement in createLogger ([33682dd](https://github.com/Alwatr/nanolib/commit/33682dde84814b121234e58a97de300d4f8b09ee))
125
-
126
- ### 🐛 Bug Fixes
127
-
128
- * access self in logger ([4898e2a](https://github.com/Alwatr/nanolib/commit/4898e2ab42482662444fede6459284004fe2ec9e))
129
- * change logTable parameter type from any to unknown for better type safety ([8f7d632](https://github.com/Alwatr/nanolib/commit/8f7d632139d0387af224b7779b3f8e3d7c061791))
130
- * correct regex in sanitizeDomain function to properly validate domain format ([831c56d](https://github.com/Alwatr/nanolib/commit/831c56d2cb77a6d8b053121cd4a034bb060b82e1))
131
- * replace globalThis initialization with getGlobalThis for improved consistency ([dff4090](https://github.com/Alwatr/nanolib/commit/dff40901f060815ff0f8800487a7bb091c2367ff))
132
- * update default debug mode logic to include NODE_ENV check for CLI environments ([c334071](https://github.com/Alwatr/nanolib/commit/c33407167a4be02b450249d985f43daac46b52f0))
133
-
134
- ### 🔨 Code Refactoring
135
-
136
- * enhance logger configuration and improve color handling ([7ab540d](https://github.com/Alwatr/nanolib/commit/7ab540dc5ac81561810ab1e6922b80be617f8dd6))
137
-
138
- ### 🧹 Miscellaneous Chores
139
-
140
- * remove unnecessary types from tsconfig.json for cleaner configuration ([986afde](https://github.com/Alwatr/nanolib/commit/986afde2dc976cf69f550f715d74fc5eb7a96086))
141
-
142
- ## [5.6.2](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.6.1...@alwatr/logger@5.6.2) (2025-09-13)
143
-
144
- ### 🔗 Dependencies update
145
-
146
- * update @types/node version to ^22.18.3 in multiple package.json files ([13db6fc](https://github.com/Alwatr/nanolib/commit/13db6fc176bc6cdcefedc50d77ac550bd5052c9a))
147
-
148
- ## [5.6.1](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.6.0...@alwatr/logger@5.6.1) (2025-09-13)
149
-
150
- ### 🧹 Miscellaneous Chores
151
-
152
- * remove package-tracer dependency and related code from fetch package ([96fe4e9](https://github.com/Alwatr/nanolib/commit/96fe4e9552a205f218ceed187c55e4e904a07089))
153
- * remove package-tracer dependency and related code from logger ([7dcc7e2](https://github.com/Alwatr/nanolib/commit/7dcc7e27d6d4aeb1b3efe262b10e12cb80363fd1))
154
-
155
- ## [5.6.0](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.10...@alwatr/logger@5.6.0) (2025-09-13)
156
-
157
- ### ✨ Features
158
-
159
- * **logger:** change domain sanitization to use curly braces instead of square brackets ([b1898c5](https://github.com/Alwatr/nanolib/commit/b1898c5f0805901af7a137bb064e3e23e61f0591))
160
-
161
- ## [5.5.10](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.9...@alwatr/logger@5.5.10) (2025-09-09)
162
-
163
- ### 🧹 Miscellaneous Chores
164
-
165
- * remove trailing newlines from contributing sections in README files ([e8ab1bc](https://github.com/Alwatr/nanolib/commit/e8ab1bc43e0addea5ccd4c897c2cec597cb9e15f))
166
-
167
- ## [5.5.9](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.8...@alwatr/logger@5.5.9) (2025-09-06)
168
-
169
- **Note:** Version bump only for package @alwatr/logger
170
-
171
- ## [5.5.8](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.7...@alwatr/logger@5.5.8) (2025-09-05)
172
-
173
- ### 🔗 Dependencies update
174
-
175
- * update jest to version 30.1.3 and @types/node to version 22.18.1 ([754212b](https://github.com/Alwatr/nanolib/commit/754212b1523cfc4cfe26c9e9f6d634aa8311e0b7))
176
-
177
- ## [5.5.7](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.6...@alwatr/logger@5.5.7) (2025-09-01)
178
-
179
- ### 🔗 Dependencies update
180
-
181
- * update lerna-lite dependencies to version 4.7.3 and jest to 30.1.2 ([95d7870](https://github.com/Alwatr/nanolib/commit/95d7870ec7ad1e6ed2688bafddcabf46857f6981))
182
-
183
- ## [5.5.6](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.5...@alwatr/logger@5.5.6) (2025-08-23)
184
-
185
- **Note:** Version bump only for package @alwatr/logger
186
-
187
- ## [5.5.5](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.3...@alwatr/logger@5.5.5) (2025-08-23)
188
-
189
- ### 🐛 Bug Fixes
190
-
191
- * update license from AGPL-3.0-only to MPL-2.0 ([d20968e](https://github.com/Alwatr/nanolib/commit/d20968e60cc89b1dcdf9b96507178da6ed562f55))
192
- * update package versions in multiple package.json files ([7638b1c](https://github.com/Alwatr/nanolib/commit/7638b1cafee2b4e0f97db7a89ac9fba6384b9b10))
193
-
194
- ### 🔨 Code Refactoring
195
-
196
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3))
197
-
198
- ### 🧹 Miscellaneous Chores
199
-
200
- * reformat all package.json files ([ceda45d](https://github.com/Alwatr/nanolib/commit/ceda45de186667790474f729cb4b161a5148ce19))
201
-
202
- ### 🔗 Dependencies update
203
-
204
- * revert @types/node version to ^22.17.2 (LTS) ([49f8101](https://github.com/Alwatr/nanolib/commit/49f8101eac5c41aa7684112f4308254dbfab9787))
205
- * update TypeScript and Jest versions across all packages to improve compatibility and performance ([31baf36](https://github.com/Alwatr/nanolib/commit/31baf366101e92e27db66a21c849fb101f19be47))
206
-
207
- ## [5.5.4](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.3...@alwatr/logger@5.5.4) (2025-08-23)
208
-
209
- ### Code Refactoring
210
-
211
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3)) by @alimd
212
-
213
- ## <small>5.5.3 (2025-04-15)</small>
214
-
215
- **Note:** Version bump only for package @alwatr/logger
216
-
217
- ## [5.5.2](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.1...@alwatr/logger@5.5.2) (2025-04-01)
218
-
219
- ### Dependencies update
220
-
221
- * bump the development-dependencies group across 1 directory with 2 updates ([c1320b4](https://github.com/Alwatr/nanolib/commit/c1320b447a492c5e720e25ad71e9df81eeea3670)) by @dependabot[bot]
222
-
223
- ## [5.5.1](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.0...@alwatr/logger@5.5.1) (2025-03-18)
224
-
225
- ### Dependencies update
226
-
227
- * bump the development-dependencies group with 9 updates ([7290aa3](https://github.com/Alwatr/nanolib/commit/7290aa3b52ce66ca237d2a12d28a7687b113f83d)) by @dependabot[bot]
228
-
229
- ## [5.5.0](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.4.0...@alwatr/logger@5.5.0) (2025-03-06)
230
-
231
- ### Miscellaneous Chores
232
-
233
- * update username casing in changelog entries ([9722ac9](https://github.com/Alwatr/nanolib/commit/9722ac9a078438a4e8ebfa5826ea70e0e3a52ca6)) by @
234
-
235
- ### Dependencies update
236
-
237
- * bump the development-dependencies group across 1 directory with 11 updates ([720c395](https://github.com/Alwatr/nanolib/commit/720c3954da55c929fe8fb16957121f4c51fb7f0c)) by @dependabot[bot]
238
-
239
- ## [5.4.0](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@4.0.8...@alwatr/logger@5.4.0) (2025-02-18)
240
-
241
- ### Dependencies update
242
-
243
- * bump @types/node from ^22.13.0 to ^22.13.4 and prettier from 3.4.2 to 3.5.1; update eslint-import-resolver-typescript to 3.8.2 ([b9a8399](https://github.com/Alwatr/nanolib/commit/b9a8399add39509e90bfdc589fb5e2321718029d)) by @
244
-
245
- ## 5.3.0 (2025-02-03)
246
-
247
- ### Miscellaneous Chores
248
-
249
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @
250
-
251
- ### Dependencies update
252
-
253
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @
254
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @
255
-
256
- ## 5.0.0 (2024-11-02)
257
-
258
- ### ⚠ BREAKING CHANGES
259
-
260
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
261
-
262
- ### Code Refactoring
263
-
264
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
265
-
266
- ## [5.3.0](https://github.com/Alwatr/nanolib/compare/v5.2.1...v5.3.0) (2025-02-03)
267
-
268
- ### Miscellaneous Chores
269
-
270
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @ArmanAsadian
271
-
272
- ### Dependencies update
273
-
274
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @dependabot[bot]
275
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @alimd
276
-
277
- ## 5.0.0 (2024-11-02)
278
-
279
- ### ⚠ BREAKING CHANGES
280
-
281
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
282
- * **logger:** logModule renamed to logFileModule
283
- * **logger:** definePackage and dedupt remove!
284
- * **logger:** define packages removed and must use @alwatr/dedupe instead
285
- * **logger:** use DEBUG in cli and debug in browser
286
-
287
- ### Features
288
-
289
- * **logger:** add logStep method to logger ([860aeed](https://github.com/Alwatr/nanolib/commit/860aeedb2da390ee3d47c037b22a37f73e6dbbbc)) by @
290
- * **logger:** change devMode env name ([ad549dc](https://github.com/Alwatr/nanolib/commit/ad549dc39e52242261c78939bd62ca10f69cea60)) by @
291
- * **logger:** debugMode in definePackage ([9799320](https://github.com/Alwatr/nanolib/commit/97993203d76db57e55b31bef485ea77cfd32a64c)) by @
292
- * **logger:** definePackage ([dfd090e](https://github.com/Alwatr/nanolib/commit/dfd090ebd691c9a589370094d49f950524f71369)) by @
293
- * **logger:** Update debugMode to enabled by default in development mode ([bc7c7ee](https://github.com/Alwatr/nanolib/commit/bc7c7ee1118a259ceaa1be1dade90f2f9ccf9e1d)) by @
294
- * **logger:** use alwatr dedupe ([d89d076](https://github.com/Alwatr/nanolib/commit/d89d076c9fd0dd311804831b1ac0ea955efd4b6d)) by @
295
- * use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @
296
-
297
- ### Bug Fixes
298
-
299
- * __package_version__ global type ([de8a3f9](https://github.com/Alwatr/nanolib/commit/de8a3f93bdb5a786c42f56324072b4b9520ce3a1)) by @
300
- * all dependeny topology ([1c17f34](https://github.com/Alwatr/nanolib/commit/1c17f349adf3e98e2a80ab2da4f0f81028dc9c5f)) by @
301
- * exported types by add .js extensions to all imports ([fc3d83e](https://github.com/Alwatr/nanolib/commit/fc3d83e8f375da97ba276314b2e6966aa82c9b3f)) by @
302
- * **logger:** defaultDebugMode ([bab9f7c](https://github.com/Alwatr/nanolib/commit/bab9f7c7b26fc2f50476ebc74d484a4b39c9dbda)) by @
303
- * **logger:** definePackage ([e2e5c6c](https://github.com/Alwatr/nanolib/commit/e2e5c6c8175d6f7bfba1d103c1cac2f647aa6116)) by @
304
- * **logger:** Update default debug mode logic for prevent side-effects ([42101d6](https://github.com/Alwatr/nanolib/commit/42101d6471bd0d4e88e47dc8321dddc1cd63cec8)) by @
305
-
306
- ### Code Refactoring
307
-
308
- * **logger:** prevent side-effects ([e084894](https://github.com/Alwatr/nanolib/commit/e084894cdc4b46d52d99be872f5f789fe83c3cc0)) by @
309
- * **logger:** remove definePackage from logger ([c8a9d0c](https://github.com/Alwatr/nanolib/commit/c8a9d0cdcc3e45e7a33731ec6ee6a496451e9eb1)) by @
310
- * **logger:** rename logModule to logFileModule ([1f6bd71](https://github.com/Alwatr/nanolib/commit/1f6bd71272007f5bbc90258ffa13b7d851e0918c)) by @
311
- * prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @
312
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
313
-
314
- ### Miscellaneous Chores
315
-
316
- * **dedupe:** fix version ([9754409](https://github.com/Alwatr/nanolib/commit/9754409d978265ba2ce08a9f86af1d1e143940e4)) by @
317
- * **deps-dev:** bump the development-dependencies group with 3 updates ([0e0ec0f](https://github.com/Alwatr/nanolib/commit/0e0ec0f7c66c849727563cabe0e88606aee49035)) by @
318
- * **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @
319
- * **deps:** update ([8e70dff](https://github.com/Alwatr/nanolib/commit/8e70dffb1e751496ef2e72d6cffd685f1fea44e3)) by @
320
- * **deps:** update ([f0b60d2](https://github.com/Alwatr/nanolib/commit/f0b60d24c9fae6190940baf95167a1175360d4b3)) by @
321
- * fix all typescript reference ([dea4c44](https://github.com/Alwatr/nanolib/commit/dea4c4414167602ea2f13888c6ecee24eb65ed93)) by @
322
- * include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @
323
- * **logger:** add reference ([2f30ef1](https://github.com/Alwatr/nanolib/commit/2f30ef15240a3629c7697409c322c7fdfc91a5f8)) by @
324
- * **logger:** change the license to AGPL-3.0 ([4bb4673](https://github.com/Alwatr/nanolib/commit/4bb4673972069a307e799cad9a5078b0288a9340)) by @
325
- * **logger:** Fix import file extensions ([faeef41](https://github.com/Alwatr/nanolib/commit/faeef41b0115fc5b9b22ba297e936bad68a71343)) by @
326
- * **logger:** Fix import file extensions ([f620739](https://github.com/Alwatr/nanolib/commit/f6207396504fe3a2a708ad0feaf988d14f99d130)) by @
327
- * **logger:** rename main file ([618d008](https://github.com/Alwatr/nanolib/commit/618d008c23561105ba45acb31dedcf2daafe4202)) by @
328
- * **logger:** update dedupe version ([9704dc9](https://github.com/Alwatr/nanolib/commit/9704dc92a4614aaa9ba25d88bcc1beee2bc826f4)) by @
329
- * Update build and lint scripts ([392d0b7](https://github.com/Alwatr/nanolib/commit/392d0b71f446bce336b0256119a80f07aff794ba)) by @
330
- * Update debug command in package.json ([be8403d](https://github.com/Alwatr/nanolib/commit/be8403dec754f2117259bb915b110ea386596401)) by @
331
- * Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
332
-
333
- ### Dependencies update
334
-
335
- * bump @types/node ([3d80fed](https://github.com/Alwatr/nanolib/commit/3d80fedaf720af792feb060c2f81c737ebb84e11)) by @
336
- * bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @
337
- * bump the development-dependencies group across 1 directory with 2 updates ([2dfda9e](https://github.com/Alwatr/nanolib/commit/2dfda9ec38a595f1fd961490d1a2fbf060f20a66)) by @
338
- * bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @
339
- * bump the development-dependencies group with 2 updates ([be5d6c2](https://github.com/Alwatr/nanolib/commit/be5d6c2d86b937f32cebc6848aaff85af07055dd)) by @
340
- * bump the development-dependencies group with 8 updates ([16847ac](https://github.com/Alwatr/nanolib/commit/16847acba91da027c422e3910d0f2dcc1f084e93)) by @
341
- * upd ([451d025](https://github.com/Alwatr/nanolib/commit/451d0255ba96ed55f897a6f44f62cf4e6d2b12be)) by @
342
- * update ([4434ba6](https://github.com/Alwatr/nanolib/commit/4434ba67c3f576bb1a0c307fbdb263c43cd9733a)) by @
343
- * update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @
344
- * update all ([53342f6](https://github.com/Alwatr/nanolib/commit/53342f67a8a013127f073540bc11929f1813c05c)) by @
345
- * update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @
346
- * update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
347
- * upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @
348
-
349
- ## [4.0.8](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@4.0.7...@alwatr/logger@4.0.8) (2024-11-02)
350
-
351
- ### Dependencies update
352
-
353
- * update ([4434ba6](https://github.com/Alwatr/nanolib/commit/4434ba67c3f576bb1a0c307fbdb263c43cd9733a)) by @alimd
354
-
355
- ## [4.0.7](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@4.0.6...@alwatr/logger@4.0.7) (2024-10-25)
356
-
357
- ### Dependencies update
358
-
359
- * bump the development-dependencies group across 1 directory with 2 updates ([2dfda9e](https://github.com/Alwatr/nanolib/commit/2dfda9ec38a595f1fd961490d1a2fbf060f20a66)) by @dependabot[bot]
360
- * bump the development-dependencies group with 8 updates ([16847ac](https://github.com/Alwatr/nanolib/commit/16847acba91da027c422e3910d0f2dcc1f084e93)) by @dependabot[bot]
361
-
362
- ## [4.0.6](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@4.0.5...@alwatr/logger@4.0.6) (2024-10-12)
363
-
364
- **Note:** Version bump only for package @alwatr/logger
365
-
366
- ## [4.0.5](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@4.0.4...@alwatr/logger@4.0.5) (2024-10-11)
367
-
368
- ### Bug Fixes
369
-
370
- - **logger:** Update default debug mode logic for prevent side-effects ([42101d6](https://github.com/Alwatr/nanolib/commit/42101d6471bd0d4e88e47dc8321dddc1cd63cec8)) by @alimd
371
-
372
- ### Code Refactoring
373
-
374
- - **logger:** prevent side-effects ([e084894](https://github.com/Alwatr/nanolib/commit/e084894cdc4b46d52d99be872f5f789fe83c3cc0)) by @mohammadhonarvar
375
- - prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @mohammadhonarvar
376
-
377
- ## [4.0.4](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@4.0.3...@alwatr/logger@4.0.4) (2024-10-11)
378
-
379
- ### Miscellaneous Chores
380
-
381
- - include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @alimd
382
-
383
- ## [4.0.3](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@4.0.2...@alwatr/logger@4.0.3) (2024-10-11)
384
-
385
- **Note:** Version bump only for package @alwatr/logger
386
-
387
- ## [4.0.2](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@4.0.1...@alwatr/logger@4.0.2) (2024-10-10)
388
-
389
- ### Dependencies update
390
-
391
- - bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @dependabot[bot]
392
-
393
- ## [4.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@4.0.0...@alwatr/logger@4.0.1) (2024-10-08)
394
-
395
- **Note:** Version bump only for package @alwatr/logger
396
-
397
- ## [4.0.0](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.14...@alwatr/logger@4.0.0) (2024-09-29)
398
-
399
- ### ⚠ BREAKING CHANGES
400
-
401
- - **logger:** logModule renamed to logFileModule
402
- - **logger:** definePackage and dedupt remove!
403
-
404
- ### Features
405
-
406
- - **logger:** add logStep method to logger ([860aeed](https://github.com/Alwatr/nanolib/commit/860aeedb2da390ee3d47c037b22a37f73e6dbbbc)) by @alimd
407
- - use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @mohammadhonarvar
408
-
409
- ### Bug Fixes
410
-
411
- - all dependeny topology ([1c17f34](https://github.com/Alwatr/nanolib/commit/1c17f349adf3e98e2a80ab2da4f0f81028dc9c5f)) by @mohammadhonarvar
412
-
413
- ### Code Refactoring
414
-
415
- - **logger:** remove definePackage from logger ([c8a9d0c](https://github.com/Alwatr/nanolib/commit/c8a9d0cdcc3e45e7a33731ec6ee6a496451e9eb1)) by @mohammadhonarvar
416
- - **logger:** rename logModule to logFileModule ([1f6bd71](https://github.com/Alwatr/nanolib/commit/1f6bd71272007f5bbc90258ffa13b7d851e0918c)) by @alimd
417
-
418
- ### Miscellaneous Chores
419
-
420
- - **logger:** change the license to AGPL-3.0 ([4bb4673](https://github.com/Alwatr/nanolib/commit/4bb4673972069a307e799cad9a5078b0288a9340)) by @alimd
421
- - Update build and lint scripts ([392d0b7](https://github.com/Alwatr/nanolib/commit/392d0b71f446bce336b0256119a80f07aff794ba)) by @alimd
422
-
423
- ### Dependencies update
424
-
425
- - bump @types/node ([3d80fed](https://github.com/Alwatr/nanolib/commit/3d80fedaf720af792feb060c2f81c737ebb84e11)) by @dependabot[bot]
426
-
427
- ## [3.2.14](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.13...@alwatr/logger@3.2.14) (2024-09-21)
428
-
429
- **Note:** Version bump only for package @alwatr/logger
430
-
431
- ## [3.2.13](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.12...@alwatr/logger@3.2.13) (2024-09-15)
432
-
433
- ### Dependencies update
434
-
435
- - bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @dependabot[bot]
436
- - update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @alimd
437
-
438
- ## [3.2.12](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.11...@alwatr/logger@3.2.12) (2024-08-31)
439
-
440
- ### Miscellaneous Chores
441
-
442
- - Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
443
-
444
- ## [3.2.11](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.10...@alwatr/logger@3.2.11) (2024-08-31)
445
-
446
- **Note:** Version bump only for package @alwatr/logger
447
-
448
- ## [3.2.10](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.9...@alwatr/logger@3.2.10) (2024-08-31)
449
-
450
- ### Dependencies update
451
-
452
- - update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @alimd
453
-
454
- ## [3.2.9](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.8...@alwatr/logger@3.2.9) (2024-07-04)
455
-
456
- ### Dependencies update
457
-
458
- - update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
459
-
460
- ## [3.2.8](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.7...@alwatr/logger@3.2.8) (2024-05-12)
461
-
462
- ### Dependencies update
463
-
464
- - upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @alimd
465
-
466
- ## [3.2.7](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.6...@alwatr/logger@3.2.7) (2024-04-25)
467
-
468
- **Note:** Version bump only for package @alwatr/logger
469
-
470
- ## [3.2.6](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.5...@alwatr/logger@3.2.6) (2024-03-28)
471
-
472
- **Note:** Version bump only for package @alwatr/logger
473
-
474
- ## [3.2.5](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.4...@alwatr/logger@3.2.5) (2024-01-31)
475
-
476
- ### Bug Fixes
477
-
478
- - exported types by add .js extensions to all imports ([fc3d83e](https://github.com/Alwatr/nanolib/commit/fc3d83e8f375da97ba276314b2e6966aa82c9b3f)) by @alimd
479
-
480
- ### Miscellaneous Chores
481
-
482
- - **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @alimd
483
-
484
- ## [3.2.4](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.3...@alwatr/logger@3.2.4) (2024-01-24)
485
-
486
- **Note:** Version bump only for package @alwatr/logger
487
-
488
- ## [3.2.3](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.2...@alwatr/logger@3.2.3) (2024-01-20)
489
-
490
- **Note:** Version bump only for package @alwatr/logger
491
-
492
- ## [3.2.2](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.1...@alwatr/logger@3.2.2) (2024-01-16)
493
-
494
- **Note:** Version bump only for package @alwatr/logger
495
-
496
- ## [3.2.1](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.2.0...@alwatr/logger@3.2.1) (2024-01-08)
497
-
498
- **Note:** Version bump only for package @alwatr/logger
499
-
500
- # [3.2.0](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.1.0...@alwatr/logger@3.2.0) (2024-01-08)
501
-
502
- ### Bug Fixes
503
-
504
- - **logger:** defaultDebugMode ([bab9f7c](https://github.com/Alwatr/nanolib/commit/bab9f7c7b26fc2f50476ebc74d484a4b39c9dbda)) by @alimd
505
-
506
- ### Features
507
-
508
- - **logger:** debugMode in definePackage ([9799320](https://github.com/Alwatr/nanolib/commit/97993203d76db57e55b31bef485ea77cfd32a64c)) by @njfamirm
509
-
510
- # [3.1.0](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.0.1...@alwatr/logger@3.1.0) (2024-01-06)
511
-
512
- ### Features
513
-
514
- - **logger:** definePackage ([dfd090e](https://github.com/Alwatr/nanolib/commit/dfd090ebd691c9a589370094d49f950524f71369)) by @alimd
515
-
516
- ## [3.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@3.0.0...@alwatr/logger@3.0.1) (2024-01-03)
517
-
518
- **Note:** Version bump only for package @alwatr/logger
519
-
520
- # 3.0.0 (2024-01-03)
521
-
522
- ### Bug Fixes
523
-
524
- - `__package_version__` global type ([de8a3f9](https://github.com/Alwatr/nanolib/commit/de8a3f93bdb5a786c42f56324072b4b9520ce3a1)) by @alimd
525
- - **logger:** definePackage ([e2e5c6c](https://github.com/Alwatr/nanolib/commit/e2e5c6c8175d6f7bfba1d103c1cac2f647aa6116)) by @alimd
526
-
527
- ### Features
528
-
529
- - **logger:** change devMode env name ([ad549dc](https://github.com/Alwatr/nanolib/commit/ad549dc39e52242261c78939bd62ca10f69cea60)) by @njfamirm
530
- - **logger:** Update debugMode to enabled by default in development mode ([bc7c7ee](https://github.com/Alwatr/nanolib/commit/bc7c7ee1118a259ceaa1be1dade90f2f9ccf9e1d)) by @alimd
531
- - **logger:** use alwatr dedupe ([d89d076](https://github.com/Alwatr/nanolib/commit/d89d076c9fd0dd311804831b1ac0ea955efd4b6d)) by @njfamirm
532
-
533
- ### BREAKING CHANGES
534
-
535
- - **logger:** define packages removed and must use @alwatr/dedupe instead
536
- - **logger:** use DEBUG in cli and debug in browser
package/dist/main.cjs DELETED
@@ -1,7 +0,0 @@
1
- /** 📦 @alwatr/logger v6.0.18 */
2
- "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{createLogger:()=>createLogger});module.exports=__toCommonJS(main_exports);var import_global_this=require("@alwatr/global-this");var import_platform_info=require("@alwatr/platform-info");var console_=(0,import_global_this.getGlobalThis)().console;var defaultDebugMode=(()=>{if(import_platform_info.platformInfo.development){if(import_platform_info.platformInfo.isCli){return process.env.ALWATR_DEBUG!=="0"}else{return typeof localStorage!=="undefined"&&localStorage.getItem("ALWATR_DEBUG")!=="0"}}return import_platform_info.platformInfo.isCli?Boolean(process.env.DEBUG):typeof localStorage!=="undefined"&&localStorage.getItem("ALWATR_DEBUG")==="1"})();var colorList=(()=>import_platform_info.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"])();var style_=(()=>({scope:import_platform_info.platformInfo.isCli?"\x1B[{{color}}m":"color: {{color}};",reset:import_platform_info.platformInfo.isCli?"\x1B[0m":"color: inherit;"}))();var keySection_=(()=>import_platform_info.platformInfo.isCli?"%s%s%s":"%c%s%c")();var colorIndex_=0;function getNextColor_(){const color=colorList[colorIndex_];colorIndex_=(colorIndex_+1)%colorList.length;return color}function sanitizeDomain_(domain){domain=domain.trim();if(!/^[[{<]/.test(domain)){domain=`{${domain}}`}return domain}function createLogger(domain,debugMode=defaultDebugMode){const color=getNextColor_();const styleScope=style_.scope.replace("{{color}}",color);const sanitizedDomain=sanitizeDomain_(domain);const requiredItems={debugMode,banner:import_platform_info.platformInfo.isCli?console_.log.bind(console_,`\x1B[1;37;45m {{{ %s }}} ${style_.reset}`):console_.log.bind(console_,"%c%s","font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;"),accident:import_platform_info.platformInfo.isCli?console_.warn.bind(console_,`${styleScope}⚠️
3
- %s\x1B[33m.%s() Accident \`%s\`!${style_.reset}`,sanitizedDomain):console_.warn.bind(console_,"%c%s%c.%s() Accident `%s`!",styleScope,sanitizedDomain,style_.reset),error:import_platform_info.platformInfo.isCli?console_.error.bind(console_,`${styleScope}❌
4
- %s\x1B[31m.%s() Error \`%s\`${style_.reset}
5
- `,sanitizedDomain):console_.error.bind(console_,"%c%s%c.%s() Error `%s`\n",styleScope,sanitizedDomain,style_.reset)};if(!debugMode){return requiredItems}return{...requiredItems,logProperty:console_.debug.bind(console_,keySection_+".%s = %o;",styleScope,sanitizedDomain,style_.reset),logMethod:console_.debug.bind(console_,keySection_+".%s();",styleScope,sanitizedDomain,style_.reset),logFileModule:console_.debug.bind(console_,keySection_+"/%s.js;",styleScope,sanitizedDomain,style_.reset),logMethodArgs:console_.debug.bind(console_,keySection_+".%s(%o);",styleScope,sanitizedDomain,style_.reset),logMethodFull:console_.debug.bind(console_,keySection_+".%s(%o) => %o",styleScope,sanitizedDomain,style_.reset),logStep:console_.debug.bind(console_,keySection_+".%s() -> %s",styleScope,sanitizedDomain,style_.reset),logOther:console_.debug.bind(console_,keySection_,styleScope,sanitizedDomain,style_.reset),logTable:console_.table.bind(console_),incident:import_platform_info.platformInfo.isCli?console_.log.bind(console_,`${styleScope}🚸
6
- %s${style_.reset}.%s() Incident \`%s\`!${style_.reset}`,sanitizedDomain):console_.log.bind(console_,"%c%s%c.%s() Incident `%s`!",styleScope,sanitizedDomain,"color: orange;"),time:label=>console_.time(sanitizedDomain+"."+label),timeEnd:label=>console_.timeEnd(sanitizedDomain+"."+label)}}0&&(module.exports={createLogger});
7
- //# sourceMappingURL=main.cjs.map
package/dist/main.cjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts", "../src/logger.ts"],
4
- "sourcesContent": ["export * from './logger.js';\nexport * from './type.js';\n", "import {getGlobalThis} from '@alwatr/global-this';\nimport {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\nconst console_ = getGlobalThis().console;\n\n/**\n * Default debug mode state, determined by environment variables or localStorage.\n */\nconst defaultDebugMode = (() => {\n if (platformInfo.development) {\n if (platformInfo.isCli) {\n return process.env.ALWATR_DEBUG !== '0';\n }\n else {\n return typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') !== '0';\n }\n }\n // else\n return platformInfo.isCli\n ? Boolean(process.env.DEBUG)\n : typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') === '1';\n})();\n\n/**\n * A list of aesthetically pleasing colors for console logging, adapted for CLI and browser environments.\n */\nconst colorList = (() =>\n platformInfo.isCli\n ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // CLI-safe colors\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\n/**\n * Platform-specific styling templates for logger output.\n */\nconst style_ = (() => ({\n scope: platformInfo.isCli ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: platformInfo.isCli ? '\\x1b[0m' : 'color: inherit;',\n}))();\n\n/**\n * Platform-specific format for displaying the logger's scope.\n */\nconst keySection_ = (() => (platformInfo.isCli ? '%s%s%s' : '%c%s%c'))();\n\n// --- Utility Functions ---\n\nlet colorIndex_ = 0;\n/**\n * Cycles through the `colorList` to provide a new color for each logger instance.\n */\nfunction getNextColor_(): string {\n const color = colorList[colorIndex_];\n colorIndex_ = (colorIndex_ + 1) % colorList.length;\n return color;\n}\n\n/**\n * Sanitizes and formats the logger domain string by wrapping it in brackets if not already.\n */\nfunction sanitizeDomain_(domain: string): string {\n domain = domain.trim();\n if (!/^[[{<]/.test(domain)) {\n domain = `{${domain}}`;\n }\n return domain;\n}\n\n// --- Core Factory ---\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - `color` is optional and automatically selected from an internal list.\n * - `debug` is optional and automatically detected from `ALWATR_DEBUG` in localStorage or `process.env.DEBUG`.\n *\n * @example\n * ```ts\n * import {createLogger} from '@alwatr/logger';\n * const logger = createLogger('my-module');\n *\n * logger.logMethodArgs?.('myMethod', {a: 1}); // This line is ignored if debugMode is false.\n * ```\n */\nexport function createLogger(domain: string, debugMode = defaultDebugMode): AlwatrLogger {\n const color = getNextColor_();\n const styleScope = style_.scope.replace('{{color}}', color);\n const sanitizedDomain = sanitizeDomain_(domain);\n\n /**\n * Logger methods that are always available, regardless of debugMode.\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}`, sanitizedDomain)\n : console_.warn.bind(console_, '%c%s%c.%s() Accident `%s`!', styleScope, sanitizedDomain, style_.reset),\n\n error: platformInfo.isCli\n ? console_.error.bind(console_, `${styleScope}❌\\n%s\\x1b[31m.%s() Error \\`%s\\`${style_.reset}\\n`, sanitizedDomain)\n : console_.error.bind(console_, '%c%s%c.%s() Error `%s`\\n', styleScope, sanitizedDomain, style_.reset),\n };\n\n if (!debugMode) {\n return requiredItems;\n }\n\n /**\n * Logger methods available only when debugMode is true.\n * Using `console.debug` which is often filtered by default in browsers unless \"Verbose\" logs are enabled.\n */\n return {\n ...requiredItems,\n\n logProperty: console_.debug.bind(console_, keySection_ + '.%s = %o;', styleScope, sanitizedDomain, style_.reset),\n\n logMethod: console_.debug.bind(console_, keySection_ + '.%s();', styleScope, sanitizedDomain, style_.reset),\n\n logFileModule: console_.debug.bind(console_, keySection_ + '/%s.js;', styleScope, sanitizedDomain, style_.reset),\n\n logMethodArgs: console_.debug.bind(console_, keySection_ + '.%s(%o);', styleScope, sanitizedDomain, style_.reset),\n\n logMethodFull: console_.debug.bind(console_, keySection_ + '.%s(%o) => %o', styleScope, sanitizedDomain, style_.reset),\n\n logStep: console_.debug.bind(console_, keySection_ + '.%s() -> %s', styleScope, sanitizedDomain, style_.reset),\n\n logOther: console_.debug.bind(console_, keySection_, styleScope, sanitizedDomain, style_.reset),\n\n logTable: console_.table.bind(console_),\n\n incident: platformInfo.isCli\n ? console_.log.bind(console_, `${styleScope}🚸\\n%s${style_.reset}.%s() Incident \\`%s\\`!${style_.reset}`, sanitizedDomain)\n : console_.log.bind(console_, '%c%s%c.%s() Incident `%s`!', styleScope, sanitizedDomain, 'color: orange;'),\n\n time: (label: string) => console_.time(sanitizedDomain + '.' + label),\n timeEnd: (label: string) => console_.timeEnd(sanitizedDomain + '.' + label),\n } as const;\n}\n"],
5
- "mappings": "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",
6
- "names": []
7
- }
package/dist/main.mjs DELETED
@@ -1,7 +0,0 @@
1
- /** 📦 @alwatr/logger v6.0.18 */
2
- import{getGlobalThis}from"@alwatr/global-this";import{platformInfo}from"@alwatr/platform-info";var console_=getGlobalThis().console;var defaultDebugMode=(()=>{if(platformInfo.development){if(platformInfo.isCli){return process.env.ALWATR_DEBUG!=="0"}else{return typeof localStorage!=="undefined"&&localStorage.getItem("ALWATR_DEBUG")!=="0"}}return platformInfo.isCli?Boolean(process.env.DEBUG):typeof localStorage!=="undefined"&&localStorage.getItem("ALWATR_DEBUG")==="1"})();var colorList=(()=>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"])();var style_=(()=>({scope:platformInfo.isCli?"\x1B[{{color}}m":"color: {{color}};",reset:platformInfo.isCli?"\x1B[0m":"color: inherit;"}))();var keySection_=(()=>platformInfo.isCli?"%s%s%s":"%c%s%c")();var colorIndex_=0;function getNextColor_(){const color=colorList[colorIndex_];colorIndex_=(colorIndex_+1)%colorList.length;return color}function sanitizeDomain_(domain){domain=domain.trim();if(!/^[[{<]/.test(domain)){domain=`{${domain}}`}return domain}function createLogger(domain,debugMode=defaultDebugMode){const color=getNextColor_();const styleScope=style_.scope.replace("{{color}}",color);const sanitizedDomain=sanitizeDomain_(domain);const requiredItems={debugMode,banner:platformInfo.isCli?console_.log.bind(console_,`\x1B[1;37;45m {{{ %s }}} ${style_.reset}`):console_.log.bind(console_,"%c%s","font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;"),accident:platformInfo.isCli?console_.warn.bind(console_,`${styleScope}⚠️
3
- %s\x1B[33m.%s() Accident \`%s\`!${style_.reset}`,sanitizedDomain):console_.warn.bind(console_,"%c%s%c.%s() Accident `%s`!",styleScope,sanitizedDomain,style_.reset),error:platformInfo.isCli?console_.error.bind(console_,`${styleScope}❌
4
- %s\x1B[31m.%s() Error \`%s\`${style_.reset}
5
- `,sanitizedDomain):console_.error.bind(console_,"%c%s%c.%s() Error `%s`\n",styleScope,sanitizedDomain,style_.reset)};if(!debugMode){return requiredItems}return{...requiredItems,logProperty:console_.debug.bind(console_,keySection_+".%s = %o;",styleScope,sanitizedDomain,style_.reset),logMethod:console_.debug.bind(console_,keySection_+".%s();",styleScope,sanitizedDomain,style_.reset),logFileModule:console_.debug.bind(console_,keySection_+"/%s.js;",styleScope,sanitizedDomain,style_.reset),logMethodArgs:console_.debug.bind(console_,keySection_+".%s(%o);",styleScope,sanitizedDomain,style_.reset),logMethodFull:console_.debug.bind(console_,keySection_+".%s(%o) => %o",styleScope,sanitizedDomain,style_.reset),logStep:console_.debug.bind(console_,keySection_+".%s() -> %s",styleScope,sanitizedDomain,style_.reset),logOther:console_.debug.bind(console_,keySection_,styleScope,sanitizedDomain,style_.reset),logTable:console_.table.bind(console_),incident:platformInfo.isCli?console_.log.bind(console_,`${styleScope}🚸
6
- %s${style_.reset}.%s() Incident \`%s\`!${style_.reset}`,sanitizedDomain):console_.log.bind(console_,"%c%s%c.%s() Incident `%s`!",styleScope,sanitizedDomain,"color: orange;"),time:label=>console_.time(sanitizedDomain+"."+label),timeEnd:label=>console_.timeEnd(sanitizedDomain+"."+label)}}export{createLogger};
7
- //# sourceMappingURL=main.mjs.map
package/dist/main.mjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/logger.ts"],
4
- "sourcesContent": ["import {getGlobalThis} from '@alwatr/global-this';\nimport {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\nconst console_ = getGlobalThis().console;\n\n/**\n * Default debug mode state, determined by environment variables or localStorage.\n */\nconst defaultDebugMode = (() => {\n if (platformInfo.development) {\n if (platformInfo.isCli) {\n return process.env.ALWATR_DEBUG !== '0';\n }\n else {\n return typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') !== '0';\n }\n }\n // else\n return platformInfo.isCli\n ? Boolean(process.env.DEBUG)\n : typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') === '1';\n})();\n\n/**\n * A list of aesthetically pleasing colors for console logging, adapted for CLI and browser environments.\n */\nconst colorList = (() =>\n platformInfo.isCli\n ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // CLI-safe colors\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\n/**\n * Platform-specific styling templates for logger output.\n */\nconst style_ = (() => ({\n scope: platformInfo.isCli ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: platformInfo.isCli ? '\\x1b[0m' : 'color: inherit;',\n}))();\n\n/**\n * Platform-specific format for displaying the logger's scope.\n */\nconst keySection_ = (() => (platformInfo.isCli ? '%s%s%s' : '%c%s%c'))();\n\n// --- Utility Functions ---\n\nlet colorIndex_ = 0;\n/**\n * Cycles through the `colorList` to provide a new color for each logger instance.\n */\nfunction getNextColor_(): string {\n const color = colorList[colorIndex_];\n colorIndex_ = (colorIndex_ + 1) % colorList.length;\n return color;\n}\n\n/**\n * Sanitizes and formats the logger domain string by wrapping it in brackets if not already.\n */\nfunction sanitizeDomain_(domain: string): string {\n domain = domain.trim();\n if (!/^[[{<]/.test(domain)) {\n domain = `{${domain}}`;\n }\n return domain;\n}\n\n// --- Core Factory ---\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - `color` is optional and automatically selected from an internal list.\n * - `debug` is optional and automatically detected from `ALWATR_DEBUG` in localStorage or `process.env.DEBUG`.\n *\n * @example\n * ```ts\n * import {createLogger} from '@alwatr/logger';\n * const logger = createLogger('my-module');\n *\n * logger.logMethodArgs?.('myMethod', {a: 1}); // This line is ignored if debugMode is false.\n * ```\n */\nexport function createLogger(domain: string, debugMode = defaultDebugMode): AlwatrLogger {\n const color = getNextColor_();\n const styleScope = style_.scope.replace('{{color}}', color);\n const sanitizedDomain = sanitizeDomain_(domain);\n\n /**\n * Logger methods that are always available, regardless of debugMode.\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}`, sanitizedDomain)\n : console_.warn.bind(console_, '%c%s%c.%s() Accident `%s`!', styleScope, sanitizedDomain, style_.reset),\n\n error: platformInfo.isCli\n ? console_.error.bind(console_, `${styleScope}❌\\n%s\\x1b[31m.%s() Error \\`%s\\`${style_.reset}\\n`, sanitizedDomain)\n : console_.error.bind(console_, '%c%s%c.%s() Error `%s`\\n', styleScope, sanitizedDomain, style_.reset),\n };\n\n if (!debugMode) {\n return requiredItems;\n }\n\n /**\n * Logger methods available only when debugMode is true.\n * Using `console.debug` which is often filtered by default in browsers unless \"Verbose\" logs are enabled.\n */\n return {\n ...requiredItems,\n\n logProperty: console_.debug.bind(console_, keySection_ + '.%s = %o;', styleScope, sanitizedDomain, style_.reset),\n\n logMethod: console_.debug.bind(console_, keySection_ + '.%s();', styleScope, sanitizedDomain, style_.reset),\n\n logFileModule: console_.debug.bind(console_, keySection_ + '/%s.js;', styleScope, sanitizedDomain, style_.reset),\n\n logMethodArgs: console_.debug.bind(console_, keySection_ + '.%s(%o);', styleScope, sanitizedDomain, style_.reset),\n\n logMethodFull: console_.debug.bind(console_, keySection_ + '.%s(%o) => %o', styleScope, sanitizedDomain, style_.reset),\n\n logStep: console_.debug.bind(console_, keySection_ + '.%s() -> %s', styleScope, sanitizedDomain, style_.reset),\n\n logOther: console_.debug.bind(console_, keySection_, styleScope, sanitizedDomain, style_.reset),\n\n logTable: console_.table.bind(console_),\n\n incident: platformInfo.isCli\n ? console_.log.bind(console_, `${styleScope}🚸\\n%s${style_.reset}.%s() Incident \\`%s\\`!${style_.reset}`, sanitizedDomain)\n : console_.log.bind(console_, '%c%s%c.%s() Incident `%s`!', styleScope, sanitizedDomain, 'color: orange;'),\n\n time: (label: string) => console_.time(sanitizedDomain + '.' + label),\n timeEnd: (label: string) => console_.timeEnd(sanitizedDomain + '.' + label),\n } as const;\n}\n"],
5
- "mappings": "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",
6
- "names": []
7
- }