@alwatr/logger 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.3.1](https://github.com/Alwatr/eslib/compare/@alwatr/logger@2.3.0...@alwatr/logger@2.3.1) (2023-11-29)
7
+
8
+ **Note:** Version bump only for package @alwatr/logger
9
+
10
+ # [2.3.0](https://github.com/Alwatr/eslib/compare/@alwatr/logger@2.2.0...@alwatr/logger@2.3.0) (2023-11-23)
11
+
12
+ ### Features
13
+
14
+ * **logger/global:** globalScope ([8111c10](https://github.com/Alwatr/eslib/commit/8111c108edff13d433d5f2f50470d00058e761ba)) by @AliMD
15
+
6
16
  # [2.2.0](https://github.com/Alwatr/eslib/compare/@alwatr/logger@2.1.3...@alwatr/logger@2.2.0) (2023-11-14)
7
17
 
8
18
  ### Bug Fixes
@@ -1,2 +1,3 @@
1
+ import './global.js';
1
2
  export declare const definePackage: (packageName: string, version: string) => void;
2
3
  //# sourceMappingURL=define-package.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"define-package.d.ts","sourceRoot":"","sources":["src/define-package.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,aAAa,gBAAiB,MAAM,WAAW,MAAM,SAajE,CAAC"}
1
+ {"version":3,"file":"define-package.d.ts","sourceRoot":"","sources":["src/define-package.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAarB,eAAO,MAAM,aAAa,gBAAiB,MAAM,WAAW,MAAM,SAajE,CAAC"}
package/define-package.js CHANGED
@@ -1,5 +1,5 @@
1
+ import './global.js';
1
2
  import { createLogger } from './logger.js';
2
- globalThis.Alwatr ?? (globalThis.Alwatr = { packages: {} });
3
3
  Alwatr.packages ?? (Alwatr.packages = {});
4
4
  const logger = createLogger('logger');
5
5
  setTimeout(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"define-package.js","sourceRoot":"","sources":["src/define-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAIzC,UAAU,CAAC,MAAM,KAAjB,UAAU,CAAC,MAAM,GAAK,EAAC,QAAQ,EAAE,EAAE,EAAC,EAAC;AACrC,MAAM,CAAC,QAAQ,KAAf,MAAM,CAAC,QAAQ,GAAK,EAAE,EAAC;AAEvB,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAEtC,UAAU,CAAC,GAAG,EAAE;IACd,IAAI,gBAAgB,IAAI,MAAM,EAAE;QAC9B,MAAM,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,+BAA+B,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;KAC7F;AACH,CAAC,EAAE,IAAI,CAAC,CAAC;AAET,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,WAAmB,EAAE,OAAe,EAAE,EAAE;IACpE,MAAM,CAAC,aAAa,EAAE,CAAC,gBAAgB,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,CAAC,CAAC;IAEjE,IAAI,WAAW,IAAI,MAAM,CAAC,QAAQ,EAAE;QAClC,MAAM,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,2BAA2B,EAAE;YAC/D,WAAW;YACX,GAAG,EAAE,OAAO;YACZ,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;SAClC,CAAC,CAAC;QACH,OAAO;KACR;IAED,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;AACzC,CAAC,CAAC;AAEF,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC","sourcesContent":["import {createLogger} from './logger.js';\n\nimport type {} from './type.js';\n\nglobalThis.Alwatr ??= {packages: {}};\nAlwatr.packages ??= {};\n\nconst logger = createLogger('logger');\n\nsetTimeout(() => {\n if ('registeredList' in Alwatr) {\n logger.accident?.('define-package', 'duplicate_old_package_defined', Alwatr.registeredList);\n }\n}, 2000);\n\nexport const definePackage = (packageName: string, version: string) => {\n logger.logMethodArgs?.('define-package', {packageName, version});\n\n if (packageName in Alwatr.packages) {\n logger.accident?.('define-package', 'duplicate_package_defined', {\n packageName,\n new: version,\n old: Alwatr.packages[packageName],\n });\n return;\n }\n\n Alwatr.packages[packageName] = version;\n};\n\ndefinePackage('logger', '2.x');\n"]}
1
+ {"version":3,"file":"define-package.js","sourceRoot":"","sources":["src/define-package.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,QAAQ,KAAf,MAAM,CAAC,QAAQ,GAAK,EAAE,EAAC;AAEvB,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAEtC,UAAU,CAAC,GAAG,EAAE;IACd,IAAI,gBAAgB,IAAI,MAAM,EAAE,CAAC;QAC/B,MAAM,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,+BAA+B,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC,EAAE,IAAI,CAAC,CAAC;AAET,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,WAAmB,EAAE,OAAe,EAAE,EAAE;IACpE,MAAM,CAAC,aAAa,EAAE,CAAC,gBAAgB,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,CAAC,CAAC;IAEjE,IAAI,WAAW,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACnC,MAAM,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,2BAA2B,EAAE;YAC/D,WAAW;YACX,GAAG,EAAE,OAAO;YACZ,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;SAClC,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;AACzC,CAAC,CAAC;AAEF,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC","sourcesContent":["import './global.js';\nimport {createLogger} from './logger.js';\n\nAlwatr.packages ??= {};\n\nconst logger = createLogger('logger');\n\nsetTimeout(() => {\n if ('registeredList' in Alwatr) {\n logger.accident?.('define-package', 'duplicate_old_package_defined', Alwatr.registeredList);\n }\n}, 2000);\n\nexport const definePackage = (packageName: string, version: string) => {\n logger.logMethodArgs?.('define-package', {packageName, version});\n\n if (packageName in Alwatr.packages) {\n logger.accident?.('define-package', 'duplicate_package_defined', {\n packageName,\n new: version,\n old: Alwatr.packages[packageName],\n });\n return;\n }\n\n Alwatr.packages[packageName] = version;\n};\n\ndefinePackage('logger', '2.x');\n"]}
package/global.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export interface GlobalAlwatr {
2
+ packages: Record<string, string>;
3
+ }
4
+ declare global {
5
+ var Alwatr: GlobalAlwatr;
6
+ }
7
+ export declare const globalScope: typeof globalThis;
8
+ export declare const NODE_MODE: boolean;
9
+ export declare const DEV_MODE: boolean;
10
+ //# sourceMappingURL=global.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["src/global.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,MAAM,EAAE,YAAY,CAAC;CAC1B;AAED,eAAO,MAAM,WAAW,mBAIlB,CAAC;AAIP,eAAO,MAAM,SAAS,SAAiC,CAAC;AACxD,eAAO,MAAM,QAAQ,SAEuC,CAAC"}
package/global.js ADDED
@@ -0,0 +1,10 @@
1
+ export const globalScope = (typeof globalThis === 'object' && globalThis) ||
2
+ ('object' === typeof window && window) ||
3
+ ('object' === typeof global && global) ||
4
+ self;
5
+ globalScope.Alwatr ?? (globalScope.Alwatr = { packages: {} });
6
+ export const NODE_MODE = typeof process !== 'undefined';
7
+ export const DEV_MODE = NODE_MODE
8
+ ? process.env.ALWATR_DEBUG === '1'
9
+ : globalScope.localStorage?.getItem('alwatrDebug') === '1';
10
+ //# sourceMappingURL=global.js.map
package/global.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.js","sourceRoot":"","sources":["src/global.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,WAAW,GACtB,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC;IAC9C,CAAC,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,CAAC;IACtC,CAAC,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,CAAC;IACtC,IAAI,CAAC;AAEP,WAAW,CAAC,MAAM,KAAlB,WAAW,CAAC,MAAM,GAAK,EAAC,QAAQ,EAAE,EAAE,EAAC,EAAC;AAEtC,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC;AACxD,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS;IAC/B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,GAAG;IAClC,CAAC,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,GAAG,CAAC","sourcesContent":["export interface GlobalAlwatr {\n packages: Record<string, string>;\n}\n\ndeclare global {\n // eslint-disable-next-line no-var\n var Alwatr: GlobalAlwatr;\n}\n\nexport const globalScope =\n (typeof globalThis === 'object' && globalThis) ||\n ('object' === typeof window && window) ||\n ('object' === typeof global && global) ||\n self;\n\nglobalScope.Alwatr ??= {packages: {}};\n\nexport const NODE_MODE = typeof process !== 'undefined';\nexport const DEV_MODE = NODE_MODE\n ? process.env.ALWATR_DEBUG === '1'\n : globalScope.localStorage?.getItem('alwatrDebug') === '1';\n"]}
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './global.js';
1
2
  export * from './logger.js';
2
3
  export * from './define-package.js';
3
4
  export type * from './type.js';
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,mBAAmB,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,mBAAmB,WAAW,CAAA"}
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './global.js';
1
2
  export * from './logger.js';
2
3
  export * from './define-package.js';
3
4
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA","sourcesContent":["export * from './logger.js'\nexport * from './define-package.js'\nexport type * from './type.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA","sourcesContent":["export * from './global.js'\nexport * from './logger.js'\nexport * from './define-package.js'\nexport type * from './type.js'\n"]}
package/logger.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  import type { AlwatrLogger } from './type.js';
2
- export declare const NODE_MODE: boolean;
3
- export declare const DEV_MODE: boolean;
4
2
  /**
5
3
  * Create a logger function for fancy console debug with custom scope.
6
4
  *
package/logger.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAE5C,eAAO,MAAM,SAAS,SAAiC,CAAC;AACxD,eAAO,MAAM,QAAQ,SAEsC,CAAC;AAmD5D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,WAAY,MAAM,wBAAuB,YAoDjE,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAmD5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,WAAY,MAAM,wBAAuB,YAuDjE,CAAC"}
package/logger.js CHANGED
@@ -1,7 +1,4 @@
1
- export const NODE_MODE = typeof process !== 'undefined';
2
- export const DEV_MODE = NODE_MODE
3
- ? process.env.ALWATR_DEBUG === '1'
4
- : globalThis.localStorage?.getItem('alwatrDebug') === '1';
1
+ import { DEV_MODE, NODE_MODE } from './global.js';
5
2
  /**
6
3
  * Color list storage for logger.
7
4
  */
package/logger.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC;AACxD,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS;IAC/B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,GAAG;IAClC,CAAC,CAAC,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,GAAG,CAAC;AAE5D;;GAEG;AACH,MAAM,SAAS,GAAG,SAAS;IACzB,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,wBAAwB;IACnE,CAAC,CAAC;QACA,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS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ined';\nexport const DEV_MODE = NODE_MODE\n ? process.env.ALWATR_DEBUG === '1'\n : globalThis.localStorage?.getItem('alwatrDebug') === '1';\n\n/**\n * Color list storage for logger.\n */\nconst colorList = NODE_MODE\n ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // red and white omitted\n : [\n '#35b997',\n '#f05561',\n '#ee224a',\n '#91c13e',\n '#22af4b',\n '#f0e995',\n '#0fe995',\n '#0f89ca',\n '#08b9a5',\n '#fee851',\n '#ee573d',\n '#f9df30',\n '#1da2dc',\n '#f05123',\n '#ee2524',\n ];\n\nlet _colorIndex = 0;\nconst _getNextColor = (): string => {\n const color = colorList[_colorIndex];\n _colorIndex++;\n if (_colorIndex >= colorList.length) {\n _colorIndex = 0;\n }\n return color;\n};\n\nconst _style = {\n scope: NODE_MODE ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: NODE_MODE ? '\\x1b[0m' : 'color: inherit;',\n};\n\nconst _keySection = NODE_MODE ? '%s%s%s' : '%c%s%c';\n\nconst _sanitizeDomain = (domain: string): string => {\n domain = domain.trim();\n const first = domain.charAt(0);\n if (first !== '[' && first !== '{' && first !== '<') {\n domain = '[' + domain + ']';\n }\n return domain;\n};\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - **color** is optional and automatically select from internal fancy color list.\n * - **debug** is optional and automatically detect from localStorage `ALWATR_DEBUG` item or `process.env.ALWATR_DEBUG`\n *\n * Example:\n *\n * ```ts\n * import {createLogger} from 'https://esm.run/@alwatr/logger';\n * const logger = createLogger('logger/demo');\n * ```\n */\nexport const createLogger = (domain: string, devMode = DEV_MODE): AlwatrLogger => {\n const color = _getNextColor();\n const styleScope = _style.scope.replaceAll('{{color}}', color);\n domain = _sanitizeDomain(domain);\n\n /**\n * Required logger object, accident, error always reported even when the devMode is false.\n */\n const requiredItems: AlwatrLogger = {\n devMode,\n domain,\n\n banner: NODE_MODE\n ? console.log.bind(console, `\\x1b[1;37;45m\\n\\n %s${_style.reset}`)\n : console.log.bind(console, '%c%s',\n 'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;'),\n\n accident: NODE_MODE\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: NODE_MODE\n ? console.error.bind(console, `${styleScope}❌\\n%s\\x1b[31m.%s() Error \\`%s\\`${_style.reset}\\n`, domain)\n : console.error.bind(console, '%c%s%c.%s() Error `%s`\\n', styleScope, domain, _style.reset),\n };\n\n if (!devMode) {\n return requiredItems;\n }\n // else\n return {\n ...requiredItems,\n\n logProperty: console.debug.bind(console, _keySection + '.%s = %o;', styleScope, domain, _style.reset),\n\n logMethod: console.debug.bind(console, _keySection + '.%s();', styleScope, domain, _style.reset),\n\n logModule: console.debug.bind(console, _keySection + '/%s.js;', styleScope, domain, _style.reset),\n\n logMethodArgs: console.debug.bind(console, _keySection + '.%s(%o);', styleScope, domain, _style.reset),\n\n logMethodFull: console.debug.bind(console, _keySection + '.%s(%o) => %o', styleScope, domain, _style.reset),\n\n logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset),\n\n incident: NODE_MODE\n ? console.log.bind(console, `${styleScope}🚸\\n%s${_style.reset}.%s() Incident \\`%s\\`!${_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"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AAIhD;;GAEG;AACH,MAAM,SAAS,GAAG,SAAS;IACzB,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,EAA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E,CAAC,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,gBAAgB,CAAC;KAC5E,CAAC;AACb,CAAC,CAAC","sourcesContent":["import {DEV_MODE, NODE_MODE} from './global.js';\n\nimport type {AlwatrLogger} from './type.js';\n\n/**\n * Color list storage for logger.\n */\nconst colorList = NODE_MODE\n ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // red and white omitted\n : [\n '#35b997',\n '#f05561',\n '#ee224a',\n '#91c13e',\n '#22af4b',\n '#f0e995',\n '#0fe995',\n '#0f89ca',\n '#08b9a5',\n '#fee851',\n '#ee573d',\n '#f9df30',\n '#1da2dc',\n '#f05123',\n '#ee2524',\n ];\n\nlet _colorIndex = 0;\nconst _getNextColor = (): string => {\n const color = colorList[_colorIndex];\n _colorIndex++;\n if (_colorIndex >= colorList.length) {\n _colorIndex = 0;\n }\n return color;\n};\n\nconst _style = {\n scope: NODE_MODE ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: NODE_MODE ? '\\x1b[0m' : 'color: inherit;',\n};\n\nconst _keySection = NODE_MODE ? '%s%s%s' : '%c%s%c';\n\nconst _sanitizeDomain = (domain: string): string => {\n domain = domain.trim();\n const first = domain.charAt(0);\n if (first !== '[' && first !== '{' && first !== '<') {\n domain = '[' + domain + ']';\n }\n return domain;\n};\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - **color** is optional and automatically select from internal fancy color list.\n * - **debug** is optional and automatically detect from localStorage `ALWATR_DEBUG` item or `process.env.ALWATR_DEBUG`\n *\n * Example:\n *\n * ```ts\n * import {createLogger} from 'https://esm.run/@alwatr/logger';\n * const logger = createLogger('logger/demo');\n * ```\n */\nexport const createLogger = (domain: string, devMode = DEV_MODE): AlwatrLogger => {\n const color = _getNextColor();\n const styleScope = _style.scope.replaceAll('{{color}}', color);\n domain = _sanitizeDomain(domain);\n\n /**\n * Required logger object, accident, error always reported even when the devMode is false.\n */\n const requiredItems: AlwatrLogger = {\n devMode,\n domain,\n\n banner: NODE_MODE\n ? console.log.bind(console, `\\x1b[1;37;45m\\n\\n %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: NODE_MODE\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: NODE_MODE\n ? console.error.bind(console, `${styleScope}❌\\n%s\\x1b[31m.%s() Error \\`%s\\`${_style.reset}\\n`, domain)\n : console.error.bind(console, '%c%s%c.%s() Error `%s`\\n', styleScope, domain, _style.reset),\n };\n\n if (!devMode) {\n return requiredItems;\n }\n // else\n return {\n ...requiredItems,\n\n logProperty: console.debug.bind(console, _keySection + '.%s = %o;', styleScope, domain, _style.reset),\n\n logMethod: console.debug.bind(console, _keySection + '.%s();', styleScope, domain, _style.reset),\n\n logModule: console.debug.bind(console, _keySection + '/%s.js;', styleScope, domain, _style.reset),\n\n logMethodArgs: console.debug.bind(console, _keySection + '.%s(%o);', styleScope, domain, _style.reset),\n\n logMethodFull: console.debug.bind(console, _keySection + '.%s(%o) => %o', styleScope, domain, _style.reset),\n\n logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset),\n\n incident: NODE_MODE\n ? console.log.bind(console, `${styleScope}🚸\\n%s${_style.reset}.%s() Incident \\`%s\\`!${_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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwatr/logger",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.",
5
5
  "keywords": [
6
6
  "log",
@@ -31,11 +31,8 @@
31
31
  "bugs": {
32
32
  "url": "https://github.com/Alwatr/eslib/issues"
33
33
  },
34
- "dependencies": {
35
- "tslib": "^2.6.2"
36
- },
37
34
  "devDependencies": {
38
- "@types/node": "^20.9.0"
35
+ "@types/node": "^20.10.0"
39
36
  },
40
- "gitHead": "c9c6d5abf5e2aeafa915fde58c73e030ac00db27"
37
+ "gitHead": "27cb935580d5ccdc4459f1018c66f23ea0a42ddf"
41
38
  }
package/type.d.ts CHANGED
@@ -1,9 +1,3 @@
1
- export interface GlobalAlwatr {
2
- packages: Record<string, string>;
3
- }
4
- declare global {
5
- var Alwatr: GlobalAlwatr;
6
- }
7
1
  export interface AlwatrLogger {
8
2
  /**
9
3
  * Debug state for current scope base on localStorage `ALWATR_LOG` pattern.
package/type.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,MAAM,EAAE,YAAY,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;;;;;;;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,CA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package/type.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"","sourcesContent":["export interface GlobalAlwatr {\n packages: Record<string, string>;\n}\n\ndeclare global {\n // eslint-disable-next-line no-var\n var Alwatr: GlobalAlwatr;\n}\n\nexport interface AlwatrLogger {\n /**\n * Debug state for current scope base on localStorage `ALWATR_LOG` pattern.\n */\n readonly devMode: boolean;\n\n /**\n * Domain scope defined for this logger.\n */\n readonly domain: string;\n\n /**\n * `console.debug` property change.\n *\n * Example:\n *\n * ```ts\n * logger.logProperty?.('name', 'ali');\n * ```\n */\n logProperty?(property: string, value: unknown): void;\n\n /**\n * `console.debug` module name.\n *\n * Example:\n *\n * ```ts\n * logger.logModule?.('app');\n * ```\n */\n logModule?(name: string): void;\n\n /**\n * `console.debug` function or method calls.\n *\n * Example:\n *\n * ```ts\n * function myMethod () {\n * logger.logMethod?.('myMethod');\n * }\n * ```\n */\n logMethod?(method: string): void;\n\n /**\n * `console.debug` function or method calls with arguments.\n *\n * Example:\n *\n * ```ts\n * function myMethod (a: number, b: number) {\n * logger.logMethodArgs?.('myMethod', {a, b});\n * }\n * ```\n */\n logMethodArgs?(method: string, args: unknown): void;\n\n /**\n * `console.debug` function or method calls with arguments.\n *\n * Example:\n *\n * ```ts\n * function add (a: number, b: number): number {\n * const result = a + b;\n * logger.logMethodFull?.('add', {a, b}, result);\n * return result;\n * }\n * ```\n */\n logMethodFull?(method: string, args: unknown, result: unknown): void;\n\n /**\n * `console.log` an event or expected accident.\n * not warn or error just important information.\n *\n * Example:\n *\n * ```ts\n * logger.incident?.('fetch', 'abort_signal', {url: '/test.json'});\n * ```\n */\n incident?(method: string, code: string, ...args: unknown[]): void;\n\n /**\n * `console.warn` an unexpected accident or error that you handled like warning.\n *\n * Example:\n *\n * ```ts\n * logger.accident('fetch', 'file_not_found', {url: '/test.json'});\n * ```\n */\n accident(method: string, code: string, ...args: unknown[]): void;\n\n /**\n * `console.error` an unexpected error.\n *\n * Example:\n *\n * ```ts\n * try {\n * ...\n * }\n * catch (err) {\n * logger.error('myMethod', 'error_code', err, {a: 1, b: 2});\n * }\n * ```\n */\n error(method: string, code: string, ...args: unknown[]): void;\n\n /**\n * Simple `console.debug` with styled scope.\n *\n * Example:\n *\n * ```ts\n * logger.logOther?.('foo:', 'bar', {a: 1});\n * ```\n */\n logOther?(...args: unknown[]): void;\n\n /**\n * Simple `console.time` with scope.\n *\n * Example:\n *\n * ```ts\n * logger.time?.('foo');\n * ```\n */\n time?(label: string): void;\n\n /**\n * Simple `console.timeEnd` with scope.\n *\n * Example:\n *\n * ```ts\n * logger.timeEnd?.('foo');\n * ```\n */\n timeEnd?(label: string): void;\n\n /**\n * log big banner\n *\n * Example:\n *\n * ```ts\n * logger.banner('Alwatr PWA v2');\n * ```\n */\n banner(message: string): void;\n}\n"]}
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"","sourcesContent":["export interface AlwatrLogger {\n /**\n * Debug state for current scope base on localStorage `ALWATR_LOG` pattern.\n */\n readonly devMode: boolean;\n\n /**\n * Domain scope defined for this logger.\n */\n readonly domain: string;\n\n /**\n * `console.debug` property change.\n *\n * Example:\n *\n * ```ts\n * logger.logProperty?.('name', 'ali');\n * ```\n */\n logProperty?(property: string, value: unknown): void;\n\n /**\n * `console.debug` module name.\n *\n * Example:\n *\n * ```ts\n * logger.logModule?.('app');\n * ```\n */\n logModule?(name: string): void;\n\n /**\n * `console.debug` function or method calls.\n *\n * Example:\n *\n * ```ts\n * function myMethod () {\n * logger.logMethod?.('myMethod');\n * }\n * ```\n */\n logMethod?(method: string): void;\n\n /**\n * `console.debug` function or method calls with arguments.\n *\n * Example:\n *\n * ```ts\n * function myMethod (a: number, b: number) {\n * logger.logMethodArgs?.('myMethod', {a, b});\n * }\n * ```\n */\n logMethodArgs?(method: string, args: unknown): void;\n\n /**\n * `console.debug` function or method calls with arguments.\n *\n * Example:\n *\n * ```ts\n * function add (a: number, b: number): number {\n * const result = a + b;\n * logger.logMethodFull?.('add', {a, b}, result);\n * return result;\n * }\n * ```\n */\n logMethodFull?(method: string, args: unknown, result: unknown): void;\n\n /**\n * `console.log` an event or expected accident.\n * not warn or error just important information.\n *\n * Example:\n *\n * ```ts\n * logger.incident?.('fetch', 'abort_signal', {url: '/test.json'});\n * ```\n */\n incident?(method: string, code: string, ...args: unknown[]): void;\n\n /**\n * `console.warn` an unexpected accident or error that you handled like warning.\n *\n * Example:\n *\n * ```ts\n * logger.accident('fetch', 'file_not_found', {url: '/test.json'});\n * ```\n */\n accident(method: string, code: string, ...args: unknown[]): void;\n\n /**\n * `console.error` an unexpected error.\n *\n * Example:\n *\n * ```ts\n * try {\n * ...\n * }\n * catch (err) {\n * logger.error('myMethod', 'error_code', err, {a: 1, b: 2});\n * }\n * ```\n */\n error(method: string, code: string, ...args: unknown[]): void;\n\n /**\n * Simple `console.debug` with styled scope.\n *\n * Example:\n *\n * ```ts\n * logger.logOther?.('foo:', 'bar', {a: 1});\n * ```\n */\n logOther?(...args: unknown[]): void;\n\n /**\n * Simple `console.time` with scope.\n *\n * Example:\n *\n * ```ts\n * logger.time?.('foo');\n * ```\n */\n time?(label: string): void;\n\n /**\n * Simple `console.timeEnd` with scope.\n *\n * Example:\n *\n * ```ts\n * logger.timeEnd?.('foo');\n * ```\n */\n timeEnd?(label: string): void;\n\n /**\n * log big banner\n *\n * Example:\n *\n * ```ts\n * logger.banner('Alwatr PWA v2');\n * ```\n */\n banner(message: string): void;\n}\n"]}