nightingale 11.6.0 → 11.7.4

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/.eslintrc.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "root": true,
3
- "extends": ["@pob/eslint-config/root", "@pob/eslint-config-node"],
3
+ "extends": ["@pob/eslint-config/root-commonjs"],
4
4
  "ignorePatterns": ["*.d.ts", "/dist"]
5
5
  }
package/CHANGELOG.md CHANGED
@@ -3,6 +3,44 @@
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
+ ## [11.7.4](https://github.com/christophehurpeau/nightingale/compare/v11.7.3...v11.7.4) (2021-11-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * build all packages ([dbb4785](https://github.com/christophehurpeau/nightingale/commit/dbb4785cbb8c75942935c4a5935df32fd2e93690))
12
+
13
+
14
+
15
+
16
+
17
+ ## [11.7.2](https://github.com/christophehurpeau/nightingale/compare/v11.7.1...v11.7.2) (2021-11-27)
18
+
19
+ **Note:** Version bump only for package nightingale
20
+
21
+
22
+
23
+
24
+
25
+ ## [11.7.1](https://github.com/christophehurpeau/nightingale/compare/v11.7.0...v11.7.1) (2021-06-29)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * update pob-babel to bring back webpack 4 support ([4887431](https://github.com/christophehurpeau/nightingale/commit/4887431b3b272496511f879af022638723b9056e))
31
+
32
+
33
+
34
+
35
+
36
+ # [11.7.0](https://github.com/christophehurpeau/nightingale/compare/v11.6.0...v11.7.0) (2021-03-29)
37
+
38
+ **Note:** Version bump only for package nightingale
39
+
40
+
41
+
42
+
43
+
6
44
  # [11.6.0](https://github.com/christophehurpeau/nightingale/compare/v11.5.4...v11.6.0) (2021-03-21)
7
45
 
8
46
 
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+
5
+ module.exports = function babelConfig(api) {
6
+ const isTest = api.env('test');
7
+
8
+ if (!isTest) return {};
9
+
10
+ return {
11
+ only: [path.resolve(__dirname, 'src')],
12
+ presets: [require.resolve('pob-babel/preset')],
13
+ };
14
+ };
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var nightingaleLevels = require('nightingale-levels');
6
5
  var nightingaleLogger = require('nightingale-logger');
6
+ var nightingaleLevels = require('nightingale-levels');
7
7
 
8
8
  if (global.__NIGHTINGALE_GLOBAL_HANDLERS) {
9
9
  throw new Error('nightingale: update all to ^5.0.0');
@@ -70,7 +70,11 @@ function configure(config) {
70
70
  clearCache();
71
71
  global.__NIGHTINGALE_CONFIG = config.map(handleConfig);
72
72
  }
73
- function addConfig(config, unshift = false) {
73
+ function addConfig(config, unshift) {
74
+ if (unshift === void 0) {
75
+ unshift = false;
76
+ }
77
+
74
78
  config = handleConfig(config);
75
79
 
76
80
  global.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);
@@ -78,28 +82,32 @@ function addConfig(config, unshift = false) {
78
82
  clearCache();
79
83
  }
80
84
 
81
- const configIsForKey = key => config => {
82
- if (config.keys) return config.keys.includes(key);
83
- if (config.pattern) return config.pattern.test(key);
84
- return true;
85
+ var configIsForKey = function configIsForKey(key) {
86
+ return function (config) {
87
+ if (config.keys) return config.keys.includes(key);
88
+ if (config.pattern) return config.pattern.test(key);
89
+ return true;
90
+ };
85
91
  };
86
92
 
87
- global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = key => {
88
- const globalCache = global.__NIGHTINGALE_LOGGER_MAP_CACHE;
89
- const existingCache = globalCache.get(key);
93
+ global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = function (key) {
94
+ var globalCache = global.__NIGHTINGALE_LOGGER_MAP_CACHE;
95
+ var existingCache = globalCache.get(key);
90
96
 
91
97
  if (existingCache) {
92
98
  return existingCache;
93
99
  }
94
100
 
95
- const loggerConfig = {
101
+ var loggerConfig = {
96
102
  handlers: [],
97
103
  processors: []
98
104
  };
99
105
 
100
- global.__NIGHTINGALE_CONFIG.filter(configIsForKey(key)).some(config => {
101
- if (config.handlers) loggerConfig.handlers.push(...config.handlers);
102
- if (config.processors) loggerConfig.processors.push(...config.processors);
106
+ global.__NIGHTINGALE_CONFIG.filter(configIsForKey(key)).some(function (config) {
107
+ var _loggerConfig$handler, _loggerConfig$process;
108
+
109
+ if (config.handlers) (_loggerConfig$handler = loggerConfig.handlers).push.apply(_loggerConfig$handler, config.handlers);
110
+ if (config.processors) (_loggerConfig$process = loggerConfig.processors).push.apply(_loggerConfig$process, config.processors);
103
111
  return config.stop;
104
112
  });
105
113
 
@@ -108,13 +116,15 @@ global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = key => {
108
116
  };
109
117
 
110
118
  if (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
111
- global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (key, level) => {
112
- const _global$__NIGHTINGALE = global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key),
113
- handlers = _global$__NIGHTINGALE.handlers,
114
- processors = _global$__NIGHTINGALE.processors;
119
+ global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = function (key, level) {
120
+ var _global$__NIGHTINGALE = global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key),
121
+ handlers = _global$__NIGHTINGALE.handlers,
122
+ processors = _global$__NIGHTINGALE.processors;
115
123
 
116
124
  return {
117
- handlers: handlers.filter(handler => level >= handler.minLevel && (!handler.isHandling || handler.isHandling(level, key))),
125
+ handlers: handlers.filter(function (handler) {
126
+ return level >= handler.minLevel && (!handler.isHandling || handler.isHandling(level, key));
127
+ }),
118
128
  processors
119
129
  };
120
130
  };
@@ -125,21 +135,29 @@ if (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
125
135
  * @param {Logger} [logger]
126
136
  */
127
137
 
128
- function listenUnhandledErrors(logger = new nightingaleLogger.Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors')) {
129
- process.on('uncaughtException', error => logger.error('uncaughtException', {
130
- error,
131
- unhandled: true
132
- }));
133
- process.on('unhandledRejection', error => logger.error('unhandledRejection', {
134
- error,
135
- unhandled: true
136
- }));
138
+ function listenUnhandledErrors(logger) {
139
+ if (logger === void 0) {
140
+ logger = new nightingaleLogger.Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors');
141
+ }
142
+
143
+ process.on('uncaughtException', function (error) {
144
+ logger.error('uncaughtException', {
145
+ error,
146
+ unhandled: true
147
+ });
148
+ });
149
+ process.on('unhandledRejection', function (error) {
150
+ logger.error('unhandledRejection', {
151
+ error,
152
+ unhandled: true
153
+ });
154
+ });
137
155
  }
138
156
 
157
+ exports.Logger = nightingaleLogger.Logger;
158
+ exports["default"] = nightingaleLogger.Logger;
139
159
  exports.Level = nightingaleLevels.Level;
140
160
  exports.levels = nightingaleLevels.Level;
141
- exports.Logger = nightingaleLogger.Logger;
142
- exports.default = nightingaleLogger.Logger;
143
161
  exports.addConfig = addConfig;
144
162
  exports.configure = configure;
145
163
  exports.listenUnhandledErrors = listenUnhandledErrors;
@@ -1 +1 @@
1
- {"version":3,"file":"index-browser-dev.cjs.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import { POB_ENV } from 'pob-babel';\nimport type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler } from 'nightingale-types';\n\nif (POB_ENV !== 'production' && global.__NIGHTINGALE_GLOBAL_HANDLERS) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!global.__NIGHTINGALE_CONFIG) {\n global.__NIGHTINGALE_CONFIG = [];\n global.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n global.__NIGHTINGALE_CONFIG_DEFAULT = { handlers: [], processors: [] };\n}\n\nfunction clearCache(): void {\n global.__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 (global.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n global.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n global.__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\nglobal.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = global.__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 global.__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 (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: number,\n ): ComputedConfigForKey => {\n const {\n handlers,\n processors,\n }: ComputedConfigForKey = global.__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 { Level } from 'nightingale-levels';\nimport { Logger } from 'nightingale-logger';\n\n/** @deprecated use named export instead */\nexport default Logger;\nexport { configure, addConfig } from './config';\nexport { Logger, Level, Level as levels };\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":["global","__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","process","on","error","unhandled"],"mappings":";;;;;;;AAIA,IAAgCA,MAAM,CAACC,6BAAvC,EAAsE;AACpE,QAAM,IAAIC,KAAJ,CAAU,mCAAV,CAAN;AACD;;AAED,IAAI,CAACF,MAAM,CAACG,oBAAZ,EAAkC;AAChCH,EAAAA,MAAM,CAACG,oBAAP,GAA8B,EAA9B;AACAH,EAAAA,MAAM,CAACI,8BAA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,EAAkCC,KAAD,IAC/BJ,MAAM,CAACI,KAAP,CAAa,oBAAb,EAAmC;AAAEA,IAAAA,KAAF;AAASC,IAAAA,SAAS,EAAE;AAApB,GAAnC,CADF;AAGD;;;;;;;;;;"}
1
+ {"version":3,"file":"index-browser-dev.cjs.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import { POB_ENV } from 'pob-babel';\nimport type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler } from 'nightingale-types';\n\nif (POB_ENV !== 'production' && global.__NIGHTINGALE_GLOBAL_HANDLERS) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!global.__NIGHTINGALE_CONFIG) {\n global.__NIGHTINGALE_CONFIG = [];\n global.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n global.__NIGHTINGALE_CONFIG_DEFAULT = { handlers: [], processors: [] };\n}\n\nfunction clearCache(): void {\n global.__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 (global.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n global.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n global.__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\nglobal.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = global.__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 global.__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 (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: number,\n ): ComputedConfigForKey => {\n const { handlers, processors }: ComputedConfigForKey =\n global.__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 {\n /** @deprecated use named export instead */\n Logger as default,\n Logger,\n} 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":["global","__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","process","on","error","unhandled"],"mappings":";;;;;;;AAIA,IAAgCA,MAAM,CAACC,6BAAvC,EAAsE;AACpE,QAAM,IAAIC,KAAJ,CAAU,mCAAV,CAAN;AACD;;AAED,IAAI,CAACF,MAAM,CAACG,oBAAZ,EAAkC;AAChCH,EAAAA,MAAM,CAACG,oBAAP,GAA8B,EAA9B;AACAH,EAAAA,MAAM,CAACI,8BAAP,GAAwC,IAAIC,GAAJ,EAAxC;AAIAL,EAAAA,MAAM,CAACM,4BAAP,GAAsC;AAAEC,IAAAA,QAAQ,EAAE,EAAZ;AAAgBC,IAAAA,UAAU,EAAE;AAA5B,GAAtC;AACD;;AAED,SAASC,UAAT,GAA4B;AAC1BT,EAAAA,MAAM,CAACI,8BAAP,CAAsCM,KAAtC;AACD;;AAED,SAASC,YAAT,CAAsBC,MAAtB,EAA8C;AAC5C,MAAIA,MAAM,CAACC,IAAX,EAAiB;AACf,QAAID,MAAM,CAACE,OAAX,EAAoB;AAClB,YAAM,IAAIZ,KAAJ,CAAU,iDAAV,CAAN;AACD;;AACD,QAAIU,MAAM,CAACG,GAAX,EAAgB;AACd,YAAM,IAAIb,KAAJ,CAAU,8CAAV,CAAN;AACD;AACF,GAPD,MAOO,IAAIU,MAAM,CAACG,GAAX,EAAgB;AACrB,QAAIH,MAAM,CAACE,OAAX,EAAoB;AAClB,YAAM,IAAIZ,K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AElDwB,KAFkD,EAGzB;AACzB,gCACEvC,MAAM,CAAC4B,mCAAP,CAA2Cb,GAA3C,CADF;AAAA,QAAQR,QAAR,yBAAQA,QAAR;AAAA,QAAkBC,UAAlB,yBAAkBA,UAAlB;;AAGA,WAAO;AACLD,MAAAA,QAAQ,EAAEA,QAAQ,CAAC0B,MAAT,CACR,UAACjB,OAAD;AAAA,eACEuB,KAAK,IAAIvB,OAAO,CAACwB,QAAjB,KACC,CAACxB,OAAO,CAACyB,UAAT,IAAuBzB,OAAO,CAACyB,UAAR,CAAmBF,KAAnB,EAA0BxB,GAA1B,CADxB,CADF;AAAA,OADQ,CADL;AAMLP,MAAAA;AANK,KAAP;AAQD,GAfD;AAgBD;;ACnHD;AACA;AACA;AACA;;AACO,SAASkC,qBAAT,CACLC,MADK,EAKC;AAAA,MAJNA,MAIM;AAJNA,IAAAA,MAIM,GAJW,IAAIC,wBAAJ,CACf,mCADe,EAEf,iBAFe,CAIX;AAAA;;AACNC,EAAAA,OAAO,CAACC,EAAR,CAAW,mBAAX,EAAgC,UAACC,KAAD,EAAW;AACzCJ,IAAAA,MAAM,CAACI,KAAP,CAAa,mBAAb,EAAkC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAlC;AACD,GAFD;AAGAH,EAAAA,OAAO,CAACC,EAAR,CAAW,oBAAX,EAAiC,UAACC,KAAD,EAAW;AAC1CJ,IAAAA,MAAM,CAACI,KAAP,CAAa,oBAAb,EAAmC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAnC;AACD,GAFD;AAGD;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
- export { Level, Level as levels } from 'nightingale-levels';
2
1
  import { Logger } from 'nightingale-logger';
3
2
  export { Logger, Logger as default } from 'nightingale-logger';
3
+ export { Level, Level as levels } from 'nightingale-levels';
4
4
 
5
5
  if (global.__NIGHTINGALE_GLOBAL_HANDLERS) {
6
6
  throw new Error('nightingale: update all to ^5.0.0');
@@ -67,7 +67,11 @@ function configure(config) {
67
67
  clearCache();
68
68
  global.__NIGHTINGALE_CONFIG = config.map(handleConfig);
69
69
  }
70
- function addConfig(config, unshift = false) {
70
+ function addConfig(config, unshift) {
71
+ if (unshift === void 0) {
72
+ unshift = false;
73
+ }
74
+
71
75
  config = handleConfig(config);
72
76
 
73
77
  global.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);
@@ -75,28 +79,32 @@ function addConfig(config, unshift = false) {
75
79
  clearCache();
76
80
  }
77
81
 
78
- const configIsForKey = key => config => {
79
- if (config.keys) return config.keys.includes(key);
80
- if (config.pattern) return config.pattern.test(key);
81
- return true;
82
+ var configIsForKey = function configIsForKey(key) {
83
+ return function (config) {
84
+ if (config.keys) return config.keys.includes(key);
85
+ if (config.pattern) return config.pattern.test(key);
86
+ return true;
87
+ };
82
88
  };
83
89
 
84
- global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = key => {
85
- const globalCache = global.__NIGHTINGALE_LOGGER_MAP_CACHE;
86
- const existingCache = globalCache.get(key);
90
+ global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = function (key) {
91
+ var globalCache = global.__NIGHTINGALE_LOGGER_MAP_CACHE;
92
+ var existingCache = globalCache.get(key);
87
93
 
88
94
  if (existingCache) {
89
95
  return existingCache;
90
96
  }
91
97
 
92
- const loggerConfig = {
98
+ var loggerConfig = {
93
99
  handlers: [],
94
100
  processors: []
95
101
  };
96
102
 
97
- global.__NIGHTINGALE_CONFIG.filter(configIsForKey(key)).some(config => {
98
- if (config.handlers) loggerConfig.handlers.push(...config.handlers);
99
- if (config.processors) loggerConfig.processors.push(...config.processors);
103
+ global.__NIGHTINGALE_CONFIG.filter(configIsForKey(key)).some(function (config) {
104
+ var _loggerConfig$handler, _loggerConfig$process;
105
+
106
+ if (config.handlers) (_loggerConfig$handler = loggerConfig.handlers).push.apply(_loggerConfig$handler, config.handlers);
107
+ if (config.processors) (_loggerConfig$process = loggerConfig.processors).push.apply(_loggerConfig$process, config.processors);
100
108
  return config.stop;
101
109
  });
102
110
 
@@ -105,13 +113,15 @@ global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = key => {
105
113
  };
106
114
 
107
115
  if (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
108
- global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (key, level) => {
109
- const _global$__NIGHTINGALE = global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key),
110
- handlers = _global$__NIGHTINGALE.handlers,
111
- processors = _global$__NIGHTINGALE.processors;
116
+ global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = function (key, level) {
117
+ var _global$__NIGHTINGALE = global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key),
118
+ handlers = _global$__NIGHTINGALE.handlers,
119
+ processors = _global$__NIGHTINGALE.processors;
112
120
 
113
121
  return {
114
- handlers: handlers.filter(handler => level >= handler.minLevel && (!handler.isHandling || handler.isHandling(level, key))),
122
+ handlers: handlers.filter(function (handler) {
123
+ return level >= handler.minLevel && (!handler.isHandling || handler.isHandling(level, key));
124
+ }),
115
125
  processors
116
126
  };
117
127
  };
@@ -122,15 +132,23 @@ if (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
122
132
  * @param {Logger} [logger]
123
133
  */
124
134
 
125
- function listenUnhandledErrors(logger = new Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors')) {
126
- process.on('uncaughtException', error => logger.error('uncaughtException', {
127
- error,
128
- unhandled: true
129
- }));
130
- process.on('unhandledRejection', error => logger.error('unhandledRejection', {
131
- error,
132
- unhandled: true
133
- }));
135
+ function listenUnhandledErrors(logger) {
136
+ if (logger === void 0) {
137
+ logger = new Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors');
138
+ }
139
+
140
+ process.on('uncaughtException', function (error) {
141
+ logger.error('uncaughtException', {
142
+ error,
143
+ unhandled: true
144
+ });
145
+ });
146
+ process.on('unhandledRejection', function (error) {
147
+ logger.error('unhandledRejection', {
148
+ error,
149
+ unhandled: true
150
+ });
151
+ });
134
152
  }
135
153
 
136
154
  export { addConfig, configure, listenUnhandledErrors };
@@ -1 +1 @@
1
- {"version":3,"file":"index-browser-dev.es.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import { POB_ENV } from 'pob-babel';\nimport type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler } from 'nightingale-types';\n\nif (POB_ENV !== 'production' && global.__NIGHTINGALE_GLOBAL_HANDLERS) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!global.__NIGHTINGALE_CONFIG) {\n global.__NIGHTINGALE_CONFIG = [];\n global.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n global.__NIGHTINGALE_CONFIG_DEFAULT = { handlers: [], processors: [] };\n}\n\nfunction clearCache(): void {\n global.__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 (global.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n global.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n global.__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\nglobal.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = global.__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 global.__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 (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: number,\n ): ComputedConfigForKey => {\n const {\n handlers,\n processors,\n }: ComputedConfigForKey = global.__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 { Level } from 'nightingale-levels';\nimport { Logger } from 'nightingale-logger';\n\n/** @deprecated use named export instead */\nexport default Logger;\nexport { configure, addConfig } from './config';\nexport { Logger, Level, Level as levels };\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":["global","__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","process","on","error","unhandled"],"mappings":";;;;AAIA,IAAgCA,MAAM,CAACC,6BAAvC,EAAsE;AACpE,QAAM,IAAIC,KAAJ,CAAU,mCAAV,CAAN;AACD;;AAED,IAAI,CAACF,MAAM,CAACG,oBAAZ,EAAkC;AAChCH,EAAAA,MAAM,CAACG,oBAAP,GAA8B,EAA9B;AACAH,EAAAA,MAAM,CAACI,8BAAP,GAAwC,IAAIC,GAAJ,EAAxC;AAIAL,EAAAA,MAAM,CAACM,4BAAP,GAAsC;AAAEC,IAAAA,QAAQ,EAAE,EAAZ;AAAgBC,IAAAA,UAAU,EAAE;AAA5B,GAAtC;AACD;;AAED,SAASC,UAAT,GAA4B;AAC1BT,EAAAA,MAAM,CAACI,8BAAP,CAAsCM,KAAtC;AACD;;AAED,SAASC,YAAT,CAAsBC,MAAtB,EAA8C;AAC5C,MAAIA,MAAM,CAACC,IAAX,EAAiB;AACf,QAAID,MAAM,CAACE,OAAX,EAAoB;AAClB,YAAM,IAAIZ,KAAJ,CAAU,iDAAV,CAAN;AACD;;AACD,QAAIU,MAAM,CAACG,GAAX,EAAgB;AACd,YAAM,IAAIb,KAAJ,CAAU,8CAAV,CAAN;AACD;AACF,GAPD,MAOO,IAAIU,MAAM,CAACG,GAAX,EAAgB;AACrB,QAAIH,MAAM,CAACE,OAAX,EAAoB;AAClB,YAAM,IAAIZ,KAAJ,C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HuB,yBAGvBA,UAHuB;;AAMzB,WAAO;AACLD,MAAAA,QAAQ,EAAEA,QAAQ,CAAC0B,MAAT,CACPjB,OAAD,IACEuB,KAAK,IAAIvB,OAAO,CAACwB,QAAjB,KACC,CAACxB,OAAO,CAACyB,UAAT,IAAuBzB,OAAO,CAACyB,UAAR,CAAmBF,KAAnB,EAA0BxB,GAA1B,CADxB,CAFM,CADL;AAMLP,MAAAA;AANK,KAAP;AAQD,GAjBD;AAkBD;;ACvHD;AACA;AACA;AACA;;AACO,SAASkC,qBAAT,CACLC,MAAc,GAAG,IAAIC,MAAJ,CACf,mCADe,EAEf,iBAFe,CADZ,EAKC;AACNC,EAAAA,OAAO,CAACC,EAAR,CAAW,mBAAX,EAAiCC,KAAD,IAC9BJ,MAAM,CAACI,KAAP,CAAa,mBAAb,EAAkC;AAAEA,IAAAA,KAAF;AAASC,IAAAA,SAAS,EAAE;AAApB,GAAlC,CADF;AAGAH,EAAAA,OAAO,CAACC,EAAR,CAAW,oBAAX,EAAkCC,KAAD,IAC/BJ,MAAM,CAACI,KAAP,CAAa,oBAAb,EAAmC;AAAEA,IAAAA,KAAF;AAASC,IAAAA,SAAS,EAAE;AAApB,GAAnC,CADF;AAGD;;;;"}
1
+ {"version":3,"file":"index-browser-dev.es.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import { POB_ENV } from 'pob-babel';\nimport type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler } from 'nightingale-types';\n\nif (POB_ENV !== 'production' && global.__NIGHTINGALE_GLOBAL_HANDLERS) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!global.__NIGHTINGALE_CONFIG) {\n global.__NIGHTINGALE_CONFIG = [];\n global.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n global.__NIGHTINGALE_CONFIG_DEFAULT = { handlers: [], processors: [] };\n}\n\nfunction clearCache(): void {\n global.__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 (global.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n global.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n global.__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\nglobal.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = global.__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 global.__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 (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: number,\n ): ComputedConfigForKey => {\n const { handlers, processors }: ComputedConfigForKey =\n global.__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 {\n /** @deprecated use named export instead */\n Logger as default,\n Logger,\n} 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":["global","__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","process","on","error","unhandled"],"mappings":";;;;AAIA,IAAgCA,MAAM,CAACC,6BAAvC,EAAsE;AACpE,QAAM,IAAIC,KAAJ,CAAU,mCAAV,CAAN;AACD;;AAED,IAAI,CAACF,MAAM,CAACG,oBAAZ,EAAkC;AAChCH,EAAAA,MAAM,CAACG,oBAAP,GAA8B,EAA9B;AACAH,EAAAA,MAAM,C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CAACC,EAAR,CAAW,mBAAX,EAAgC,UAACC,KAAD,EAAW;AACzCJ,IAAAA,MAAM,CAACI,KAAP,CAAa,mBAAb,EAAkC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAlC;AACD,GAFD;AAGAH,EAAAA,OAAO,CAACC,EAAR,CAAW,oBAAX,EAAiC,UAACC,KAAD,EAAW;AAC1CJ,IAAAA,MAAM,CAACI,KAAP,CAAa,oBAAb,EAAmC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAnC;AACD,GAFD;AAGD;;;;"}
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var nightingaleLevels = require('nightingale-levels');
6
5
  var nightingaleLogger = require('nightingale-logger');
6
+ var nightingaleLevels = require('nightingale-levels');
7
7
 
8
8
  if (!global.__NIGHTINGALE_CONFIG) {
9
9
  global.__NIGHTINGALE_CONFIG = [];
@@ -66,7 +66,11 @@ function configure(config) {
66
66
  clearCache();
67
67
  global.__NIGHTINGALE_CONFIG = config.map(handleConfig);
68
68
  }
69
- function addConfig(config, unshift = false) {
69
+ function addConfig(config, unshift) {
70
+ if (unshift === void 0) {
71
+ unshift = false;
72
+ }
73
+
70
74
  config = handleConfig(config);
71
75
 
72
76
  global.__NIGHTINGALE_CONFIG[unshift ? 'unshift' : 'push'](config);
@@ -74,28 +78,32 @@ function addConfig(config, unshift = false) {
74
78
  clearCache();
75
79
  }
76
80
 
77
- const configIsForKey = key => config => {
78
- if (config.keys) return config.keys.includes(key);
79
- if (config.pattern) return config.pattern.test(key);
80
- return true;
81
+ var configIsForKey = function configIsForKey(key) {
82
+ return function (config) {
83
+ if (config.keys) return config.keys.includes(key);
84
+ if (config.pattern) return config.pattern.test(key);
85
+ return true;
86
+ };
81
87
  };
82
88
 
83
- global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = key => {
84
- const globalCache = global.__NIGHTINGALE_LOGGER_MAP_CACHE;
85
- const existingCache = globalCache.get(key);
89
+ global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = function (key) {
90
+ var globalCache = global.__NIGHTINGALE_LOGGER_MAP_CACHE;
91
+ var existingCache = globalCache.get(key);
86
92
 
87
93
  if (existingCache) {
88
94
  return existingCache;
89
95
  }
90
96
 
91
- const loggerConfig = {
97
+ var loggerConfig = {
92
98
  handlers: [],
93
99
  processors: []
94
100
  };
95
101
 
96
- global.__NIGHTINGALE_CONFIG.filter(configIsForKey(key)).some(config => {
97
- if (config.handlers) loggerConfig.handlers.push(...config.handlers);
98
- if (config.processors) loggerConfig.processors.push(...config.processors);
102
+ global.__NIGHTINGALE_CONFIG.filter(configIsForKey(key)).some(function (config) {
103
+ var _loggerConfig$handler, _loggerConfig$process;
104
+
105
+ if (config.handlers) (_loggerConfig$handler = loggerConfig.handlers).push.apply(_loggerConfig$handler, config.handlers);
106
+ if (config.processors) (_loggerConfig$process = loggerConfig.processors).push.apply(_loggerConfig$process, config.processors);
99
107
  return config.stop;
100
108
  });
101
109
 
@@ -104,13 +112,15 @@ global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = key => {
104
112
  };
105
113
 
106
114
  if (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
107
- global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (key, level) => {
108
- const _global$__NIGHTINGALE = global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key),
109
- handlers = _global$__NIGHTINGALE.handlers,
110
- processors = _global$__NIGHTINGALE.processors;
115
+ global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = function (key, level) {
116
+ var _global$__NIGHTINGALE = global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key),
117
+ handlers = _global$__NIGHTINGALE.handlers,
118
+ processors = _global$__NIGHTINGALE.processors;
111
119
 
112
120
  return {
113
- handlers: handlers.filter(handler => level >= handler.minLevel && (!handler.isHandling || handler.isHandling(level, key))),
121
+ handlers: handlers.filter(function (handler) {
122
+ return level >= handler.minLevel && (!handler.isHandling || handler.isHandling(level, key));
123
+ }),
114
124
  processors
115
125
  };
116
126
  };
@@ -121,21 +131,29 @@ if (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
121
131
  * @param {Logger} [logger]
122
132
  */
123
133
 
124
- function listenUnhandledErrors(logger = new nightingaleLogger.Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors')) {
125
- process.on('uncaughtException', error => logger.error('uncaughtException', {
126
- error,
127
- unhandled: true
128
- }));
129
- process.on('unhandledRejection', error => logger.error('unhandledRejection', {
130
- error,
131
- unhandled: true
132
- }));
134
+ function listenUnhandledErrors(logger) {
135
+ if (logger === void 0) {
136
+ logger = new nightingaleLogger.Logger('nightingale:listenUnhandledErrors', 'UnhandledErrors');
137
+ }
138
+
139
+ process.on('uncaughtException', function (error) {
140
+ logger.error('uncaughtException', {
141
+ error,
142
+ unhandled: true
143
+ });
144
+ });
145
+ process.on('unhandledRejection', function (error) {
146
+ logger.error('unhandledRejection', {
147
+ error,
148
+ unhandled: true
149
+ });
150
+ });
133
151
  }
134
152
 
153
+ exports.Logger = nightingaleLogger.Logger;
154
+ exports["default"] = nightingaleLogger.Logger;
135
155
  exports.Level = nightingaleLevels.Level;
136
156
  exports.levels = nightingaleLevels.Level;
137
- exports.Logger = nightingaleLogger.Logger;
138
- exports.default = nightingaleLogger.Logger;
139
157
  exports.addConfig = addConfig;
140
158
  exports.configure = configure;
141
159
  exports.listenUnhandledErrors = listenUnhandledErrors;
@@ -1 +1 @@
1
- {"version":3,"file":"index-browser.cjs.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import { POB_ENV } from 'pob-babel';\nimport type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler } from 'nightingale-types';\n\nif (POB_ENV !== 'production' && global.__NIGHTINGALE_GLOBAL_HANDLERS) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!global.__NIGHTINGALE_CONFIG) {\n global.__NIGHTINGALE_CONFIG = [];\n global.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n global.__NIGHTINGALE_CONFIG_DEFAULT = { handlers: [], processors: [] };\n}\n\nfunction clearCache(): void {\n global.__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 (global.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n global.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n global.__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\nglobal.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = global.__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 global.__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 (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: number,\n ): ComputedConfigForKey => {\n const {\n handlers,\n processors,\n }: ComputedConfigForKey = global.__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 { Level } from 'nightingale-levels';\nimport { Logger } from 'nightingale-logger';\n\n/** @deprecated use named export instead */\nexport default Logger;\nexport { configure, addConfig } from './config';\nexport { Logger, Level, Level as levels };\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":["global","__NIGHTINGALE_CONFIG","__NIGHTINGALE_LOGGER_MAP_CACHE","Map","__NIGHTINGALE_CONFIG_DEFAULT","handlers","processors","clearCache","clear","handleConfig","config","keys","pattern","Error","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","process","on","error","unhandled"],"mappings":";;;;;;;AAQA,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AkC;AAAEA,IAAAA,KAAF;AAASC,IAAAA,SAAS,EAAE;AAApB,GAAlC,CADF;AAGAH,EAAAA,OAAO,CAACC,EAAR,CAAW,oBAAX,EAAkCC,KAAD,IAC/BJ,MAAM,CAACI,KAAP,CAAa,oBAAb,EAAmC;AAAEA,IAAAA,KAAF;AAASC,IAAAA,SAAS,EAAE;AAApB,GAAnC,CADF;AAGD;;;;;;;;;;"}
1
+ {"version":3,"file":"index-browser.cjs.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import { POB_ENV } from 'pob-babel';\nimport type { ComputedConfigForKey, Config } from 'nightingale-logger';\nimport type { Handler } from 'nightingale-types';\n\nif (POB_ENV !== 'production' && global.__NIGHTINGALE_GLOBAL_HANDLERS) {\n throw new Error('nightingale: update all to ^5.0.0');\n}\n\nif (!global.__NIGHTINGALE_CONFIG) {\n global.__NIGHTINGALE_CONFIG = [];\n global.__NIGHTINGALE_LOGGER_MAP_CACHE = new Map<\n string,\n ComputedConfigForKey\n >();\n global.__NIGHTINGALE_CONFIG_DEFAULT = { handlers: [], processors: [] };\n}\n\nfunction clearCache(): void {\n global.__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 (global.__NIGHTINGALE_CONFIG.length > 0) {\n // eslint-disable-next-line no-console\n console.log('nightingale: warning: config overridden');\n }\n\n clearCache();\n global.__NIGHTINGALE_CONFIG = config.map(handleConfig);\n}\n\nexport function addConfig(config: Config, unshift = false): void {\n config = handleConfig(config);\n global.__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\nglobal.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER = (\n key: string,\n): ComputedConfigForKey => {\n const globalCache = global.__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 global.__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 (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {\n global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD = (\n key: string,\n level: number,\n ): ComputedConfigForKey => {\n const { handlers, processors }: ComputedConfigForKey =\n global.__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 {\n /** @deprecated use named export instead */\n Logger as default,\n Logger,\n} 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":["global","__NIGHTINGALE_CONFIG","__NIGHTINGALE_LOGGER_MAP_CACHE","Map","__NIGHTINGALE_CONFIG_DEFAULT","handlers","processors","clearCache","clear","handleConfig","config","keys","pattern","Error","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","process","on","error","unhandled"],"mappings":";;;;;;;AAQA,IAAI,CAACA,MAAM,CAACC,oBAAZ,EAAkC;AAChCD,EAAAA,MAAM,CAACC,oBAAP,GAA8B,EAA9B;AACAD,EAAAA,MAAM,CAACE,8BAAP,GAAwC,IAAIC,GAAJ,EAAxC;AAIAH,EAAAA,MAAM,CAACI,4BAAP,GAAsC;AAAEC,IAAAA,QAAQ,EAAE,EAAZ;AAAgBC,IAAAA,UAAU,EAAE;AAA5B,GAAtC;AACD;;AAED,SAASC,UAAT,GAA4B;AAC1BP,EAAAA,MAAM,CAACE,8BAAP,CAAsCM,KAAtC;AACD;;AAED,SAASC,YAAT,CAAsBC,MAAtB,EAA8C;AAC5C,MAAIA,MAAM,CAACC,IAAX,EAAiB;AACf,QAAID,MAAM,CAACE,OAAX,EAAoB;AAClB,YAAM,IAAIC,KAAJ,CAAU,iDAAV,CAAN;AACD;;AACD,QAAIH,MAAM,CAACI,GAAX,EAAgB;AACd,YAAM,IAAID,KAAJ,CAAU,8CAAV,CAAN;AACD;AACF,GAPD,MAOO,IAAIH,MAAM,CAACI,GAAX,EAAgB;AACrB,QAAIJ,MAAM,CAACE,OAAX,EAAoB;AAClB,YAAM,IAAIC,KAAJ,CAAU,iDA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