nightingale 11.5.2 → 11.7.2
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 +1 -1
- package/CHANGELOG.md +38 -0
- package/babel.config.cjs +14 -0
- package/dist/index-browser-dev.cjs.js +1 -1
- package/dist/index-browser-dev.cjs.js.map +1 -1
- package/dist/index-browser-dev.es.js.map +1 -1
- package/dist/index-browser.cjs.js +1 -1
- package/dist/index-browser.cjs.js.map +1 -1
- package/dist/index-browser.es.js.map +1 -1
- package/dist/index-browsermodern-dev.es.js.map +1 -1
- package/dist/index-browsermodern.es.js.map +1 -1
- package/dist/index-node12-dev.cjs.js +1 -1
- package/dist/index-node12-dev.cjs.js.map +1 -1
- package/dist/index-node12-dev.mjs.map +1 -1
- package/dist/index-node12.cjs.js +1 -1
- package/dist/index-node12.cjs.js.map +1 -1
- package/dist/index-node12.mjs.map +1 -1
- package/package.json +26 -34
- package/rollup.config.mjs +3 -0
- package/src/.eslintrc.json +1 -1
- package/src/config.ts +2 -4
- package/src/index.test.ts +1 -1
- package/src/index.ts +12 -10
- package/index.js +0 -6
package/.eslintrc.json
CHANGED
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.2](https://github.com/christophehurpeau/nightingale/compare/v11.7.1...v11.7.2) (2021-11-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package nightingale
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [11.7.1](https://github.com/christophehurpeau/nightingale/compare/v11.7.0...v11.7.1) (2021-06-29)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* update pob-babel to bring back webpack 4 support ([4887431](https://github.com/christophehurpeau/nightingale/commit/4887431b3b272496511f879af022638723b9056e))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [11.7.0](https://github.com/christophehurpeau/nightingale/compare/v11.6.0...v11.7.0) (2021-03-29)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package nightingale
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [11.6.0](https://github.com/christophehurpeau/nightingale/compare/v11.5.4...v11.6.0) (2021-03-21)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* update dependencies and browserlist config ([81d2340](https://github.com/christophehurpeau/nightingale/commit/81d234069412c746ebc99faed778092790f332ca))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
## [11.5.2](https://github.com/christophehurpeau/nightingale/compare/v11.5.1...v11.5.2) (2021-02-14)
|
|
7
45
|
|
|
8
46
|
**Note:** Version bump only for package nightingale
|
package/babel.config.cjs
ADDED
|
@@ -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
|
+
};
|
|
@@ -157,7 +157,7 @@ function listenUnhandledErrors(logger) {
|
|
|
157
157
|
exports.Level = nightingaleLevels.Level;
|
|
158
158
|
exports.levels = nightingaleLevels.Level;
|
|
159
159
|
exports.Logger = nightingaleLogger.Logger;
|
|
160
|
-
exports
|
|
160
|
+
exports["default"] = nightingaleLogger.Logger;
|
|
161
161
|
exports.addConfig = addConfig;
|
|
162
162
|
exports.configure = configure;
|
|
163
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 {
|
|
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 { 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,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kC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAlC,CAD8B;AAAA,GAAhC;AAGAH,EAAAA,OAAO,CAACC,EAAR,CAAW,oBAAX,EAAiC,UAACC,KAAD;AAAA,WAC/BJ,MAAM,CAACI,KAAP,CAAa,oBAAb,EAAmC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAnC,CAD+B;AAAA,GAAjC;AAGD;;;;;;;;;;"}
|
|
@@ -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 {
|
|
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 { 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,IA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A,MAIM;AAJNA,IAAAA,MAIM,GAJW,IAAIC,MAAJ,CACf,mCADe,EAEf,iBAFe,CAIX;AAAA;;AACNC,EAAAA,OAAO,CAACC,EAAR,CAAW,mBAAX,EAAgC,UAACC,KAAD;AAAA,WAC9BJ,MAAM,CAACI,KAAP,CAAa,mBAAb,EAAkC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAlC,CAD8B;AAAA,GAAhC;AAGAH,EAAAA,OAAO,CAACC,EAAR,CAAW,oBAAX,EAAiC,UAACC,KAAD;AAAA,WAC/BJ,MAAM,CAACI,KAAP,CAAa,oBAAb,EAAmC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAnC,CAD+B;AAAA,GAAjC;AAGD;;;;"}
|
|
@@ -153,7 +153,7 @@ function listenUnhandledErrors(logger) {
|
|
|
153
153
|
exports.Level = nightingaleLevels.Level;
|
|
154
154
|
exports.levels = nightingaleLevels.Level;
|
|
155
155
|
exports.Logger = nightingaleLogger.Logger;
|
|
156
|
-
exports
|
|
156
|
+
exports["default"] = nightingaleLogger.Logger;
|
|
157
157
|
exports.addConfig = addConfig;
|
|
158
158
|
exports.configure = configure;
|
|
159
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 {
|
|
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 { 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,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,iDAAV,CAAN;AACD;;AACDH,IAAAA,MAAM,CAACC,IAAP,GAAc,CAACD,MAAM,CAACI,GAAR,CAAd;AACA,WAAOJ,MAAM,CAACI,GAAd;AACD;;AAED,MA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AAlB;;AAGA,WAAO;AACLD,MAAAA,QAAQ,EAAEA,QAAQ,CAAC2B,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;AAMLR,MAAAA;AANK,KAAP;AAQD,GAfD;AAgBD;;ACrHD;AACA;AACA;AACA;;AACO,SAASmC,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;AAAA,WAC9BJ,MAAM,CAACI,KAAP,CAAa,mBAAb,EAAkC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAlC,CAD8B;AAAA,GAAhC;AAGAH,EAAAA,OAAO,CAACC,EAAR,CAAW,oBAAX,EAAiC,UAACC,KAAD;AAAA,WAC/BJ,MAAM,CAACI,KAAP,CAAa,oBAAb,EAAmC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAnC,CAD+B;AAAA,GAAjC;AAGD;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-browser.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 {
|
|
1
|
+
{"version":3,"file":"index-browser.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 { 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,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,iDAAV,CAAN;AACD;;AACDH,IAAAA,MAAM,CAACC,IAAP,GAAc,CAACD,M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;AAAA,QAAQT,QAAR,yBAAQA,QAAR;AAAA,QAAkBC,UAAlB,yBAAkBA,UAAlB;;AAGA,WAAO;AACLD,MAAAA,QAAQ,EAAEA,QAAQ,CAAC2B,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;AAMLR,MAAAA;AANK,KAAP;AAQD,GAfD;AAgBD;;ACrHD;AACA;AACA;AACA;;AACO,SAASmC,qBAAT,CACLC,MADK,EAKC;AAAA,MAJNA,MAIM;AAJNA,IAAAA,MAIM,GAJW,IAAIC,MAAJ,CACf,mCADe,EAEf,iBAFe,CAIX;AAAA;;AACNC,EAAAA,OAAO,CAACC,EAAR,CAAW,mBAAX,EAAgC,UAACC,KAAD;AAAA,WAC9BJ,MAAM,CAACI,KAAP,CAAa,mBAAb,EAAkC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAlC,CAD8B;AAAA,GAAhC;AAGAH,EAAAA,OAAO,CAACC,EAAR,CAAW,oBAAX,EAAiC,UAACC,KAAD;AAAA,WAC/BJ,MAAM,CAACI,KAAP,CAAa,oBAAb,EAAmC;AAAEA,MAAAA,KAAF;AAASC,MAAAA,SAAS,EAAE;AAApB,KAAnC,CAD+B;AAAA,GAAjC;AAGD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-browsermodern-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 {
|
|
1
|
+
{"version":3,"file":"index-browsermodern-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 { 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,8CAA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,KAFkD,KAGzB;AACzB,UAAM;AAAEhC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QACJR,MAAM,CAAC4B,mCAAP,CAA2Cb,GAA3C,CADF;;AAGA,WAAO;AACLR,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,GAfD;AAgBD;;ACrHD;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-browsermodern.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 {
|
|
1
|
+
{"version":3,"file":"index-browsermodern.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 { 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,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,iDAAV,CAAN;AACD;;AACDH,IAAAA,MAAM,CAACC,IAAP,GAAc,CAACD,MAAM,CA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,IAAIvB,OAAO,CAACwB,QAAjB,KACC,CAACxB,OAAO,CAACyB,UAAT,IAAuBzB,OAAO,CAACyB,UAAR,CAAmBF,KAAnB,EAA0BxB,GAA1B,CADxB,CAFM,CADL;AAMLR,MAAAA;AANK,KAAP;AAQD,GAfD;AAgBD;;ACrHD;AACA;AACA;AACA;;AACO,SAASmC,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;;;;"}
|
|
@@ -140,7 +140,7 @@ function listenUnhandledErrors(logger = new nightingaleLogger.Logger('nightingal
|
|
|
140
140
|
exports.Level = nightingaleLevels.Level;
|
|
141
141
|
exports.levels = nightingaleLevels.Level;
|
|
142
142
|
exports.Logger = nightingaleLogger.Logger;
|
|
143
|
-
exports
|
|
143
|
+
exports["default"] = nightingaleLogger.Logger;
|
|
144
144
|
exports.addConfig = addConfig;
|
|
145
145
|
exports.configure = configure;
|
|
146
146
|
exports.listenUnhandledErrors = listenUnhandledErrors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-node12-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 {
|
|
1
|
+
{"version":3,"file":"index-node12-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 { 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,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CAACsC,0CAAP,GAAoD,CAClDvB,GADkD,EAElDwB,KAFkD,KAGzB;AACzB,UAAM;AAAEhC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QACJR,MAAM,CAAC4B,mCAAP,CAA2Cb,GAA3C,CADF;;AAGA,WAAO;AACLR,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,GAfD;AAgBD;;ACrHD;AACA;AACA;AACA;;AACO,SAASkC,qBAAT,CACLC,MAAc,GAAG,IAAIC,wBAAJ,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-node12-dev.mjs","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 {
|
|
1
|
+
{"version":3,"file":"index-node12-dev.mjs","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 { 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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AAEhC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QACJR,MAAM,CAAC4B,mCAAP,CAA2Cb,GAA3C,CADF;;AAGA,WAAO;AACLR,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,GAfD;AAgBD;;ACrHD;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;;;;"}
|
package/dist/index-node12.cjs.js
CHANGED
|
@@ -136,7 +136,7 @@ function listenUnhandledErrors(logger = new nightingaleLogger.Logger('nightingal
|
|
|
136
136
|
exports.Level = nightingaleLevels.Level;
|
|
137
137
|
exports.levels = nightingaleLevels.Level;
|
|
138
138
|
exports.Logger = nightingaleLogger.Logger;
|
|
139
|
-
exports
|
|
139
|
+
exports["default"] = nightingaleLogger.Logger;
|
|
140
140
|
exports.addConfig = addConfig;
|
|
141
141
|
exports.configure = configure;
|
|
142
142
|
exports.listenUnhandledErrors = listenUnhandledErrors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-node12.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 {
|
|
1
|
+
{"version":3,"file":"index-node12.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 { 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,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,Y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1BD;;AA4BA,IAAI/B,MAAM,CAACqC,0CAAX,EAAuD;AACrDrC,EAAAA,MAAM,CAACqC,0CAAP,GAAoD,CAClDvB,GADkD,EAElDwB,KAFkD,KAGzB;AACzB,UAAM;AAAEjC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QACJN,MAAM,CAAC2B,mCAAP,CAA2Cb,GAA3C,CADF;;AAGA,WAAO;AACLT,MAAAA,QAAQ,EAAEA,QAAQ,CAAC2B,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;AAMLR,MAAAA;AANK,KAAP;AAQD,GAfD;AAgBD;;ACrHD;AACA;AACA;AACA;;AACO,SAASmC,qBAAT,CACLC,MAAc,GAAG,IAAIC,wBAAJ,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-node12.mjs","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 {
|
|
1
|
+
{"version":3,"file":"index-node12.mjs","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 { 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,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,O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CAAP,CAA2Cb,GAA3C,CADF;;AAGA,WAAO;AACLT,MAAAA,QAAQ,EAAEA,QAAQ,CAAC2B,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;AAMLR,MAAAA;AANK,KAAP;AAQD,GAfD;AAgBD;;ACrHD;AACA;AACA;AACA;;AACO,SAASmC,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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nightingale",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.7.2",
|
|
4
4
|
"description": "Logger for browser and node",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logger"
|
|
@@ -13,21 +13,23 @@
|
|
|
13
13
|
"directory": "packages/nightingale"
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/christophehurpeau/nightingale",
|
|
16
|
+
"type": "commonjs",
|
|
16
17
|
"engines": {
|
|
17
|
-
"node": "
|
|
18
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
18
19
|
},
|
|
19
20
|
"browserslist": [
|
|
21
|
+
"defaults",
|
|
20
22
|
"> 0.2%",
|
|
21
|
-
"Firefox ESR",
|
|
22
23
|
"not ie < 12",
|
|
23
|
-
"not
|
|
24
|
-
"not
|
|
24
|
+
"not safari < 10",
|
|
25
|
+
"not ios_saf < 10"
|
|
25
26
|
],
|
|
26
|
-
"main": "./index.js",
|
|
27
|
+
"main": "./dist/index-node12.cjs.js",
|
|
27
28
|
"types": "./dist/index.d.ts",
|
|
28
29
|
"module": "./dist/index-browser.es.js",
|
|
29
30
|
"browser": "./dist/index-browser.es.js",
|
|
30
31
|
"exports": {
|
|
32
|
+
"./package.json": "./package.json",
|
|
31
33
|
".": {
|
|
32
34
|
"node": {
|
|
33
35
|
"development": {
|
|
@@ -63,12 +65,12 @@
|
|
|
63
65
|
"scripts": {
|
|
64
66
|
"build": "pob-build && yarn run build:definitions",
|
|
65
67
|
"build:definitions": "tsc -p tsconfig.build.json",
|
|
66
|
-
"clean": "rm -Rf
|
|
68
|
+
"clean": "rm -Rf dist",
|
|
67
69
|
"generate:test-coverage": "rm -Rf docs/coverage/ ; NODE_ENV=production BABEL_ENV=test jest --coverage --coverageReporters=pob-lcov-reporter --coverageDirectory=docs/coverage/",
|
|
68
70
|
"lint": "yarn run lint:eslint",
|
|
69
|
-
"lint:eslint": "
|
|
71
|
+
"lint:eslint": "cd ../.. && yarn run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/nightingale",
|
|
70
72
|
"test": "jest",
|
|
71
|
-
"test:watch": "jest",
|
|
73
|
+
"test:watch": "jest --watch",
|
|
72
74
|
"watch": "pob-watch"
|
|
73
75
|
},
|
|
74
76
|
"prettier": {
|
|
@@ -126,34 +128,24 @@
|
|
|
126
128
|
},
|
|
127
129
|
"dependencies": {
|
|
128
130
|
"@types/node": ">=12.0.0",
|
|
129
|
-
"nightingale-levels": "^11.
|
|
130
|
-
"nightingale-logger": "^11.
|
|
131
|
-
"nightingale-types": "^11.
|
|
131
|
+
"nightingale-levels": "^11.7.2",
|
|
132
|
+
"nightingale-logger": "^11.7.2",
|
|
133
|
+
"nightingale-types": "^11.7.2"
|
|
132
134
|
},
|
|
133
135
|
"devDependencies": {
|
|
134
|
-
"@babel/core": "7.
|
|
135
|
-
"@babel/preset-env": "7.
|
|
136
|
-
"@
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"@types/jest": "26.0.20",
|
|
140
|
-
"@typescript-eslint/eslint-plugin": "4.15.0",
|
|
141
|
-
"@typescript-eslint/parser": "4.15.0",
|
|
142
|
-
"babel-jest": "26.6.3",
|
|
143
|
-
"babel-preset-latest-node": "5.4.0",
|
|
136
|
+
"@babel/core": "7.16.0",
|
|
137
|
+
"@babel/preset-env": "7.16.4",
|
|
138
|
+
"@types/jest": "27.0.3",
|
|
139
|
+
"babel-jest": "27.3.1",
|
|
140
|
+
"babel-preset-latest-node": "5.5.1",
|
|
144
141
|
"babel-preset-modern-browsers": "15.0.2",
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"nightingale-string": "^11.5.2",
|
|
152
|
-
"pob-babel": "26.5.0",
|
|
153
|
-
"pob-lcov-reporter": "4.0.1",
|
|
154
|
-
"rollup": "2.39.0",
|
|
155
|
-
"typescript": "4.1.5",
|
|
142
|
+
"jest": "27.3.1",
|
|
143
|
+
"nightingale-string": "^11.7.2",
|
|
144
|
+
"pob-babel": "28.5.0",
|
|
145
|
+
"pob-lcov-reporter": "5.4.0",
|
|
146
|
+
"rollup": "2.60.1",
|
|
147
|
+
"typescript": "4.5.2",
|
|
156
148
|
"xunit-file": "1.0.0"
|
|
157
149
|
},
|
|
158
|
-
"gitHead": "
|
|
150
|
+
"gitHead": "00b1ec6c7468b320e268a12eaac70d59a177787b"
|
|
159
151
|
}
|
package/src/.eslintrc.json
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"overrides": [
|
|
11
11
|
{
|
|
12
12
|
"files": ["**/*.test.ts", "__tests__/**/*.ts"],
|
|
13
|
+
"extends": ["@pob/eslint-config-typescript/test"],
|
|
13
14
|
"env": {
|
|
14
15
|
"jest": true
|
|
15
16
|
},
|
|
16
|
-
"extends": ["@pob/eslint-config-typescript/test"],
|
|
17
17
|
"rules": {
|
|
18
18
|
"import/no-extraneous-dependencies": [
|
|
19
19
|
"error",
|
package/src/config.ts
CHANGED
|
@@ -111,10 +111,8 @@ if (global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER_RECORD) {
|
|
|
111
111
|
key: string,
|
|
112
112
|
level: number,
|
|
113
113
|
): ComputedConfigForKey => {
|
|
114
|
-
const {
|
|
115
|
-
|
|
116
|
-
processors,
|
|
117
|
-
}: ComputedConfigForKey = global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key);
|
|
114
|
+
const { handlers, processors }: ComputedConfigForKey =
|
|
115
|
+
global.__NIGHTINGALE_GET_CONFIG_FOR_LOGGER(key);
|
|
118
116
|
|
|
119
117
|
return {
|
|
120
118
|
handlers: handlers.filter(
|
package/src/index.test.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Level } from 'nightingale-levels';
|
|
2
1
|
import { Logger } from 'nightingale-logger';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
export
|
|
3
|
+
export {
|
|
4
|
+
/** @deprecated use named export instead */
|
|
5
|
+
Logger as default,
|
|
6
|
+
Logger,
|
|
7
|
+
} from 'nightingale-logger';
|
|
8
|
+
export { Level, Level as levels } from 'nightingale-levels';
|
|
6
9
|
export { configure, addConfig } from './config';
|
|
7
|
-
export { Logger, Level, Level as levels };
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* listen to uncaughtException and unhandledRejection
|
|
@@ -16,10 +18,10 @@ export function listenUnhandledErrors(
|
|
|
16
18
|
'UnhandledErrors',
|
|
17
19
|
),
|
|
18
20
|
): void {
|
|
19
|
-
process.on('uncaughtException', (error) =>
|
|
20
|
-
logger.error('uncaughtException', { error, unhandled: true })
|
|
21
|
-
);
|
|
22
|
-
process.on('unhandledRejection', (error) =>
|
|
23
|
-
logger.error('unhandledRejection', { error, unhandled: true })
|
|
24
|
-
);
|
|
21
|
+
process.on('uncaughtException', (error) => {
|
|
22
|
+
logger.error('uncaughtException', { error, unhandled: true });
|
|
23
|
+
});
|
|
24
|
+
process.on('unhandledRejection', (error) => {
|
|
25
|
+
logger.error('unhandledRejection', { error, unhandled: true });
|
|
26
|
+
});
|
|
25
27
|
}
|