nightingale 14.2.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
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
+ ## [15.0.0](https://github.com/christophehurpeau/nightingale/compare/v14.2.1...v15.0.0) (2023-12-25)
7
+
8
+
9
+ ### ⚠ BREAKING CHANGES
10
+
11
+ * update babel and drop browser modern version
12
+
13
+ ### Features
14
+
15
+ * update babel and drop browser modern version ([5c76abc](https://github.com/christophehurpeau/nightingale/commit/5c76abc8bfb595a617fc4c8b795dae7e674ea664))
16
+
17
+ Version bump for dependency: nightingale-levels
18
+ Version bump for dependency: nightingale-logger
19
+ Version bump for dependency: nightingale-types
20
+ Version bump for dependency: nightingale-string
21
+
22
+
23
+ ## [14.2.1](https://github.com/christophehurpeau/nightingale/compare/v14.2.0...v14.2.1) (2023-11-05)
24
+
25
+ Note: no notable changes
26
+
27
+ Version bump for dependency: nightingale-levels
28
+ Version bump for dependency: nightingale-logger
29
+ Version bump for dependency: nightingale-types
30
+ Version bump for dependency: nightingale-string
31
+
32
+
6
33
  ## [14.2.0](https://github.com/christophehurpeau/nightingale/compare/v14.1.0...v14.2.0) (2023-11-04)
7
34
 
8
35
 
@@ -2,7 +2,7 @@ import { Logger } from 'nightingale-logger';
2
2
  export { Logger } from 'nightingale-logger';
3
3
  export { Level, Level as levels } from 'nightingale-levels';
4
4
 
5
- var globalOrWindow = typeof global !== 'undefined' ? global : window;
5
+ const globalOrWindow = typeof global !== 'undefined' ? global : window;
6
6
  if (process.env.NODE_ENV !== 'production' && globalOrWindow.__NIGHTINGALE_GLOBAL_HANDLERS) {
7
7
  throw new Error('nightingale: update all to ^5.0.0');
8
8
  }
@@ -56,50 +56,43 @@ function configure(config) {
56
56
  clearCache();
57
57
  globalOrWindow.__NIGHTINGALE_CONFIG = config.map(handleConfig);
58
58
  }
59
- function addConfig(config, unshift) {
60
- if (unshift === void 0) {
61
- unshift = false;
62
- }
59
+ function addConfig(config, unshift = false) {
63
60
  config = handleConfig(config);
64
61
  globalOrWindow.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);
65
62
  clearCache();
66
63
  }
67
- var configIsForKey = function configIsForKey(key) {
68
- return function (config) {
69
- if (config.keys) return config.keys.includes(key);
70
- if (config.pattern) return config.pattern.test(key);
71
- return true;
72
- };
64
+ const configIsForKey = key => config => {
65
+ if (config.keys) return config.keys.includes(key);
66
+ if (config.pattern) return config.pattern.test(key);
67
+ return true;
73
68
  };
74
- globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = function (key) {
75
- var globalCache = globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE;
76
- var existingCache = globalCache.get(key);
69
+ globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = key => {
70
+ const globalCache = globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE;
71
+ const existingCache = globalCache.get(key);
77
72
  if (existingCache) {
78
73
  return existingCache;
79
74
  }
80
- var loggerConfig = {
75
+ const loggerConfig = {
81
76
  handlers: [],
82
77
  processors: []
83
78
  };
84
- globalOrWindow.__NIGHTINGALE_CONFIG.filter(configIsForKey(key)).some(function (config) {
85
- var _loggerConfig$handler, _loggerConfig$process;
86
- if (config.handlers) (_loggerConfig$handler = loggerConfig.handlers).push.apply(_loggerConfig$handler, config.handlers);
87
- if (config.processors) (_loggerConfig$process = loggerConfig.processors).push.apply(_loggerConfig$process, config.processors);
79
+ globalOrWindow.__NIGHTINGALE_CONFIG.filter(configIsForKey(key)).some(config => {
80
+ if (config.handlers) loggerConfig.handlers.push(...config.handlers);
81
+ if (config.processors) loggerConfig.processors.push(...config.processors);
88
82
  return config.stop;
89
83
  });
90
84
  globalCache.set(key, loggerConfig);
91
85
  return loggerConfig;
92
86
  };
93
87
  if (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
94
- globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = function (key, level) {
95
- var _globalOrWindow$__NIG = globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key),
96
- handlers = _globalOrWindow$__NIG.handlers,
97
- processors = _globalOrWindow$__NIG.processors;
88
+ globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (key, level) => {
89
+ const {
90
+ handlers,
91
+ processors
92
+ } = globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key);
98
93
  return {
99
- handlers: handlers.filter(function (handler) {
100
- return level >= handler.minLevel && (!handler.isHandling || handler.isHandling(level, key));
101
- }),
102
- processors: processors
94
+ handlers: handlers.filter(handler => level >= handler.minLevel && (!handler.isHandling || handler.isHandling(level, key))),
95
+ processors
103
96
  };
104
97
  };
105
98
  }
@@ -108,17 +101,14 @@ if (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
108
101
  * listen to uncaughtException and unhandledRejection
109
102
  * @param {Logger} [logger]
110
103
  */
111
- function listenUnhandledErrors(logger) {
112
- if (logger === void 0) {
113
- logger = new Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors');
114
- }
115
- process.on('uncaughtException', function (error) {
104
+ function listenUnhandledErrors(logger = new Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors')) {
105
+ process.on('uncaughtException', error => {
116
106
  logger.error(error, {
117
107
  unhandled: true,
118
108
  type: 'uncaughtException'
119
109
  });
120
110
  });
121
- process.on('unhandledRejection', function (error) {
111
+ process.on('unhandledRejection', error => {
122
112
  logger.error(error, {
123
113
  unhandled: true,
124
114
  type: 'unhandledRejection'
@@ -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(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,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,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,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;;;;"}
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","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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AAQ,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,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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nightingale",
3
- "version": "14.2.0",
3
+ "version": "15.0.0",
4
4
  "description": "Logger for browser and node",
5
5
  "keywords": [
6
6
  "logger"
@@ -38,9 +38,6 @@
38
38
  "import": "./dist/index-node18.mjs"
39
39
  },
40
40
  "browser": {
41
- "browser:modern": {
42
- "import": "./dist/index-browsermodern.es.js"
43
- },
44
41
  "import": "./dist/index-browser.es.js"
45
42
  }
46
43
  }
@@ -67,10 +64,6 @@
67
64
  "target": "node",
68
65
  "version": "18"
69
66
  },
70
- {
71
- "target": "browser",
72
- "version": "modern"
73
- },
74
67
  {
75
68
  "target": "browser"
76
69
  }
@@ -81,15 +74,15 @@
81
74
  },
82
75
  "dependencies": {
83
76
  "@types/node": ">=18.0.0",
84
- "nightingale-levels": "14.2.0",
85
- "nightingale-logger": "14.2.0",
86
- "nightingale-types": "14.2.0"
77
+ "nightingale-levels": "15.0.0",
78
+ "nightingale-logger": "15.0.0",
79
+ "nightingale-types": "15.0.0"
87
80
  },
88
81
  "devDependencies": {
89
- "@babel/core": "7.23.2",
90
- "@babel/preset-env": "7.23.2",
91
- "nightingale-string": "14.2.0",
92
- "pob-babel": "36.4.4",
93
- "typescript": "5.2.2"
82
+ "@babel/core": "7.23.6",
83
+ "@babel/preset-env": "7.23.6",
84
+ "nightingale-string": "15.0.0",
85
+ "pob-babel": "38.0.0",
86
+ "typescript": "5.3.3"
94
87
  }
95
88
  }
package/src/index.test.ts CHANGED
@@ -10,7 +10,7 @@ class TestableStringLogger extends Logger {
10
10
  this.stringHandler = new StringHandler(Level.ALL);
11
11
  }
12
12
 
13
- protected getHandlersAndProcessors(): ComputedConfigForKey {
13
+ protected override getHandlersAndProcessors(): ComputedConfigForKey {
14
14
  return {
15
15
  handlers: [this.stringHandler],
16
16
  processors: [],
@@ -1,120 +0,0 @@
1
- import { Logger } from 'nightingale-logger';
2
- export { Logger } from 'nightingale-logger';
3
- export { Level, Level as levels } from 'nightingale-levels';
4
-
5
- const globalOrWindow = typeof global !== 'undefined' ? global : window;
6
- if (process.env.NODE_ENV !== 'production' && globalOrWindow.__NIGHTINGALE_GLOBAL_HANDLERS) {
7
- throw new Error('nightingale: update all to ^5.0.0');
8
- }
9
- if (!globalOrWindow.__NIGHTINGALE_CONFIG) {
10
- globalOrWindow.__NIGHTINGALE_CONFIG = [];
11
- globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map();
12
- globalOrWindow.__NIGHTINGALE_CONFIG_DEFAULT = {
13
- handlers: [],
14
- processors: []
15
- };
16
- }
17
- function clearCache() {
18
- globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE.clear();
19
- }
20
- function handleConfig(config) {
21
- if (config.keys) {
22
- if (config.pattern) {
23
- throw new Error('Cannot have key and pattern for the same config');
24
- }
25
- if (config.key) {
26
- throw new Error('Cannot have key and keys for the same config');
27
- }
28
- } else if (config.key) {
29
- if (config.pattern) {
30
- throw new Error('Cannot have key and pattern for the same config');
31
- }
32
- config.keys = [config.key];
33
- delete config.key;
34
- }
35
- if (config.handler) {
36
- if (config.handlers) {
37
- throw new Error('Cannot have handler and handlers for the same config');
38
- }
39
- config.handlers = [config.handler];
40
- delete config.handler;
41
- }
42
- if (config.processor) {
43
- if (config.processors) {
44
- throw new Error('Cannot have processors and processors for the same config');
45
- }
46
- config.processors = [config.processor];
47
- delete config.processor;
48
- }
49
- return config;
50
- }
51
- function configure(config) {
52
- if (globalOrWindow.__NIGHTINGALE_CONFIG.length > 0) {
53
- // eslint-disable-next-line no-console
54
- console.log('nightingale: warning: config overridden');
55
- }
56
- clearCache();
57
- globalOrWindow.__NIGHTINGALE_CONFIG = config.map(handleConfig);
58
- }
59
- function addConfig(config, unshift = false) {
60
- config = handleConfig(config);
61
- globalOrWindow.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);
62
- clearCache();
63
- }
64
- const configIsForKey = key => config => {
65
- if (config.keys) return config.keys.includes(key);
66
- if (config.pattern) return config.pattern.test(key);
67
- return true;
68
- };
69
- globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = key => {
70
- const globalCache = globalOrWindow.__NIGHTINGALE_LOGGER_MAP_CACHE;
71
- const existingCache = globalCache.get(key);
72
- if (existingCache) {
73
- return existingCache;
74
- }
75
- const loggerConfig = {
76
- handlers: [],
77
- processors: []
78
- };
79
- globalOrWindow.__NIGHTINGALE_CONFIG.filter(configIsForKey(key)).some(config => {
80
- if (config.handlers) loggerConfig.handlers.push(...config.handlers);
81
- if (config.processors) loggerConfig.processors.push(...config.processors);
82
- return config.stop;
83
- });
84
- globalCache.set(key, loggerConfig);
85
- return loggerConfig;
86
- };
87
- if (globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
88
- globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (key, level) => {
89
- const {
90
- handlers,
91
- processors
92
- } = globalOrWindow.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key);
93
- return {
94
- handlers: handlers.filter(handler => level >= handler.minLevel && (!handler.isHandling || handler.isHandling(level, key))),
95
- processors
96
- };
97
- };
98
- }
99
-
100
- /**
101
- * listen to uncaughtException and unhandledRejection
102
- * @param {Logger} [logger]
103
- */
104
- function listenUnhandledErrors(logger = new Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors')) {
105
- process.on('uncaughtException', error => {
106
- logger.error(error, {
107
- unhandled: true,
108
- type: 'uncaughtException'
109
- });
110
- });
111
- process.on('unhandledRejection', error => {
112
- logger.error(error, {
113
- unhandled: true,
114
- type: 'unhandledRejection'
115
- });
116
- });
117
- }
118
-
119
- export { addConfig, configure, listenUnhandledErrors };
120
- //# sourceMappingURL=index-browsermodern.es.js.map
@@ -1 +0,0 @@
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,C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