@alwatr/logger 0.25.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
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
+ # [0.27.0](https://github.com/AliMD/alwatr/compare/v0.26.0...v0.27.0) (2022-12-29)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **logger:** version ([2295fee](https://github.com/AliMD/alwatr/commit/2295fee74e8eebd9db399129de31f2b0d6d6b168))
11
+
12
+ # [0.26.0](https://github.com/AliMD/alwatr/compare/v0.25.0...v0.26.0) (2022-12-22)
13
+
14
+ ### Bug Fixes
15
+
16
+ - set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9))
17
+ - tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35))
18
+
19
+ ### Features
20
+
21
+ - improve error debugging ([1fba504](https://github.com/AliMD/alwatr/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c))
22
+ - **logger:** add root version ([2ac01c1](https://github.com/AliMD/alwatr/commit/2ac01c1d12323a6c8591b3dd4826d08a55647dc1))
23
+ - **logger:** move incident to deployment mode ([4ee8dac](https://github.com/AliMD/alwatr/commit/4ee8dac5c54ce8a897382d3d4fb5bb852d24cf24))
24
+
6
25
  # [0.25.0](https://github.com/AliMD/alwatr/compare/v0.24.1...v0.25.0) (2022-12-07)
7
26
 
8
27
  ### Features
package/README.md CHANGED
@@ -148,7 +148,7 @@ try {
148
148
  ...
149
149
  }
150
150
  catch (err) {
151
- logger.error('myMethod', 'error_code', (err as Error).stack || err, {a: 1, b: 2});
151
+ logger.error('myMethod', 'error_code', err, {a: 1, b: 2});
152
152
  }
153
153
  ```
154
154
 
@@ -175,7 +175,7 @@ Best practices to catch the error and log it:
175
175
  ```ts
176
176
  // Unhandled promise rejection (just log it)
177
177
  failPromiseTest().catch((err) =>
178
- logger.error('myMethod', (err as Error).message || 'error_code', (err as Error).stack || err)
178
+ logger.error('myMethod', (err as Error).message || 'error_code', err)
179
179
  );
180
180
 
181
181
  // Handled promise rejection
@@ -186,7 +186,7 @@ try {
186
186
  'myMethod',
187
187
  'error_code',
188
188
  'failPromiseTest failed!, ' + (err as Error).message,
189
- (err as Error).stack || err
189
+ err
190
190
  );
191
191
  // do something to handle the error...
192
192
  }
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;AAC5C,OAAO,EAAC,YAAY,EAAC,CAAC;AAItB;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;GAA0C,CAAC;AA8E5E,eAAO,MAAM,KAAK;;;CAGjB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,UAAU,MAAM,GAAG,IAAI,UAAU,OAAO,KAAG,YA8DpF,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,CAAC;AAItB;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;GAA0C,CAAC;AA8E5E,eAAO,MAAM,KAAK;;;CAGjB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,UAAU,MAAM,GAAG,IAAI,UAAU,OAAO,KAAG,YA+DpF,CAAC"}
package/logger.js CHANGED
@@ -4,7 +4,7 @@ const isBrowser = typeof process === 'undefined';
4
4
  * Define `globalThis.Alwatr.registeredList`
5
5
  */
6
6
  export const alwatrRegisteredList = ((_a = globalThis.Alwatr) === null || _a === void 0 ? void 0 : _a.registeredList) || [];
7
- (_b = globalThis.Alwatr) !== null && _b !== void 0 ? _b : (globalThis.Alwatr = { registeredList: alwatrRegisteredList });
7
+ (_b = globalThis.Alwatr) !== null && _b !== void 0 ? _b : (globalThis.Alwatr = { version: '0.26.0', registeredList: alwatrRegisteredList });
8
8
  alwatrRegisteredList.push({
9
9
  name: '@alwatr/logger',
10
10
  version: '{{ALWATR_VERSION}}', // TODO: replace with real version at release time.
@@ -100,9 +100,6 @@ export const createLogger = (scope, color, debug) => {
100
100
  debug,
101
101
  color,
102
102
  scope,
103
- incident: isBrowser
104
- ? console.log.bind(console, '%c%s%c.%s() Incident `%s` %s!', styleScope, scope, 'color: orange;')
105
- : console.log.bind(console, `${styleScope}🚸\n%s${style.reset}.%s() Incident \`%s\` %s!${style.reset}`, scope),
106
103
  accident: isBrowser
107
104
  ? console.warn.bind(console, '%c%s%c.%s() Accident `%s` %s!', styleScope, scope, style.reset)
108
105
  : console.warn.bind(console, `${styleScope}⚠️\n%s\x1b[33m.%s() Accident \`%s\` %s!${style.reset}`, scope),
@@ -118,6 +115,7 @@ export const createLogger = (scope, color, debug) => {
118
115
  logMethodArgs: empty,
119
116
  logMethodFull: empty,
120
117
  logOther: empty,
118
+ incident: empty,
121
119
  };
122
120
  }
123
121
  // else if debug is true for this scope
@@ -128,6 +126,9 @@ export const createLogger = (scope, color, debug) => {
128
126
  logMethodArgs: console.debug.bind(console, keySection + '.%s(%o);', styleScope, scope, style.reset),
129
127
  logMethodFull: console.debug.bind(console, keySection + '.%s(%o) => %o', styleScope, scope, style.reset),
130
128
  logOther: console.debug.bind(console, keySection, styleScope, scope, style.reset),
129
+ incident: isBrowser
130
+ ? console.log.bind(console, '%c%s%c.%s() Incident `%s` %s!', styleScope, scope, 'color: orange;')
131
+ : console.log.bind(console, `${styleScope}🚸\n%s${style.reset}.%s() Incident \`%s\` %s!${style.reset}`, scope),
131
132
  };
132
133
  };
133
134
  //# sourceMappingURL=logger.js.map
package/logger.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":";AAGA,MAAM,SAAS,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAA,MAAA,UAAU,CAAC,MAAM,0CAAE,cAAc,KAAI,EAAE,CAAC;AAC5E,MAAA,UAAU,CAAC,MAAM,oCAAjB,UAAU,CAAC,MAAM,GAAK,EAAC,cAAc,EAAE,oBAAoB,EAAC,EAAC;AAE7D,oBAAoB,CAAC,IAAI,CAAC;IACxB,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,oBAAoB,EAAE,mDAAmD;CACnF,CAAC,CAAC;AAEH;;GAEG;AACH,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,MAAM,SAAS,GAAG,SAAS;IACzB,CAAC,CAAC;QACA,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,wBAAwB;AAEtE,MAAM,YAAY,GAAG,GAAW,EAAE;IAChC,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IACpC,UAAU,EAAE,CAAC;IACb,IAAI,UAAU,IAAI,SAAS,CAAC,MAAM,EAAE;QAClC,UAAU,GAAG,CAAC,CAAC;KAChB;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,SAAS;IAC3B,CAAC,CAAC,MAAA,MAAA,UAAU,CAAC,YAAY,0CAAE,OAAO,CAAC,cAAc,CAAC,0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AExG,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;KAClF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type {AlwatrLogger} from './type.js';\nexport {AlwatrLogger};\n\nconst isBrowser = typeof process === 'undefined';\n\n/**\n * Define `globalThis.Alwatr.registeredList`\n */\nexport const alwatrRegisteredList = globalThis.Alwatr?.registeredList || [];\nglobalThis.Alwatr ??= {registeredList: alwatrRegisteredList};\n\nalwatrRegisteredList.push({\n name: '@alwatr/logger',\n version: '{{ALWATR_VERSION}}', // TODO: replace with real version at release time.\n});\n\n/**\n * Color list storage for logger.\n */\nlet colorIndex = 0;\nconst colorList = isBrowser\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 : ['0;36', '0;35', '0;34', '0;33', '0;32']; // red and white omitted\n\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 debugString = isBrowser\n ? globalThis.localStorage?.getItem('ALWATR_DEBUG')?.trim()\n : process?.env?.ALWATR_DEBUG?.trim();\n\nconst getDebugState = (scope: string): boolean => {\n if (debugString == null && isBrowser === false && process.env.NODE_ENV !== 'production') {\n return true;\n }\n\n // prettier-ignore\n if (\n debugString == null ||\n debugString == ''\n ) {\n return false;\n }\n\n // prettier-ignore\n if (\n debugString === scope ||\n debugString === '*' ||\n (\n debugString.indexOf('*') === 0 && // starts with `*` for example: `*alwatr*`\n scope.indexOf(debugString.replaceAll('*', '')) !== -1\n ) ||\n (\n debugString.indexOf('*') === debugString.length - 1 && // ends with `*` for example: `alwatr/*`\n scope.indexOf(debugString.replaceAll('*', '')) === 0\n )\n ) {\n return true;\n }\n\n // else\n return false;\n};\n\nexport const style = {\n scope: isBrowser ? 'color: {{color}};' : '\\x1b[{{color}}m',\n reset: isBrowser ? 'color: inherit;' : '\\x1b[0m',\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 = (scope: string, color?: string | null, debug?: boolean): AlwatrLogger => {\n scope = scope.trim();\n color ??= getNextColor();\n debug ??= getDebugState(scope);\n\n const first = scope.charAt(0);\n if (first !== '[' && first !== '{' && first !== '(' && first !== '<') {\n scope = '[' + scope + ']';\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const empty = (): void => {};\n\n const keySection = isBrowser ? '%c%s%c' : '%s%s%s';\n const styleScope = style.scope.replaceAll('{{color}}', color);\n\n /**\n * Required logger object, accident, error always reported even when the debug is false.\n */\n const requiredItems = {\n debug,\n color,\n scope,\n\n incident: isBrowser\n ? console.log.bind(console, '%c%s%c.%s() Incident `%s` %s!', styleScope, scope, 'color: orange;')\n : console.log.bind(console, `${styleScope}🚸\\n%s${style.reset}.%s() Incident \\`%s\\` %s!${style.reset}`, scope),\n\n accident: isBrowser\n ? console.warn.bind(console, '%c%s%c.%s() Accident `%s` %s!', styleScope, scope, style.reset)\n : console.warn.bind(console, `${styleScope}⚠️\\n%s\\x1b[33m.%s() Accident \\`%s\\` %s!${style.reset}`, scope),\n\n error: isBrowser\n ? console.error.bind(console, '%c%s%c.%s() Error `%s`\\n', styleScope, scope, style.reset)\n : console.error.bind(console, `${styleScope}❌\\n%s\\x1b[31m.%s() Error \\`%s\\`${style.reset}\\n`, scope),\n };\n\n if (!debug) {\n return {\n ...requiredItems,\n logProperty: empty,\n logMethod: empty,\n logMethodArgs: empty,\n logMethodFull: empty,\n logOther: empty,\n };\n }\n\n // else if debug is true for this scope\n return {\n ...requiredItems,\n\n logProperty: console.debug.bind(console, keySection + '.%s = %o;', styleScope, scope, style.reset),\n\n logMethod: console.debug.bind(console, keySection + '.%s();', styleScope, scope, style.reset),\n\n logMethodArgs: console.debug.bind(console, keySection + '.%s(%o);', styleScope, scope, style.reset),\n\n logMethodFull: console.debug.bind(console, keySection + '.%s(%o) => %o', styleScope, scope, style.reset),\n\n logOther: console.debug.bind(console, keySection, styleScope, scope, style.reset),\n };\n};\n"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["src/logger.ts"],"names":[],"mappings":";AAGA,MAAM,SAAS,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAA,MAAA,UAAU,CAAC,MAAM,0CAAE,cAAc,KAAI,EAAE,CAAC;AAC5E,MAAA,UAAU,CAAC,MAAM,oCAAjB,UAAU,CAAC,MAAM,GAAK,EAAC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,oBAAoB,EAAC,EAAC;AAEhF,oBAAoB,CAAC,IAAI,CAAC;IACxB,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,oBAAoB,EAAE,mDAAmD;CACnF,CAAC,CAAC;AAEH;;GAEG;AACH,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,MAAM,SAAS,GAAG,SAAS;IACzB,CAAC,CAAC;QACA,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,wBAAwB;AAEtE,MAA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AG,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;QAExG,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;QAEjF,QAAQ,EAAE,SAAS;YACjB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,+BAA+B,EAAE,UAAU,EAAE,KAAK,EAAE,gBAAgB,CAAC;YACjG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,UAAU,SAAS,KAAK,CAAC,KAAK,4BAA4B,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC;KACjH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type {AlwatrLogger} from './type.js';\nexport {AlwatrLogger};\n\nconst isBrowser = typeof process === 'undefined';\n\n/**\n * Define `globalThis.Alwatr.registeredList`\n */\nexport const alwatrRegisteredList = globalThis.Alwatr?.registeredList || [];\nglobalThis.Alwatr ??= {version: '0.26.0', registeredList: alwatrRegisteredList};\n\nalwatrRegisteredList.push({\n name: '@alwatr/logger',\n version: '{{ALWATR_VERSION}}', // TODO: replace with real version at release time.\n});\n\n/**\n * Color list storage for logger.\n */\nlet colorIndex = 0;\nconst colorList = isBrowser\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 : ['0;36', '0;35', '0;34', '0;33', '0;32']; // red and white omitted\n\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 debugString = isBrowser\n ? globalThis.localStorage?.getItem('ALWATR_DEBUG')?.trim()\n : process?.env?.ALWATR_DEBUG?.trim();\n\nconst getDebugState = (scope: string): boolean => {\n if (debugString == null && isBrowser === false && process.env.NODE_ENV !== 'production') {\n return true;\n }\n\n // prettier-ignore\n if (\n debugString == null ||\n debugString == ''\n ) {\n return false;\n }\n\n // prettier-ignore\n if (\n debugString === scope ||\n debugString === '*' ||\n (\n debugString.indexOf('*') === 0 && // starts with `*` for example: `*alwatr*`\n scope.indexOf(debugString.replaceAll('*', '')) !== -1\n ) ||\n (\n debugString.indexOf('*') === debugString.length - 1 && // ends with `*` for example: `alwatr/*`\n scope.indexOf(debugString.replaceAll('*', '')) === 0\n )\n ) {\n return true;\n }\n\n // else\n return false;\n};\n\nexport const style = {\n scope: isBrowser ? 'color: {{color}};' : '\\x1b[{{color}}m',\n reset: isBrowser ? 'color: inherit;' : '\\x1b[0m',\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 = (scope: string, color?: string | null, debug?: boolean): AlwatrLogger => {\n scope = scope.trim();\n color ??= getNextColor();\n debug ??= getDebugState(scope);\n\n const first = scope.charAt(0);\n if (first !== '[' && first !== '{' && first !== '(' && first !== '<') {\n scope = '[' + scope + ']';\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const empty = (): void => {};\n\n const keySection = isBrowser ? '%c%s%c' : '%s%s%s';\n const styleScope = style.scope.replaceAll('{{color}}', color);\n\n /**\n * Required logger object, accident, error always reported even when the debug is false.\n */\n const requiredItems = {\n debug,\n color,\n scope,\n\n accident: isBrowser\n ? console.warn.bind(console, '%c%s%c.%s() Accident `%s` %s!', styleScope, scope, style.reset)\n : console.warn.bind(console, `${styleScope}⚠️\\n%s\\x1b[33m.%s() Accident \\`%s\\` %s!${style.reset}`, scope),\n\n error: isBrowser\n ? console.error.bind(console, '%c%s%c.%s() Error `%s`\\n', styleScope, scope, style.reset)\n : console.error.bind(console, `${styleScope}❌\\n%s\\x1b[31m.%s() Error \\`%s\\`${style.reset}\\n`, scope),\n };\n\n if (!debug) {\n return {\n ...requiredItems,\n logProperty: empty,\n logMethod: empty,\n logMethodArgs: empty,\n logMethodFull: empty,\n logOther: empty,\n incident: empty,\n };\n }\n\n // else if debug is true for this scope\n return {\n ...requiredItems,\n\n logProperty: console.debug.bind(console, keySection + '.%s = %o;', styleScope, scope, style.reset),\n\n logMethod: console.debug.bind(console, keySection + '.%s();', styleScope, scope, style.reset),\n\n logMethodArgs: console.debug.bind(console, keySection + '.%s(%o);', styleScope, scope, style.reset),\n\n logMethodFull: console.debug.bind(console, keySection + '.%s(%o) => %o', styleScope, scope, style.reset),\n\n logOther: console.debug.bind(console, keySection, styleScope, scope, style.reset),\n\n incident: isBrowser\n ? console.log.bind(console, '%c%s%c.%s() Incident `%s` %s!', styleScope, scope, 'color: orange;')\n : console.log.bind(console, `${styleScope}🚸\\n%s${style.reset}.%s() Incident \\`%s\\` %s!${style.reset}`, scope),\n };\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwatr/logger",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "description": "Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.",
5
5
  "keywords": [
6
6
  "log",
@@ -25,14 +25,14 @@
25
25
  "repository": {
26
26
  "type": "git",
27
27
  "url": "https://github.com/AliMD/alwatr",
28
- "directory": "packages/core/logger"
28
+ "directory": "core/logger"
29
29
  },
30
- "homepage": "https://github.com/AliMD/alwatr/tree/main/packages/core/logger#readme",
30
+ "homepage": "https://github.com/AliMD/alwatr/tree/main/core/logger#readme",
31
31
  "bugs": {
32
32
  "url": "https://github.com/AliMD/alwatr/issues"
33
33
  },
34
34
  "dependencies": {
35
35
  "tslib": "~2.4.1"
36
36
  },
37
- "gitHead": "03cf3c146f075309527bcf1e762a589696d0ce1d"
37
+ "gitHead": "f6612d969fe49af71ab27e75fa54601071953141"
38
38
  }
package/type.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export interface GlobalAlwatr {
2
+ version: string;
2
3
  registeredList: Array<{
3
4
  name: string;
4
5
  version: string;
@@ -76,7 +77,8 @@ export interface AlwatrLogger {
76
77
  */
77
78
  logMethodFull(method: string, args: Record<string, unknown> | string | number | boolean, result: unknown): void;
78
79
  /**
79
- * `console.log` an event or expected accident. (not warn or error)
80
+ * `console.log` an event or expected accident.
81
+ * not warn or error just important information.
80
82
  *
81
83
  * Example:
82
84
  *
@@ -86,7 +88,7 @@ export interface AlwatrLogger {
86
88
  */
87
89
  incident(method: string, code: string, desc: string, ...args: unknown[]): void;
88
90
  /**
89
- * `console.warn` an unexpected accident or error that you handled.
91
+ * `console.warn` an unexpected accident or error that you handled like warning.
90
92
  *
91
93
  * Example:
92
94
  *
@@ -105,11 +107,11 @@ export interface AlwatrLogger {
105
107
  * ...
106
108
  * }
107
109
  * catch (err) {
108
- * logger.error('myMethod', 'error_code', (err as Error).stack || err, {a: 1, b: 2});
110
+ * logger.error('myMethod', 'error_code', err, {a: 1, b: 2});
109
111
  * }
110
112
  * ```
111
113
  */
112
- error(method: string, code: string, errorStack: string | unknown, ...args: unknown[]): void;
114
+ error(method: string, code: string, ...args: unknown[]): void;
113
115
  /**
114
116
  * Simple `console.debug` with styled scope.
115
117
  *
package/type.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,KAAK,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ;AAED,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,MAAM,EAA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AE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE/E;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE/E;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE9D;;;;;;;;OAQG;IACH,QAAQ,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CACpC"}
package/type.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable no-var */\nexport interface GlobalAlwatr {\n registeredList: Array<{\n name: string;\n version: string;\n }>;\n}\n\ndeclare global {\n var Alwatr: GlobalAlwatr;\n var ALWATR_DEBUG: string | undefined;\n\n /**\n * @TODO: Make an issue to TS, WTF is this way! any better solution for more args in bind?!\n */\n interface CallableFunction {\n bind<T, A0, A1, A2, A3, A4, A extends unknown[], R>(\n this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, arg4: A4, ...args: A) => R,\n thisArg: T,\n arg0: A0,\n arg1: A1,\n arg2: A2,\n arg3: A3,\n arg4: A4\n ): (...args: A) => R;\n }\n}\n\nexport interface AlwatrLogger {\n /**\n * Debug state for current scope base on localStorage `ALWATR_LOG` pattern.\n */\n readonly debug: boolean;\n\n /**\n * Color picked for current scope.\n */\n readonly color: string;\n\n /**\n * Scope defined for this logger.\n */\n readonly scope: 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` 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: Record<string, unknown> | string | number | boolean): 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: Record<string, unknown> | string | number | boolean, result: unknown): void;\n\n /**\n * `console.log` an event or expected accident. (not warn or error)\n *\n * Example:\n *\n * ```ts\n * logger.incident('fetch', 'abort_signal', 'aborted signal received', {url: '/test.json'});\n * ```\n */\n incident(method: string, code: string, desc: string, ...args: unknown[]): void;\n\n /**\n * `console.warn` an unexpected accident or error that you handled.\n *\n * Example:\n *\n * ```ts\n * logger.accident('fetch', 'file_not_found', 'url requested return 404 not found', {url: '/test.json'});\n * ```\n */\n accident(method: string, code: string, desc: 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 as Error).stack || err, {a: 1, b: 2});\n * }\n * ```\n */\n error(method: string, code: string, errorStack: string | unknown, ...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"]}
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable no-var */\nexport interface GlobalAlwatr {\n version: string;\n registeredList: Array<{\n name: string;\n version: string;\n }>;\n}\n\ndeclare global {\n var Alwatr: GlobalAlwatr;\n var ALWATR_DEBUG: string | undefined;\n\n /**\n * @TODO: Make an issue to TS, WTF is this way! any better solution for more args in bind?!\n */\n interface CallableFunction {\n bind<T, A0, A1, A2, A3, A4, A extends unknown[], R>(\n this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, arg4: A4, ...args: A) => R,\n thisArg: T,\n arg0: A0,\n arg1: A1,\n arg2: A2,\n arg3: A3,\n arg4: A4\n ): (...args: A) => R;\n }\n}\n\nexport interface AlwatrLogger {\n /**\n * Debug state for current scope base on localStorage `ALWATR_LOG` pattern.\n */\n readonly debug: boolean;\n\n /**\n * Color picked for current scope.\n */\n readonly color: string;\n\n /**\n * Scope defined for this logger.\n */\n readonly scope: 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` 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: Record<string, unknown> | string | number | boolean): 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: Record<string, unknown> | string | number | boolean, 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', 'aborted signal received', {url: '/test.json'});\n * ```\n */\n incident(method: string, code: string, desc: 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 requested return 404 not found', {url: '/test.json'});\n * ```\n */\n accident(method: string, code: string, desc: 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"]}