nightingale 14.1.0 → 14.2.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
@@ -1,8 +1,30 @@
1
- # Change Log
1
+ # Changelog
2
2
 
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
+ ## [14.2.1](https://github.com/christophehurpeau/nightingale/compare/v14.2.0...v14.2.1) (2023-11-05)
7
+
8
+ Note: no notable changes
9
+
10
+ Version bump for dependency: nightingale-levels
11
+ Version bump for dependency: nightingale-logger
12
+ Version bump for dependency: nightingale-types
13
+ Version bump for dependency: nightingale-string
14
+
15
+
16
+ ## [14.2.0](https://github.com/christophehurpeau/nightingale/compare/v14.1.0...v14.2.0) (2023-11-04)
17
+
18
+
19
+ ### Features
20
+
21
+ * **nightingale:** improve unhandled error display ([a56473e](https://github.com/christophehurpeau/nightingale/commit/a56473e2eb09267c19f12ba7a3d89bccec21d3c5))
22
+ Version bump for dependency: nightingale-levels
23
+ Version bump for dependency: nightingale-logger
24
+ Version bump for dependency: nightingale-types
25
+ Version bump for dependency: nightingale-string
26
+
27
+
6
28
  ## [14.1.0](https://github.com/christophehurpeau/nightingale/compare/v14.0.2...v14.1.0) (2023-07-27)
7
29
 
8
30
  **Note:** Version bump only for package nightingale
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,MAGP,GACA,IAAI,CAON"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,MAGP,GACA,IAAI,CAaN"}
@@ -113,15 +113,15 @@ function listenUnhandledErrors(logger) {
113
113
  logger = new Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors');
114
114
  }
115
115
  process.on('uncaughtException', function (error) {
116
- logger.error('uncaughtException', {
117
- error: error,
118
- unhandled: true
116
+ logger.error(error, {
117
+ unhandled: true,
118
+ type: 'uncaughtException'
119
119
  });
120
120
  });
121
121
  process.on('unhandledRejection', function (error) {
122
- logger.error('unhandledRejection', {
123
- error: error,
124
- unhandled: true
122
+ logger.error(error, {
123
+ unhandled: true,
124
+ type: 'unhandledRejection'
125
125
  });
126
126
  });
127
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index-browser.es.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler, Level } from 'nightingale-types';\n\nconst globalOrWindow: typeof global =\n typeof global !== 'undefined' ? global : (window as typeof global);\n\nif (\n process.env.NODE_ENV !== 'production' &&\n globalOrWindow.__NIGHTINGALE_GLOBAL_HANDLERS\n) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!globalOrWindow.__NIGHTINGALE_CONFIG) {\n globalOrWindow.__NIGHTINGALE_CONFIG = [];\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n globalOrWindow.__NIGHTINGALE_CONFIG_DEFAULT = {\n handlers: [],\n processors: [],\n };\n}\n\nfunction clearCache(): void {\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE.clear();\n}\n\nfunction handleConfig(config: Config): Config {\n if (config.keys) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n if (config.key) {\n throw new Error('Cannot have key and keys for the same config');\n }\n } else if (config.key) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n config.keys = [config.key];\n delete config.key;\n }\n\n if (config.handler) {\n if (config.handlers) {\n throw new Error('Cannot have handler and handlers for the same config');\n }\n config.handlers = [config.handler];\n delete config.handler;\n }\n\n if (config.processor) {\n if (config.processors) {\n throw new Error(\n 'Cannot have processors and processors for the same config',\n );\n }\n config.processors = [config.processor];\n delete config.processor;\n }\n\n return config;\n}\n\nexport function configure(config: Config[]): void {\n if (globalOrWindow.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n globalOrWindow.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n globalOrWindow.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);\n clearCache();\n}\n\nconst configIsForKey = (key: string) => (config: Config) => {\n if (config.keys) return config.keys.includes(key);\n if (config.pattern) return config.pattern.test(key);\n return true;\n};\n\nglobalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE;\n\n const existingCache = globalCache.get(key);\n\n if (existingCache) {\n return existingCache;\n }\n\n const loggerConfig: ComputedConfigForKey = {\n handlers: [],\n processors: [],\n };\n\n globalOrWindow.__NIGHTINGALE_CONFIG\n .filter(configIsForKey(key))\n .some((config: Config) => {\n if (config.handlers) loggerConfig.handlers.push(...config.handlers);\n if (config.processors) loggerConfig.processors.push(...config.processors);\n return config.stop;\n });\n\n globalCache.set(key, loggerConfig);\n return loggerConfig;\n};\n\nif (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: Level,\n ): ComputedConfigForKey => {\n const { handlers, processors }: ComputedConfigForKey =\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key);\n\n return {\n handlers: handlers.filter(\n (handler: Handler) =>\n level >= handler.minLevel &&\n (!handler.isHandling || handler.isHandling(level, key)),\n ),\n processors,\n };\n };\n}\n","import { Logger } from 'nightingale-logger';\n\nexport { Logger } from 'nightingale-logger';\nexport { Level, Level as levels } from 'nightingale-levels';\nexport { configure, addConfig } from './config';\n\n/**\n * listen to uncaughtException and unhandledRejection\n * @param {Logger} [logger]\n */\nexport function listenUnhandledErrors(\n logger: Logger = new Logger(\n 'nightingale:listenUnhandledErrors',\n 'UnhandledErrors',\n ),\n): void {\n process.on('uncaughtException', (error) => {\n logger.error('uncaughtException', { error, unhandled: true });\n });\n process.on('unhandledRejection', (error) => {\n logger.error('unhandledRejection', { error, unhandled: true });\n });\n}\n"],"names":["globalOrWindow","global","window","process","env","NODE_ENV","__NIGHTINGALE_GLOBAL_HANDLERS","Error","__NIGHTINGALE_CONFIG","__NIGHTINGALE_LOGGER_MAP_CACHE","Map","__NIGHTINGALE_CONFIG_DEFAULT","handlers","processors","clearCache","clear","handleConfig","config","keys","pattern","key","handler","processor","configure","length","console","log","map","addConfig","unshift","configIsForKey","includes","test","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER","globalCache","existingCache","get","loggerConfig","filter","some","_loggerConfig$handler","_loggerConfig$process","push","apply","stop","set","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD","level","_globalOrWindow$__NIG","minLevel","isHandling","listenUnhandledErrors","logger","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AC/D,GAAC,CAAC,CAAA;AACFrD,EAAAA,OAAO,CAACmD,EAAE,CAAC,oBAAoB,EAAE,UAACC,KAAK,EAAK;AAC1CH,IAAAA,MAAM,CAACG,KAAK,CAAC,oBAAoB,EAAE;AAAEA,MAAAA,KAAK,EAALA,KAAK;AAAEC,MAAAA,SAAS,EAAE,IAAA;AAAK,KAAC,CAAC,CAAA;AAChE,GAAC,CAAC,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"index-browser.es.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler, Level } from 'nightingale-types';\n\nconst globalOrWindow: typeof global =\n typeof global !== 'undefined' ? global : (window as typeof global);\n\nif (\n process.env.NODE_ENV !== 'production' &&\n globalOrWindow.__NIGHTINGALE_GLOBAL_HANDLERS\n) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!globalOrWindow.__NIGHTINGALE_CONFIG) {\n globalOrWindow.__NIGHTINGALE_CONFIG = [];\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n globalOrWindow.__NIGHTINGALE_CONFIG_DEFAULT = {\n handlers: [],\n processors: [],\n };\n}\n\nfunction clearCache(): void {\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE.clear();\n}\n\nfunction handleConfig(config: Config): Config {\n if (config.keys) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n if (config.key) {\n throw new Error('Cannot have key and keys for the same config');\n }\n } else if (config.key) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n config.keys = [config.key];\n delete config.key;\n }\n\n if (config.handler) {\n if (config.handlers) {\n throw new Error('Cannot have handler and handlers for the same config');\n }\n config.handlers = [config.handler];\n delete config.handler;\n }\n\n if (config.processor) {\n if (config.processors) {\n throw new Error(\n 'Cannot have processors and processors for the same config',\n );\n }\n config.processors = [config.processor];\n delete config.processor;\n }\n\n return config;\n}\n\nexport function configure(config: Config[]): void {\n if (globalOrWindow.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n globalOrWindow.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n globalOrWindow.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);\n clearCache();\n}\n\nconst configIsForKey = (key: string) => (config: Config) => {\n if (config.keys) return config.keys.includes(key);\n if (config.pattern) return config.pattern.test(key);\n return true;\n};\n\nglobalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE;\n\n const existingCache = globalCache.get(key);\n\n if (existingCache) {\n return existingCache;\n }\n\n const loggerConfig: ComputedConfigForKey = {\n handlers: [],\n processors: [],\n };\n\n globalOrWindow.__NIGHTINGALE_CONFIG\n .filter(configIsForKey(key))\n .some((config: Config) => {\n if (config.handlers) loggerConfig.handlers.push(...config.handlers);\n if (config.processors) loggerConfig.processors.push(...config.processors);\n return config.stop;\n });\n\n globalCache.set(key, loggerConfig);\n return loggerConfig;\n};\n\nif (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: Level,\n ): ComputedConfigForKey => {\n const { handlers, processors }: ComputedConfigForKey =\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key);\n\n return {\n handlers: handlers.filter(\n (handler: Handler) =>\n level >= handler.minLevel &&\n (!handler.isHandling || handler.isHandling(level, key)),\n ),\n processors,\n };\n };\n}\n","import { Logger } from 'nightingale-logger';\n\nexport { Logger } from 'nightingale-logger';\nexport { Level, Level as levels } from 'nightingale-levels';\nexport { configure, addConfig } from './config';\n\n/**\n * listen to uncaughtException and unhandledRejection\n * @param {Logger} [logger]\n */\nexport function listenUnhandledErrors(\n logger: Logger = new Logger(\n 'nightingale:listenUnhandledErrors',\n 'UnhandledErrors',\n ),\n): void {\n process.on('uncaughtException', (error) => {\n logger.error(error, {\n unhandled: true,\n type: 'uncaughtException',\n });\n });\n process.on('unhandledRejection', (error) => {\n logger.error(error as Error, {\n unhandled: true,\n type: 'unhandledRejection',\n });\n });\n}\n"],"names":["globalOrWindow","global","window","process","env","NODE_ENV","__NIGHTINGALE_GLOBAL_HANDLERS","Error","__NIGHTINGALE_CONFIG","__NIGHTINGALE_LOGGER_MAP_CACHE","Map","__NIGHTINGALE_CONFIG_DEFAULT","handlers","processors","clearCache","clear","handleConfig","config","keys","pattern","key","handler","processor","configure","length","console","log","map","addConfig","unshift","configIsForKey","includes","test","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER","globalCache","existingCache","get","loggerConfig","filter","some","_loggerConfig$handler","_loggerConfig$process","push","apply","stop","set","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD","level","_globalOrWindow$__NIG","minLevel","isHandling","listenUnhandledErrors","logger","Logger","on","error","unhandled","type"],"mappings":";;;;AAGA,IAAMA,cAA6B,GACjC,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAIC,MAAwB,CAAA;AAEpE,IACEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IACrCL,cAAc,CAACM,6BAA6B,EAC5C;AACA,EAAA,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC,CAAA;AACtD,CAAA;AAEA,IAAI,CAACP,cAAc,CAACQ,oBAAoB,EAAE;EACxCR,cAAc,CAACQ,oBAAoB,GAAG,EAAE,CAAA;AACxCR,EAAAA,cAAc,CAACS,8BAA8B,GAAG,IAAIC,GAAG,EAGpD,CAAA;EACHV,cAAc,CAACW,4BAA4B,GAAG;AAC5CC,IAAAA,QAAQ,EAAE,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ACLD,MAAAA,QAAQ,EAAEA,QAAQ,CAAC0B,MAAM,CACvB,UAACjB,OAAgB,EAAA;AAAA,QAAA,OACf0B,KAAK,IAAI1B,OAAO,CAAC4B,QAAQ,KACxB,CAAC5B,OAAO,CAAC6B,UAAU,IAAI7B,OAAO,CAAC6B,UAAU,CAACH,KAAK,EAAE3B,GAAG,CAAC,CAAC,CAAA;AAAA,OAC3D,CAAC;AACDP,MAAAA,UAAU,EAAVA,UAAAA;KACD,CAAA;GACF,CAAA;AACH;;AC/HA;AACA;AACA;AACA;AACO,SAASsC,qBAAqBA,CACnCC,MAAc,EAIR;AAAA,EAAA,IAJNA,MAAc,KAAA,KAAA,CAAA,EAAA;AAAdA,IAAAA,MAAc,GAAG,IAAIC,MAAM,CACzB,mCAAmC,EACnC,iBACF,CAAC,CAAA;AAAA,GAAA;AAEDlD,EAAAA,OAAO,CAACmD,EAAE,CAAC,mBAAmB,EAAE,UAACC,KAAK,EAAK;AACzCH,IAAAA,MAAM,CAACG,KAAK,CAACA,KAAK,EAAE;AAClBC,MAAAA,SAAS,EAAE,IAAI;AACfC,MAAAA,IAAI,EAAE,mBAAA;AACR,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AACFtD,EAAAA,OAAO,CAACmD,EAAE,CAAC,oBAAoB,EAAE,UAACC,KAAK,EAAK;AAC1CH,IAAAA,MAAM,CAACG,KAAK,CAACA,KAAK,EAAW;AAC3BC,MAAAA,SAAS,EAAE,IAAI;AACfC,MAAAA,IAAI,EAAE,oBAAA;AACR,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AACJ;;;;"}
@@ -103,15 +103,15 @@ if (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
103
103
  */
104
104
  function listenUnhandledErrors(logger = new Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors')) {
105
105
  process.on('uncaughtException', error => {
106
- logger.error('uncaughtException', {
107
- error,
108
- unhandled: true
106
+ logger.error(error, {
107
+ unhandled: true,
108
+ type: 'uncaughtException'
109
109
  });
110
110
  });
111
111
  process.on('unhandledRejection', error => {
112
- logger.error('unhandledRejection', {
113
- error,
114
- unhandled: true
112
+ logger.error(error, {
113
+ unhandled: true,
114
+ type: 'unhandledRejection'
115
115
  });
116
116
  });
117
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index-browsermodern.es.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler, Level } from 'nightingale-types';\n\nconst globalOrWindow: typeof global =\n typeof global !== 'undefined' ? global : (window as typeof global);\n\nif (\n process.env.NODE_ENV !== 'production' &&\n globalOrWindow.__NIGHTINGALE_GLOBAL_HANDLERS\n) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!globalOrWindow.__NIGHTINGALE_CONFIG) {\n globalOrWindow.__NIGHTINGALE_CONFIG = [];\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n globalOrWindow.__NIGHTINGALE_CONFIG_DEFAULT = {\n handlers: [],\n processors: [],\n };\n}\n\nfunction clearCache(): void {\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE.clear();\n}\n\nfunction handleConfig(config: Config): Config {\n if (config.keys) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n if (config.key) {\n throw new Error('Cannot have key and keys for the same config');\n }\n } else if (config.key) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n config.keys = [config.key];\n delete config.key;\n }\n\n if (config.handler) {\n if (config.handlers) {\n throw new Error('Cannot have handler and handlers for the same config');\n }\n config.handlers = [config.handler];\n delete config.handler;\n }\n\n if (config.processor) {\n if (config.processors) {\n throw new Error(\n 'Cannot have processors and processors for the same config',\n );\n }\n config.processors = [config.processor];\n delete config.processor;\n }\n\n return config;\n}\n\nexport function configure(config: Config[]): void {\n if (globalOrWindow.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n globalOrWindow.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n globalOrWindow.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);\n clearCache();\n}\n\nconst configIsForKey = (key: string) => (config: Config) => {\n if (config.keys) return config.keys.includes(key);\n if (config.pattern) return config.pattern.test(key);\n return true;\n};\n\nglobalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE;\n\n const existingCache = globalCache.get(key);\n\n if (existingCache) {\n return existingCache;\n }\n\n const loggerConfig: ComputedConfigForKey = {\n handlers: [],\n processors: [],\n };\n\n globalOrWindow.__NIGHTINGALE_CONFIG\n .filter(configIsForKey(key))\n .some((config: Config) => {\n if (config.handlers) loggerConfig.handlers.push(...config.handlers);\n if (config.processors) loggerConfig.processors.push(...config.processors);\n return config.stop;\n });\n\n globalCache.set(key, loggerConfig);\n return loggerConfig;\n};\n\nif (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: Level,\n ): ComputedConfigForKey => {\n const { handlers, processors }: ComputedConfigForKey =\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key);\n\n return {\n handlers: handlers.filter(\n (handler: Handler) =>\n level >= handler.minLevel &&\n (!handler.isHandling || handler.isHandling(level, key)),\n ),\n processors,\n };\n };\n}\n","import { Logger } from 'nightingale-logger';\n\nexport { Logger } from 'nightingale-logger';\nexport { Level, Level as levels } from 'nightingale-levels';\nexport { configure, addConfig } from './config';\n\n/**\n * listen to uncaughtException and unhandledRejection\n * @param {Logger} [logger]\n */\nexport function listenUnhandledErrors(\n logger: Logger = new Logger(\n 'nightingale:listenUnhandledErrors',\n 'UnhandledErrors',\n ),\n): void {\n process.on('uncaughtException', (error) => {\n logger.error('uncaughtException', { error, unhandled: true });\n });\n process.on('unhandledRejection', (error) => {\n logger.error('unhandledRejection', { error, unhandled: true });\n });\n}\n"],"names":["globalOrWindow","global","window","process","env","NODE_ENV","__NIGHTINGALE_GLOBAL_HANDLERS","Error","__NIGHTINGALE_CONFIG","__NIGHTINGALE_LOGGER_MAP_CACHE","Map","__NIGHTINGALE_CONFIG_DEFAULT","handlers","processors","clearCache","clear","handleConfig","config","keys","pattern","key","handler","processor","configure","length","console","log","map","addConfig","unshift","configIsForKey","includes","test","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER","globalCache","existingCache","get","loggerConfig","filter","some","push","stop","set","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD","level","minLevel","isHandling","listenUnhandledErrors","logger","Logger","on","error","unhandled"],"mappings":";;;;AAGA,MAAMA,cAA6B,GACjC,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAIC,MAAwB,CAAA;AAEpE,IACEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IACrCL,cAAc,CAACM,6BAA6B,EAC5C;AACA,EAAA,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC,CAAA;AACtD,CAAA;AAEA,IAAI,CAACP,cAAc,CAACQ,oBAAoB,EAAE;EACxCR,cAAc,CAACQ,oBAAoB,GAAG,EAAE,CAAA;AACxCR,EAAAA,cAAc,CAACS,8BAA8B,GAAG,IAAIC,GAAG,EAGpD,CAAA;EACHV,cAAc,CAACW,4BAA4B,GAAG;AAC5CC,IAAAA,QAAQ,EAAE,EAAE;AACZC,IAAAA,UAAU,EAAE,EAAA;GACb,CAAA;AACH,CAAA;AAEA,SAASC,UAAUA,GAAS;AAC1Bd,EAAAA,cAAc,CAACS,8BAA8B,CAACM,KAAK,EAAE,C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KAAK,CAAC,mBAAmB,EAAE;MAAEA,KAAK;AAAEC,MAAAA,SAAS,EAAE,IAAA;AAAK,KAAC,CAAC,CAAA;AAC/D,GAAC,CAAC,CAAA;AACFjD,EAAAA,OAAO,CAAC+C,EAAE,CAAC,oBAAoB,EAAGC,KAAK,IAAK;AAC1CH,IAAAA,MAAM,CAACG,KAAK,CAAC,oBAAoB,EAAE;MAAEA,KAAK;AAAEC,MAAAA,SAAS,EAAE,IAAA;AAAK,KAAC,CAAC,CAAA;AAChE,GAAC,CAAC,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"index-browsermodern.es.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler, Level } from 'nightingale-types';\n\nconst globalOrWindow: typeof global =\n typeof global !== 'undefined' ? global : (window as typeof global);\n\nif (\n process.env.NODE_ENV !== 'production' &&\n globalOrWindow.__NIGHTINGALE_GLOBAL_HANDLERS\n) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!globalOrWindow.__NIGHTINGALE_CONFIG) {\n globalOrWindow.__NIGHTINGALE_CONFIG = [];\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n globalOrWindow.__NIGHTINGALE_CONFIG_DEFAULT = {\n handlers: [],\n processors: [],\n };\n}\n\nfunction clearCache(): void {\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE.clear();\n}\n\nfunction handleConfig(config: Config): Config {\n if (config.keys) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n if (config.key) {\n throw new Error('Cannot have key and keys for the same config');\n }\n } else if (config.key) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n config.keys = [config.key];\n delete config.key;\n }\n\n if (config.handler) {\n if (config.handlers) {\n throw new Error('Cannot have handler and handlers for the same config');\n }\n config.handlers = [config.handler];\n delete config.handler;\n }\n\n if (config.processor) {\n if (config.processors) {\n throw new Error(\n 'Cannot have processors and processors for the same config',\n );\n }\n config.processors = [config.processor];\n delete config.processor;\n }\n\n return config;\n}\n\nexport function configure(config: Config[]): void {\n if (globalOrWindow.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n globalOrWindow.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n globalOrWindow.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);\n clearCache();\n}\n\nconst configIsForKey = (key: string) => (config: Config) => {\n if (config.keys) return config.keys.includes(key);\n if (config.pattern) return config.pattern.test(key);\n return true;\n};\n\nglobalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE;\n\n const existingCache = globalCache.get(key);\n\n if (existingCache) {\n return existingCache;\n }\n\n const loggerConfig: ComputedConfigForKey = {\n handlers: [],\n processors: [],\n };\n\n globalOrWindow.__NIGHTINGALE_CONFIG\n .filter(configIsForKey(key))\n .some((config: Config) => {\n if (config.handlers) loggerConfig.handlers.push(...config.handlers);\n if (config.processors) loggerConfig.processors.push(...config.processors);\n return config.stop;\n });\n\n globalCache.set(key, loggerConfig);\n return loggerConfig;\n};\n\nif (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: Level,\n ): ComputedConfigForKey => {\n const { handlers, processors }: ComputedConfigForKey =\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key);\n\n return {\n handlers: handlers.filter(\n (handler: Handler) =>\n level >= handler.minLevel &&\n (!handler.isHandling || handler.isHandling(level, key)),\n ),\n processors,\n };\n };\n}\n","import { Logger } from 'nightingale-logger';\n\nexport { Logger } from 'nightingale-logger';\nexport { Level, Level as levels } from 'nightingale-levels';\nexport { configure, addConfig } from './config';\n\n/**\n * listen to uncaughtException and unhandledRejection\n * @param {Logger} [logger]\n */\nexport function listenUnhandledErrors(\n logger: Logger = new Logger(\n 'nightingale:listenUnhandledErrors',\n 'UnhandledErrors',\n ),\n): void {\n process.on('uncaughtException', (error) => {\n logger.error(error, {\n unhandled: true,\n type: 'uncaughtException',\n });\n });\n process.on('unhandledRejection', (error) => {\n logger.error(error as Error, {\n unhandled: true,\n type: 'unhandledRejection',\n });\n });\n}\n"],"names":["globalOrWindow","global","window","process","env","NODE_ENV","__NIGHTINGALE_GLOBAL_HANDLERS","Error","__NIGHTINGALE_CONFIG","__NIGHTINGALE_LOGGER_MAP_CACHE","Map","__NIGHTINGALE_CONFIG_DEFAULT","handlers","processors","clearCache","clear","handleConfig","config","keys","pattern","key","handler","processor","configure","length","console","log","map","addConfig","unshift","configIsForKey","includes","test","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER","globalCache","existingCache","get","loggerConfig","filter","some","push","stop","set","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD","level","minLevel","isHandling","listenUnhandledErrors","logger","Logger","on","error","unhandled","type"],"mappings":";;;;AAGA,MAAMA,cAA6B,GACjC,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAIC,MAAwB,CAAA;AAEpE,IACEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IACrCL,cAAc,CAACM,6BAA6B,EAC5C;AACA,EAAA,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC,CAAA;AACtD,CAAA;AAEA,IAAI,CAACP,cAAc,CAACQ,oBAAoB,EAAE;EACxCR,cAAc,CAACQ,oBAAoB,GAAG,EAAE,CAAA;AACxCR,EAAAA,cAAc,CAACS,8BAA8B,GAAG,IAAIC,GAAG,EAGpD,CAAA;EACHV,cAAc,CAACW,4BAA4B,GA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BAAqBA,CACnCC,MAAc,GAAG,IAAIC,MAAM,CACzB,mCAAmC,EACnC,iBACF,CAAC,EACK;AACN9C,EAAAA,OAAO,CAAC+C,EAAE,CAAC,mBAAmB,EAAGC,KAAK,IAAK;AACzCH,IAAAA,MAAM,CAACG,KAAK,CAACA,KAAK,EAAE;AAClBC,MAAAA,SAAS,EAAE,IAAI;AACfC,MAAAA,IAAI,EAAE,mBAAA;AACR,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AACFlD,EAAAA,OAAO,CAAC+C,EAAE,CAAC,oBAAoB,EAAGC,KAAK,IAAK;AAC1CH,IAAAA,MAAM,CAACG,KAAK,CAACA,KAAK,EAAW;AAC3BC,MAAAA,SAAS,EAAE,IAAI;AACfC,MAAAA,IAAI,EAAE,oBAAA;AACR,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AACJ;;;;"}
@@ -103,15 +103,15 @@ if (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
103
103
  */
104
104
  function listenUnhandledErrors(logger = new Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors')) {
105
105
  process.on('uncaughtException', error => {
106
- logger.error('uncaughtException', {
107
- error,
108
- unhandled: true
106
+ logger.error(error, {
107
+ unhandled: true,
108
+ type: 'uncaughtException'
109
109
  });
110
110
  });
111
111
  process.on('unhandledRejection', error => {
112
- logger.error('unhandledRejection', {
113
- error,
114
- unhandled: true
112
+ logger.error(error, {
113
+ unhandled: true,
114
+ type: 'unhandledRejection'
115
115
  });
116
116
  });
117
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index-node18.mjs","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler, Level } from 'nightingale-types';\n\nconst globalOrWindow: typeof global =\n typeof global !== 'undefined' ? global : (window as typeof global);\n\nif (\n process.env.NODE_ENV !== 'production' &&\n globalOrWindow.__NIGHTINGALE_GLOBAL_HANDLERS\n) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!globalOrWindow.__NIGHTINGALE_CONFIG) {\n globalOrWindow.__NIGHTINGALE_CONFIG = [];\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n globalOrWindow.__NIGHTINGALE_CONFIG_DEFAULT = {\n handlers: [],\n processors: [],\n };\n}\n\nfunction clearCache(): void {\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE.clear();\n}\n\nfunction handleConfig(config: Config): Config {\n if (config.keys) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n if (config.key) {\n throw new Error('Cannot have key and keys for the same config');\n }\n } else if (config.key) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n config.keys = [config.key];\n delete config.key;\n }\n\n if (config.handler) {\n if (config.handlers) {\n throw new Error('Cannot have handler and handlers for the same config');\n }\n config.handlers = [config.handler];\n delete config.handler;\n }\n\n if (config.processor) {\n if (config.processors) {\n throw new Error(\n 'Cannot have processors and processors for the same config',\n );\n }\n config.processors = [config.processor];\n delete config.processor;\n }\n\n return config;\n}\n\nexport function configure(config: Config[]): void {\n if (globalOrWindow.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n globalOrWindow.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n globalOrWindow.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);\n clearCache();\n}\n\nconst configIsForKey = (key: string) => (config: Config) => {\n if (config.keys) return config.keys.includes(key);\n if (config.pattern) return config.pattern.test(key);\n return true;\n};\n\nglobalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE;\n\n const existingCache = globalCache.get(key);\n\n if (existingCache) {\n return existingCache;\n }\n\n const loggerConfig: ComputedConfigForKey = {\n handlers: [],\n processors: [],\n };\n\n globalOrWindow.__NIGHTINGALE_CONFIG\n .filter(configIsForKey(key))\n .some((config: Config) => {\n if (config.handlers) loggerConfig.handlers.push(...config.handlers);\n if (config.processors) loggerConfig.processors.push(...config.processors);\n return config.stop;\n });\n\n globalCache.set(key, loggerConfig);\n return loggerConfig;\n};\n\nif (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: Level,\n ): ComputedConfigForKey => {\n const { handlers, processors }: ComputedConfigForKey =\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key);\n\n return {\n handlers: handlers.filter(\n (handler: Handler) =>\n level >= handler.minLevel &&\n (!handler.isHandling || handler.isHandling(level, key)),\n ),\n processors,\n };\n };\n}\n","import { Logger } from 'nightingale-logger';\n\nexport { Logger } from 'nightingale-logger';\nexport { Level, Level as levels } from 'nightingale-levels';\nexport { configure, addConfig } from './config';\n\n/**\n * listen to uncaughtException and unhandledRejection\n * @param {Logger} [logger]\n */\nexport function listenUnhandledErrors(\n logger: Logger = new Logger(\n 'nightingale:listenUnhandledErrors',\n 'UnhandledErrors',\n ),\n): void {\n process.on('uncaughtException', (error) => {\n logger.error('uncaughtException', { error, unhandled: true });\n });\n process.on('unhandledRejection', (error) => {\n logger.error('unhandledRejection', { error, unhandled: true });\n });\n}\n"],"names":["globalOrWindow","global","window","process","env","NODE_ENV","__NIGHTINGALE_GLOBAL_HANDLERS","Error","__NIGHTINGALE_CONFIG","__NIGHTINGALE_LOGGER_MAP_CACHE","Map","__NIGHTINGALE_CONFIG_DEFAULT","handlers","processors","clearCache","clear","handleConfig","config","keys","pattern","key","handler","processor","configure","length","console","log","map","addConfig","unshift","configIsForKey","includes","test","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER","globalCache","existingCache","get","loggerConfig","filter","some","push","stop","set","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD","level","minLevel","isHandling","listenUnhandledErrors","logger","Logger","on","error","unhandled"],"mappings":";;;;AAGA,MAAMA,cAA6B,GACjC,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAIC,MAAwB,CAAA;AAEpE,IACEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IACrCL,cAAc,CAACM,6BAA6B,EAC5C;AACA,EAAA,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC,CAAA;AACtD,CAAA;AAEA,IAAI,CAACP,cAAc,CAACQ,oBAAoB,EAAE;EACxCR,cAAc,CAACQ,oBAAoB,GAAG,EAAE,CAAA;AACxCR,EAAAA,cAAc,CAACS,8BAA8B,GAAG,IAAIC,GAAG,EAGpD,CAAA;EACHV,cAAc,CAACW,4BAA4B,GAAG;AAC5CC,IAAAA,QAAQ,EAAE,EAAE;AACZC,IAAAA,UAAU,EAAE,EAAA;GACb,CAAA;AACH,CAAA;AAEA,SAASC,UAAUA,GAAS;AAC1Bd,EAAAA,cAAc,CAACS,8BAA8B,CAACM,KAAK,EAAE,CAAA;AACvD,CAAA;AAEA,SAASC,YAAYA,CAACC,MAAc,EAAU;EAC5C,IAAIA,MAAM,CAACC,IAAI,EAAE;IACf,IAAID,MAAM,CAACE,OAAO,EAAE;AAClB,MAAA,MAAM,IAAIZ,KAAK,CAAC,iDAAiD,CAAC,CAAA;AACpE,KAAA;IACA,IAAIU,MAAM,CAACG,GAAG,EAAE;AACd,MAAA,MAAM,IAAIb,KAAK,CAAC,8CAA8C,CAAC,CAAA;AACjE,KAAA;AACF,GAAC,MAAM,IAAIU,MAAM,CAACG,GAAG,EAAE;IACrB,IAAIH,MAAM,CAACE,OAAO,EAAE;AAClB,MAAA,MAAM,IAAIZ,KAAK,CAAC,iDAAiD,CAAC,CAAA;AACpE,K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AAY,CAAC,CAAA;AAClC,EAAA,OAAOA,YAAY,CAAA;AACrB,CAAC,CAAA;AAED,IAAIrC,cAAc,CAAC2C,0CAA0C,EAAE;AAC7D3C,EAAAA,cAAc,CAAC2C,0CAA0C,GAAG,CAC1DvB,GAAW,EACXwB,KAAY,KACa;IACzB,MAAM;MAAEhC,QAAQ;AAAEC,MAAAA,UAAAA;AAAiC,KAAC,GAClDb,cAAc,CAACiC,mCAAmC,CAACb,GAAG,CAAC,CAAA;IAEzD,OAAO;MACLR,QAAQ,EAAEA,QAAQ,CAAC0B,MAAM,CACtBjB,OAAgB,IACfuB,KAAK,IAAIvB,OAAO,CAACwB,QAAQ,KACxB,CAACxB,OAAO,CAACyB,UAAU,IAAIzB,OAAO,CAACyB,UAAU,CAACF,KAAK,EAAExB,GAAG,CAAC,CAC1D,CAAC;AACDP,MAAAA,UAAAA;KACD,CAAA;GACF,CAAA;AACH;;AC/HA;AACA;AACA;AACA;AACO,SAASkC,qBAAqBA,CACnCC,MAAc,GAAG,IAAIC,MAAM,CACzB,mCAAmC,EACnC,iBACF,CAAC,EACK;AACN9C,EAAAA,OAAO,CAAC+C,EAAE,CAAC,mBAAmB,EAAGC,KAAK,IAAK;AACzCH,IAAAA,MAAM,CAACG,KAAK,CAAC,mBAAmB,EAAE;MAAEA,KAAK;AAAEC,MAAAA,SAAS,EAAE,IAAA;AAAK,KAAC,CAAC,CAAA;AAC/D,GAAC,CAAC,CAAA;AACFjD,EAAAA,OAAO,CAAC+C,EAAE,CAAC,oBAAoB,EAAGC,KAAK,IAAK;AAC1CH,IAAAA,MAAM,CAACG,KAAK,CAAC,oBAAoB,EAAE;MAAEA,KAAK;AAAEC,MAAAA,SAAS,EAAE,IAAA;AAAK,KAAC,CAAC,CAAA;AAChE,GAAC,CAAC,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"index-node18.mjs","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler, Level } from 'nightingale-types';\n\nconst globalOrWindow: typeof global =\n typeof global !== 'undefined' ? global : (window as typeof global);\n\nif (\n process.env.NODE_ENV !== 'production' &&\n globalOrWindow.__NIGHTINGALE_GLOBAL_HANDLERS\n) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!globalOrWindow.__NIGHTINGALE_CONFIG) {\n globalOrWindow.__NIGHTINGALE_CONFIG = [];\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n globalOrWindow.__NIGHTINGALE_CONFIG_DEFAULT = {\n handlers: [],\n processors: [],\n };\n}\n\nfunction clearCache(): void {\n globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE.clear();\n}\n\nfunction handleConfig(config: Config): Config {\n if (config.keys) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n if (config.key) {\n throw new Error('Cannot have key and keys for the same config');\n }\n } else if (config.key) {\n if (config.pattern) {\n throw new Error('Cannot have key and pattern for the same config');\n }\n config.keys = [config.key];\n delete config.key;\n }\n\n if (config.handler) {\n if (config.handlers) {\n throw new Error('Cannot have handler and handlers for the same config');\n }\n config.handlers = [config.handler];\n delete config.handler;\n }\n\n if (config.processor) {\n if (config.processors) {\n throw new Error(\n 'Cannot have processors and processors for the same config',\n );\n }\n config.processors = [config.processor];\n delete config.processor;\n }\n\n return config;\n}\n\nexport function configure(config: Config[]): void {\n if (globalOrWindow.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n globalOrWindow.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n globalOrWindow.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);\n clearCache();\n}\n\nconst configIsForKey = (key: string) => (config: Config) => {\n if (config.keys) return config.keys.includes(key);\n if (config.pattern) return config.pattern.test(key);\n return true;\n};\n\nglobalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE;\n\n const existingCache = globalCache.get(key);\n\n if (existingCache) {\n return existingCache;\n }\n\n const loggerConfig: ComputedConfigForKey = {\n handlers: [],\n processors: [],\n };\n\n globalOrWindow.__NIGHTINGALE_CONFIG\n .filter(configIsForKey(key))\n .some((config: Config) => {\n if (config.handlers) loggerConfig.handlers.push(...config.handlers);\n if (config.processors) loggerConfig.processors.push(...config.processors);\n return config.stop;\n });\n\n globalCache.set(key, loggerConfig);\n return loggerConfig;\n};\n\nif (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: Level,\n ): ComputedConfigForKey => {\n const { handlers, processors }: ComputedConfigForKey =\n globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key);\n\n return {\n handlers: handlers.filter(\n (handler: Handler) =>\n level >= handler.minLevel &&\n (!handler.isHandling || handler.isHandling(level, key)),\n ),\n processors,\n };\n };\n}\n","import { Logger } from 'nightingale-logger';\n\nexport { Logger } from 'nightingale-logger';\nexport { Level, Level as levels } from 'nightingale-levels';\nexport { configure, addConfig } from './config';\n\n/**\n * listen to uncaughtException and unhandledRejection\n * @param {Logger} [logger]\n */\nexport function listenUnhandledErrors(\n logger: Logger = new Logger(\n 'nightingale:listenUnhandledErrors',\n 'UnhandledErrors',\n ),\n): void {\n process.on('uncaughtException', (error) => {\n logger.error(error, {\n unhandled: true,\n type: 'uncaughtException',\n });\n });\n process.on('unhandledRejection', (error) => {\n logger.error(error as Error, {\n unhandled: true,\n type: 'unhandledRejection',\n });\n });\n}\n"],"names":["globalOrWindow","global","window","process","env","NODE_ENV","__NIGHTINGALE_GLOBAL_HANDLERS","Error","__NIGHTINGALE_CONFIG","__NIGHTINGALE_LOGGER_MAP_CACHE","Map","__NIGHTINGALE_CONFIG_DEFAULT","handlers","processors","clearCache","clear","handleConfig","config","keys","pattern","key","handler","processor","configure","length","console","log","map","addConfig","unshift","configIsForKey","includes","test","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER","globalCache","existingCache","get","loggerConfig","filter","some","push","stop","set","__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD","level","minLevel","isHandling","listenUnhandledErrors","logger","Logger","on","error","unhandled","type"],"mappings":";;;;AAGA,MAAMA,cAA6B,GACjC,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAIC,MAAwB,CAAA;AAEpE,IACEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IACrCL,cAAc,CAACM,6BAA6B,EAC5C;AACA,EAAA,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC,CAAA;AACtD,CAAA;AAEA,IAAI,CAACP,cAAc,CAACQ,oBAAoB,EAAE;EACxCR,cAAc,CAACQ,oBAAoB,GAAG,EAAE,CAAA;AACxCR,EAAAA,cAAc,CAACS,8BAA8B,GAAG,IAAIC,GAAG,EAGpD,CAAA;EACHV,cAAc,CAACW,4BAA4B,GAAG;AAC5CC,IAAAA,QAAQ,EAAE,EAAE;AACZC,IAAAA,UAAU,EAAE,EAAA;GACb,CAAA;AACH,CAAA;AAEA,SAASC,UAAUA,GAAS;AAC1Bd,EAAAA,cAAc,CAACS,8BAA8B,CAACM,KAAK,EAAE,CAAA;AACvD,CAAA;AAEA,SAASC,YAAYA,CAACC,MAAc,EAAU;EAC5C,IAAIA,MAAM,CAACC,IAAI,EAAE;IACf,IAAID,MAAM,CAACE,OAAO,EAAE;AAClB,MAAA,MAAM,IAAIZ,KAAK,CAAC,iDAAiD,CAAC,CAAA;AACpE,KAAA;IACA,IAAIU,MAAM,CAACG,GAAG,EAAE;AACd,MAAA,MAAM,IAAIb,KAAK,CAAC,8CAA8C,CAAC,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AAI;AACfC,MAAAA,IAAI,EAAE,oBAAA;AACR,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AACJ;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nightingale",
3
- "version": "14.1.0",
3
+ "version": "14.2.1",
4
4
  "description": "Logger for browser and node",
5
5
  "keywords": [
6
6
  "logger"
@@ -46,6 +46,10 @@
46
46
  }
47
47
  },
48
48
  "sideEffects": false,
49
+ "files": [
50
+ "src",
51
+ "dist"
52
+ ],
49
53
  "scripts": {
50
54
  "build": "yarn clean:build && rollup --config rollup.config.mjs && yarn run build:definitions",
51
55
  "build:definitions": "tsc -p tsconfig.json",
@@ -77,16 +81,15 @@
77
81
  },
78
82
  "dependencies": {
79
83
  "@types/node": ">=18.0.0",
80
- "nightingale-levels": "14.1.0",
81
- "nightingale-logger": "14.1.0",
82
- "nightingale-types": "14.1.0"
84
+ "nightingale-levels": "14.2.1",
85
+ "nightingale-logger": "14.2.1",
86
+ "nightingale-types": "14.2.1"
83
87
  },
84
88
  "devDependencies": {
85
- "@babel/core": "7.22.9",
86
- "@babel/preset-env": "7.22.9",
87
- "nightingale-string": "14.1.0",
88
- "pob-babel": "36.2.0",
89
- "typescript": "5.1.6"
90
- },
91
- "gitHead": "fa6fa6109188db75b1b0e6a7ad5d6ae607a26711"
92
- }
89
+ "@babel/core": "7.23.2",
90
+ "@babel/preset-env": "7.23.2",
91
+ "nightingale-string": "14.2.1",
92
+ "pob-babel": "36.6.1",
93
+ "typescript": "5.2.2"
94
+ }
95
+ }
@@ -7,6 +7,9 @@
7
7
  "plugins": ["@typescript-eslint"],
8
8
  "extends": ["@pob/eslint-config-typescript"],
9
9
  "ignorePatterns": ["*.d.ts"],
10
+ "rules": {
11
+ "@typescript-eslint/max-params": "warn"
12
+ },
10
13
  "overrides": [
11
14
  {
12
15
  "files": ["**/*.test.ts", "__tests__/**/*.ts"],
package/src/index.ts CHANGED
@@ -15,9 +15,15 @@ export function listenUnhandledErrors(
15
15
  ),
16
16
  ): void {
17
17
  process.on('uncaughtException', (error) => {
18
- logger.error('uncaughtException', { error, unhandled: true });
18
+ logger.error(error, {
19
+ unhandled: true,
20
+ type: 'uncaughtException',
21
+ });
19
22
  });
20
23
  process.on('unhandledRejection', (error) => {
21
- logger.error('unhandledRejection', { error, unhandled: true });
24
+ logger.error(error as Error, {
25
+ unhandled: true,
26
+ type: 'unhandledRejection',
27
+ });
22
28
  });
23
29
  }
package/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- # EditorConfig helps developers define and maintain consistent
2
- # coding styles between different editors and IDEs
3
- # http://editorconfig.org
4
-
5
- root = true
6
-
7
- [*]
8
- indent_style = space
9
- indent_size = 2
10
- end_of_line = lf
11
- charset = utf-8
12
- trim_trailing_whitespace = true
13
- insert_final_newline = true
package/.eslintrc.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "root": true,
3
- "extends": ["@pob/eslint-config/root-module"],
4
- "ignorePatterns": ["*.d.ts", "/dist"]
5
- }
package/AUTHORS DELETED
@@ -1,3 +0,0 @@
1
- Christophe Hurpeau <christophe.hurpeau+github@gmail.com>
2
- Christophe Hurpeau <christophe@evaneos.com>
3
- Christophe Hurpeau <christophe@hurpeau.com>