standard-log 8.0.1 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -133
- package/{esm/console/createConsoleLogReporter.d.ts → cjs/console.d.ts} +5 -5
- package/cjs/console.d.ts.map +1 -0
- package/cjs/console.js +74 -0
- package/cjs/console.js.map +1 -0
- package/cjs/console.spec.d.ts +2 -0
- package/cjs/console.spec.d.ts.map +1 -0
- package/cjs/{console/createConsoleLogReporter.spec.js → console.spec.js} +50 -68
- package/cjs/console.spec.js.map +1 -0
- package/cjs/errors.d.ts +0 -10
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js +1 -43
- package/cjs/errors.js.map +1 -1
- package/cjs/formatter.d.ts +6 -0
- package/cjs/formatter.d.ts.map +1 -0
- package/cjs/formatter.js +46 -0
- package/cjs/formatter.js.map +1 -0
- package/cjs/formatter.spec.d.ts +2 -0
- package/cjs/formatter.spec.d.ts.map +1 -0
- package/cjs/formatter.spec.js +32 -0
- package/cjs/formatter.spec.js.map +1 -0
- package/cjs/global.d.ts +13 -0
- package/cjs/global.d.ts.map +1 -0
- package/cjs/global.js +33 -0
- package/cjs/global.js.map +1 -0
- package/cjs/global.spec.d.ts +2 -0
- package/cjs/global.spec.d.ts.map +1 -0
- package/cjs/global.spec.js +32 -0
- package/cjs/global.spec.js.map +1 -0
- package/cjs/index.d.ts +6 -14
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +11 -14
- package/cjs/index.js.map +1 -1
- package/cjs/logLevels.d.ts +60 -0
- package/cjs/logLevels.d.ts.map +1 -0
- package/cjs/logLevels.js +87 -0
- package/cjs/logLevels.js.map +1 -0
- package/cjs/logStore.d.ts +20 -0
- package/cjs/logStore.d.ts.map +1 -0
- package/cjs/logStore.js +44 -0
- package/cjs/logStore.js.map +1 -0
- package/cjs/logStore.spec.d.ts +2 -0
- package/cjs/logStore.spec.d.ts.map +1 -0
- package/cjs/logStore.spec.js +93 -0
- package/cjs/logStore.spec.js.map +1 -0
- package/cjs/logger.d.ts +5 -0
- package/cjs/logger.d.ts.map +1 -0
- package/cjs/logger.js +99 -0
- package/cjs/logger.js.map +1 -0
- package/{esm/memory/MemoryLogReporter.d.ts → cjs/memory.d.ts} +2 -2
- package/cjs/memory.d.ts.map +1 -0
- package/cjs/memory.js +39 -0
- package/cjs/memory.js.map +1 -0
- package/cjs/memory.spec.d.ts +2 -0
- package/cjs/memory.spec.d.ts.map +1 -0
- package/cjs/memory.spec.js +115 -0
- package/cjs/memory.spec.js.map +1 -0
- package/cjs/package.json +1 -3
- package/cjs/platform.browser.d.ts +6 -0
- package/cjs/platform.browser.d.ts.map +1 -0
- package/cjs/platform.browser.js +7 -0
- package/cjs/platform.browser.js.map +1 -0
- package/cjs/platform.d.ts +6 -0
- package/cjs/platform.d.ts.map +1 -0
- package/cjs/platform.js +9 -0
- package/cjs/platform.js.map +1 -0
- package/cjs/standardLog.d.ts +28 -0
- package/cjs/standardLog.d.ts.map +1 -0
- package/cjs/standardLog.js +65 -0
- package/cjs/standardLog.js.map +1 -0
- package/cjs/standardLog.spec.d.ts +2 -0
- package/cjs/standardLog.spec.d.ts.map +1 -0
- package/cjs/standardLog.spec.js +548 -0
- package/cjs/standardLog.spec.js.map +1 -0
- package/cjs/testUtil.d.ts +7 -5
- package/cjs/testUtil.d.ts.map +1 -1
- package/cjs/testUtil.js +11 -14
- package/cjs/testUtil.js.map +1 -1
- package/cjs/types.d.ts +33 -24
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js.map +1 -1
- package/dist/standard-log.es5.js +355 -1071
- package/dist/standard-log.es5.js.gz +0 -0
- package/dist/standard-log.es5.js.map +1 -1
- package/dist/standard-log.es5.js.map.gz +0 -0
- package/dist/standard-log.esm.js +353 -1135
- package/dist/standard-log.esm.js.gz +0 -0
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.esm.js.map.gz +0 -0
- package/{cjs/console/createConsoleLogReporter.d.ts → esm/console.d.ts} +5 -5
- package/esm/console.d.ts.map +1 -0
- package/esm/console.js +62 -0
- package/esm/console.js.map +1 -0
- package/esm/console.spec.d.ts +2 -0
- package/esm/console.spec.d.ts.map +1 -0
- package/esm/{console/createConsoleLogReporter.spec.js → console.spec.js} +50 -65
- package/esm/console.spec.js.map +1 -0
- package/esm/errors.d.ts +0 -10
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js +0 -34
- package/esm/errors.js.map +1 -1
- package/esm/formatter.d.ts +6 -0
- package/esm/formatter.d.ts.map +1 -0
- package/esm/{formatter/createTimestampFormatter.js → formatter.js} +10 -2
- package/esm/formatter.js.map +1 -0
- package/esm/formatter.spec.d.ts +2 -0
- package/esm/formatter.spec.d.ts.map +1 -0
- package/esm/formatter.spec.js +30 -0
- package/esm/formatter.spec.js.map +1 -0
- package/esm/global.d.ts +13 -0
- package/esm/global.d.ts.map +1 -0
- package/esm/global.js +28 -0
- package/esm/global.js.map +1 -0
- package/esm/global.spec.d.ts +2 -0
- package/esm/global.spec.d.ts.map +1 -0
- package/esm/global.spec.js +30 -0
- package/esm/global.spec.js.map +1 -0
- package/esm/index.d.ts +6 -14
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +6 -14
- package/esm/index.js.map +1 -1
- package/esm/logLevels.d.ts +60 -0
- package/esm/logLevels.d.ts.map +1 -0
- package/esm/{logLevel.js → logLevels.js} +29 -3
- package/esm/logLevels.js.map +1 -0
- package/esm/logStore.d.ts +20 -0
- package/esm/logStore.d.ts.map +1 -0
- package/esm/logStore.js +37 -0
- package/esm/logStore.js.map +1 -0
- package/esm/logStore.spec.d.ts +2 -0
- package/esm/logStore.spec.d.ts.map +1 -0
- package/esm/logStore.spec.js +93 -0
- package/esm/logStore.spec.js.map +1 -0
- package/esm/logger.d.ts +5 -0
- package/esm/logger.d.ts.map +1 -0
- package/esm/logger.js +75 -0
- package/esm/logger.js.map +1 -0
- package/{cjs/memory/MemoryLogReporter.d.ts → esm/memory.d.ts} +2 -2
- package/esm/memory.d.ts.map +1 -0
- package/esm/memory.js +34 -0
- package/esm/memory.js.map +1 -0
- package/esm/memory.spec.d.ts +2 -0
- package/esm/memory.spec.d.ts.map +1 -0
- package/esm/memory.spec.js +110 -0
- package/esm/memory.spec.js.map +1 -0
- package/esm/platform.browser.d.ts +6 -0
- package/esm/platform.browser.d.ts.map +1 -0
- package/esm/platform.browser.js +3 -0
- package/esm/platform.browser.js.map +1 -0
- package/esm/platform.d.ts +6 -0
- package/esm/platform.d.ts.map +1 -0
- package/esm/platform.js +5 -0
- package/esm/platform.js.map +1 -0
- package/esm/standardLog.d.ts +28 -0
- package/esm/standardLog.d.ts.map +1 -0
- package/esm/standardLog.js +41 -0
- package/esm/standardLog.js.map +1 -0
- package/esm/standardLog.spec.d.ts +2 -0
- package/esm/standardLog.spec.d.ts.map +1 -0
- package/esm/standardLog.spec.js +446 -0
- package/esm/standardLog.spec.js.map +1 -0
- package/esm/testUtil.d.ts +7 -5
- package/esm/testUtil.d.ts.map +1 -1
- package/esm/testUtil.js +8 -12
- package/esm/testUtil.js.map +1 -1
- package/esm/types.d.ts +33 -24
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/package.json +10 -19
- package/ts/console.ts +70 -0
- package/ts/errors.ts +0 -12
- package/ts/{formatter/createTimestampFormatter.ts → formatter.ts} +12 -1
- package/ts/global.ts +34 -0
- package/ts/index.ts +9 -14
- package/ts/{logLevel.ts → logLevels.ts} +20 -3
- package/ts/logStore.ts +52 -0
- package/ts/logger.ts +85 -0
- package/ts/memory.ts +47 -0
- package/ts/platform.browser.ts +5 -0
- package/ts/platform.ts +8 -0
- package/ts/standardLog.ts +65 -0
- package/ts/types.ts +39 -30
- package/cjs/LogEntry.d.ts +0 -7
- package/cjs/LogEntry.d.ts.map +0 -1
- package/cjs/LogEntry.js +0 -3
- package/cjs/LogEntry.js.map +0 -1
- package/cjs/captureLogs.d.ts +0 -4
- package/cjs/captureLogs.d.ts.map +0 -1
- package/cjs/captureLogs.js +0 -33
- package/cjs/captureLogs.js.map +0 -1
- package/cjs/captureLogs.spec.d.ts +0 -2
- package/cjs/captureLogs.spec.d.ts.map +0 -1
- package/cjs/captureLogs.spec.js +0 -117
- package/cjs/captureLogs.spec.js.map +0 -1
- package/cjs/config.d.ts +0 -12
- package/cjs/config.d.ts.map +0 -1
- package/cjs/config.js +0 -59
- package/cjs/config.js.map +0 -1
- package/cjs/config.spec.d.ts +0 -2
- package/cjs/config.spec.d.ts.map +0 -1
- package/cjs/config.spec.js +0 -72
- package/cjs/config.spec.js.map +0 -1
- package/cjs/configForTest.d.ts +0 -5
- package/cjs/configForTest.d.ts.map +0 -1
- package/cjs/configForTest.js +0 -18
- package/cjs/configForTest.js.map +0 -1
- package/cjs/configForTest.spec.d.ts +0 -2
- package/cjs/configForTest.spec.d.ts.map +0 -1
- package/cjs/configForTest.spec.js +0 -17
- package/cjs/configForTest.spec.js.map +0 -1
- package/cjs/console/createConsoleLogReporter.d.ts.map +0 -1
- package/cjs/console/createConsoleLogReporter.js +0 -42
- package/cjs/console/createConsoleLogReporter.js.map +0 -1
- package/cjs/console/createConsoleLogReporter.spec.d.ts +0 -2
- package/cjs/console/createConsoleLogReporter.spec.d.ts.map +0 -1
- package/cjs/console/createConsoleLogReporter.spec.js.map +0 -1
- package/cjs/console/index.d.ts +0 -4
- package/cjs/console/index.d.ts.map +0 -1
- package/cjs/console/index.js +0 -20
- package/cjs/console/index.js.map +0 -1
- package/cjs/console/isConsoleDebugAvailable.d.ts +0 -2
- package/cjs/console/isConsoleDebugAvailable.d.ts.map +0 -1
- package/cjs/console/isConsoleDebugAvailable.js +0 -20
- package/cjs/console/isConsoleDebugAvailable.js.map +0 -1
- package/cjs/console/polyfilledConsole.d.ts +0 -7
- package/cjs/console/polyfilledConsole.d.ts.map +0 -1
- package/cjs/console/polyfilledConsole.js +0 -41
- package/cjs/console/polyfilledConsole.js.map +0 -1
- package/cjs/console/semverGt.d.ts +0 -2
- package/cjs/console/semverGt.d.ts.map +0 -1
- package/cjs/console/semverGt.js +0 -13
- package/cjs/console/semverGt.js.map +0 -1
- package/cjs/console/semverGt.spec.d.ts +0 -2
- package/cjs/console/semverGt.spec.d.ts.map +0 -1
- package/cjs/console/semverGt.spec.js +0 -22
- package/cjs/console/semverGt.spec.js.map +0 -1
- package/cjs/console/toConsoleMethod.d.ts +0 -2
- package/cjs/console/toConsoleMethod.d.ts.map +0 -1
- package/cjs/console/toConsoleMethod.js +0 -22
- package/cjs/console/toConsoleMethod.js.map +0 -1
- package/cjs/console/types.d.ts +0 -3
- package/cjs/console/types.d.ts.map +0 -1
- package/cjs/console/types.js +0 -3
- package/cjs/console/types.js.map +0 -1
- package/cjs/customLogLevel.d.ts +0 -11
- package/cjs/customLogLevel.d.ts.map +0 -1
- package/cjs/customLogLevel.js +0 -38
- package/cjs/customLogLevel.js.map +0 -1
- package/cjs/customLogLevel.spec.d.ts +0 -2
- package/cjs/customLogLevel.spec.d.ts.map +0 -1
- package/cjs/customLogLevel.spec.js +0 -37
- package/cjs/customLogLevel.spec.js.map +0 -1
- package/cjs/formatter/createTimestampFormatter.d.ts +0 -3
- package/cjs/formatter/createTimestampFormatter.d.ts.map +0 -1
- package/cjs/formatter/createTimestampFormatter.js +0 -26
- package/cjs/formatter/createTimestampFormatter.js.map +0 -1
- package/cjs/formatter/createTimestampFormatter.spec.d.ts +0 -2
- package/cjs/formatter/createTimestampFormatter.spec.d.ts.map +0 -1
- package/cjs/formatter/createTimestampFormatter.spec.js +0 -23
- package/cjs/formatter/createTimestampFormatter.spec.js.map +0 -1
- package/cjs/formatter/formatLogLevel.d.ts +0 -2
- package/cjs/formatter/formatLogLevel.d.ts.map +0 -1
- package/cjs/formatter/formatLogLevel.js +0 -10
- package/cjs/formatter/formatLogLevel.js.map +0 -1
- package/cjs/formatter/index.d.ts +0 -4
- package/cjs/formatter/index.d.ts.map +0 -1
- package/cjs/formatter/index.js +0 -20
- package/cjs/formatter/index.js.map +0 -1
- package/cjs/formatter/plainLogFormatter.d.ts +0 -3
- package/cjs/formatter/plainLogFormatter.d.ts.map +0 -1
- package/cjs/formatter/plainLogFormatter.js +0 -19
- package/cjs/formatter/plainLogFormatter.js.map +0 -1
- package/cjs/formatter/plainLogFormatter.spec.d.ts +0 -2
- package/cjs/formatter/plainLogFormatter.spec.d.ts.map +0 -1
- package/cjs/formatter/plainLogFormatter.spec.js +0 -9
- package/cjs/formatter/plainLogFormatter.spec.js.map +0 -1
- package/cjs/getDefaultReporter.browser.d.ts +0 -2
- package/cjs/getDefaultReporter.browser.d.ts.map +0 -1
- package/cjs/getDefaultReporter.browser.js +0 -15
- package/cjs/getDefaultReporter.browser.js.map +0 -1
- package/cjs/getDefaultReporter.d.ts +0 -2
- package/cjs/getDefaultReporter.d.ts.map +0 -1
- package/cjs/getDefaultReporter.js +0 -19
- package/cjs/getDefaultReporter.js.map +0 -1
- package/cjs/getLogModeFromEnvironment.browser.d.ts +0 -3
- package/cjs/getLogModeFromEnvironment.browser.d.ts.map +0 -1
- package/cjs/getLogModeFromEnvironment.browser.js +0 -9
- package/cjs/getLogModeFromEnvironment.browser.js.map +0 -1
- package/cjs/getLogModeFromEnvironment.d.ts +0 -3
- package/cjs/getLogModeFromEnvironment.d.ts.map +0 -1
- package/cjs/getLogModeFromEnvironment.js +0 -17
- package/cjs/getLogModeFromEnvironment.js.map +0 -1
- package/cjs/getLogModeFromEnvironment.spec.d.ts +0 -2
- package/cjs/getLogModeFromEnvironment.spec.d.ts.map +0 -1
- package/cjs/getLogModeFromEnvironment.spec.js +0 -25
- package/cjs/getLogModeFromEnvironment.spec.js.map +0 -1
- package/cjs/getLogger.d.ts +0 -9
- package/cjs/getLogger.d.ts.map +0 -1
- package/cjs/getLogger.js +0 -103
- package/cjs/getLogger.js.map +0 -1
- package/cjs/getLogger.spec.d.ts +0 -2
- package/cjs/getLogger.spec.d.ts.map +0 -1
- package/cjs/getLogger.spec.js +0 -485
- package/cjs/getLogger.spec.js.map +0 -1
- package/cjs/getLoggers.d.ts +0 -7
- package/cjs/getLoggers.d.ts.map +0 -1
- package/cjs/getLoggers.js +0 -15
- package/cjs/getLoggers.js.map +0 -1
- package/cjs/logLevel.d.ts +0 -106
- package/cjs/logLevel.d.ts.map +0 -1
- package/cjs/logLevel.js +0 -59
- package/cjs/logLevel.js.map +0 -1
- package/cjs/logLevel.spec.d.ts +0 -2
- package/cjs/logLevel.spec.d.ts.map +0 -1
- package/cjs/logLevel.spec.js +0 -195
- package/cjs/logLevel.spec.js.map +0 -1
- package/cjs/logLevelFn.d.ts +0 -20
- package/cjs/logLevelFn.d.ts.map +0 -1
- package/cjs/logLevelFn.js +0 -76
- package/cjs/logLevelFn.js.map +0 -1
- package/cjs/logReporter.d.ts +0 -7
- package/cjs/logReporter.d.ts.map +0 -1
- package/cjs/logReporter.js +0 -29
- package/cjs/logReporter.js.map +0 -1
- package/cjs/logReporter.spec.d.ts +0 -2
- package/cjs/logReporter.spec.d.ts.map +0 -1
- package/cjs/logReporter.spec.js +0 -98
- package/cjs/logReporter.spec.js.map +0 -1
- package/cjs/logReporterInternal.d.ts +0 -3
- package/cjs/logReporterInternal.d.ts.map +0 -1
- package/cjs/logReporterInternal.js +0 -23
- package/cjs/logReporterInternal.js.map +0 -1
- package/cjs/memory/MemoryLogReporter.d.ts.map +0 -1
- package/cjs/memory/MemoryLogReporter.js +0 -56
- package/cjs/memory/MemoryLogReporter.js.map +0 -1
- package/cjs/memory/MemoryLogReporter.spec.d.ts +0 -2
- package/cjs/memory/MemoryLogReporter.spec.d.ts.map +0 -1
- package/cjs/memory/MemoryLogReporter.spec.js +0 -124
- package/cjs/memory/MemoryLogReporter.spec.js.map +0 -1
- package/cjs/memory/index.d.ts +0 -3
- package/cjs/memory/index.d.ts.map +0 -1
- package/cjs/memory/index.js +0 -19
- package/cjs/memory/index.js.map +0 -1
- package/cjs/memory/logEntriesToString.d.ts +0 -3
- package/cjs/memory/logEntriesToString.d.ts.map +0 -1
- package/cjs/memory/logEntriesToString.js +0 -10
- package/cjs/memory/logEntriesToString.js.map +0 -1
- package/cjs/memory/logEntriesToString.spec.d.ts +0 -2
- package/cjs/memory/logEntriesToString.spec.d.ts.map +0 -1
- package/cjs/memory/logEntriesToString.spec.js +0 -36
- package/cjs/memory/logEntriesToString.spec.js.map +0 -1
- package/cjs/memory/toInspectStringForObject.d.ts +0 -3
- package/cjs/memory/toInspectStringForObject.d.ts.map +0 -1
- package/cjs/memory/toInspectStringForObject.js +0 -17
- package/cjs/memory/toInspectStringForObject.js.map +0 -1
- package/cjs/shouldLog.d.ts +0 -8
- package/cjs/shouldLog.d.ts.map +0 -1
- package/cjs/shouldLog.js +0 -14
- package/cjs/shouldLog.js.map +0 -1
- package/cjs/store.d.ts +0 -3
- package/cjs/store.d.ts.map +0 -1
- package/cjs/store.js +0 -27
- package/cjs/store.js.map +0 -1
- package/cjs/suppressLogs.d.ts +0 -6
- package/cjs/suppressLogs.d.ts.map +0 -1
- package/cjs/suppressLogs.js +0 -17
- package/cjs/suppressLogs.js.map +0 -1
- package/cjs/suppressLogs.spec.d.ts +0 -2
- package/cjs/suppressLogs.spec.d.ts.map +0 -1
- package/cjs/suppressLogs.spec.js +0 -31
- package/cjs/suppressLogs.spec.js.map +0 -1
- package/cjs/typesInternal.d.ts +0 -20
- package/cjs/typesInternal.d.ts.map +0 -1
- package/cjs/typesInternal.js +0 -3
- package/cjs/typesInternal.js.map +0 -1
- package/cjs/utils.d.ts +0 -6
- package/cjs/utils.d.ts.map +0 -1
- package/cjs/utils.js +0 -15
- package/cjs/utils.js.map +0 -1
- package/cjs/writeToReporters.d.ts +0 -6
- package/cjs/writeToReporters.d.ts.map +0 -1
- package/cjs/writeToReporters.js +0 -22
- package/cjs/writeToReporters.js.map +0 -1
- package/cjs/writeToReporters.spec.d.ts +0 -2
- package/cjs/writeToReporters.spec.d.ts.map +0 -1
- package/cjs/writeToReporters.spec.js +0 -59
- package/cjs/writeToReporters.spec.js.map +0 -1
- package/esm/LogEntry.d.ts +0 -7
- package/esm/LogEntry.d.ts.map +0 -1
- package/esm/LogEntry.js +0 -2
- package/esm/LogEntry.js.map +0 -1
- package/esm/captureLogs.d.ts +0 -4
- package/esm/captureLogs.d.ts.map +0 -1
- package/esm/captureLogs.js +0 -29
- package/esm/captureLogs.js.map +0 -1
- package/esm/captureLogs.spec.d.ts +0 -2
- package/esm/captureLogs.spec.d.ts.map +0 -1
- package/esm/captureLogs.spec.js +0 -45
- package/esm/captureLogs.spec.js.map +0 -1
- package/esm/config.d.ts +0 -12
- package/esm/config.d.ts.map +0 -1
- package/esm/config.js +0 -44
- package/esm/config.js.map +0 -1
- package/esm/config.spec.d.ts +0 -2
- package/esm/config.spec.d.ts.map +0 -1
- package/esm/config.spec.js +0 -67
- package/esm/config.spec.js.map +0 -1
- package/esm/configForTest.d.ts +0 -5
- package/esm/configForTest.d.ts.map +0 -1
- package/esm/configForTest.js +0 -14
- package/esm/configForTest.js.map +0 -1
- package/esm/configForTest.spec.d.ts +0 -2
- package/esm/configForTest.spec.d.ts.map +0 -1
- package/esm/configForTest.spec.js +0 -15
- package/esm/configForTest.spec.js.map +0 -1
- package/esm/console/createConsoleLogReporter.d.ts.map +0 -1
- package/esm/console/createConsoleLogReporter.js +0 -37
- package/esm/console/createConsoleLogReporter.js.map +0 -1
- package/esm/console/createConsoleLogReporter.spec.d.ts +0 -2
- package/esm/console/createConsoleLogReporter.spec.d.ts.map +0 -1
- package/esm/console/createConsoleLogReporter.spec.js.map +0 -1
- package/esm/console/index.d.ts +0 -4
- package/esm/console/index.d.ts.map +0 -1
- package/esm/console/index.js +0 -4
- package/esm/console/index.js.map +0 -1
- package/esm/console/isConsoleDebugAvailable.d.ts +0 -2
- package/esm/console/isConsoleDebugAvailable.d.ts.map +0 -1
- package/esm/console/isConsoleDebugAvailable.js +0 -13
- package/esm/console/isConsoleDebugAvailable.js.map +0 -1
- package/esm/console/polyfilledConsole.d.ts +0 -7
- package/esm/console/polyfilledConsole.d.ts.map +0 -1
- package/esm/console/polyfilledConsole.js +0 -32
- package/esm/console/polyfilledConsole.js.map +0 -1
- package/esm/console/semverGt.d.ts +0 -2
- package/esm/console/semverGt.d.ts.map +0 -1
- package/esm/console/semverGt.js +0 -9
- package/esm/console/semverGt.js.map +0 -1
- package/esm/console/semverGt.spec.d.ts +0 -2
- package/esm/console/semverGt.spec.d.ts.map +0 -1
- package/esm/console/semverGt.spec.js +0 -20
- package/esm/console/semverGt.spec.js.map +0 -1
- package/esm/console/toConsoleMethod.d.ts +0 -2
- package/esm/console/toConsoleMethod.d.ts.map +0 -1
- package/esm/console/toConsoleMethod.js +0 -18
- package/esm/console/toConsoleMethod.js.map +0 -1
- package/esm/console/types.d.ts +0 -3
- package/esm/console/types.d.ts.map +0 -1
- package/esm/console/types.js +0 -2
- package/esm/console/types.js.map +0 -1
- package/esm/customLogLevel.d.ts +0 -11
- package/esm/customLogLevel.d.ts.map +0 -1
- package/esm/customLogLevel.js +0 -30
- package/esm/customLogLevel.js.map +0 -1
- package/esm/customLogLevel.spec.d.ts +0 -2
- package/esm/customLogLevel.spec.d.ts.map +0 -1
- package/esm/customLogLevel.spec.js +0 -32
- package/esm/customLogLevel.spec.js.map +0 -1
- package/esm/formatter/createTimestampFormatter.d.ts +0 -3
- package/esm/formatter/createTimestampFormatter.d.ts.map +0 -1
- package/esm/formatter/createTimestampFormatter.js.map +0 -1
- package/esm/formatter/createTimestampFormatter.spec.d.ts +0 -2
- package/esm/formatter/createTimestampFormatter.spec.d.ts.map +0 -1
- package/esm/formatter/createTimestampFormatter.spec.js +0 -21
- package/esm/formatter/createTimestampFormatter.spec.js.map +0 -1
- package/esm/formatter/formatLogLevel.d.ts +0 -2
- package/esm/formatter/formatLogLevel.d.ts.map +0 -1
- package/esm/formatter/formatLogLevel.js +0 -6
- package/esm/formatter/formatLogLevel.js.map +0 -1
- package/esm/formatter/index.d.ts +0 -4
- package/esm/formatter/index.d.ts.map +0 -1
- package/esm/formatter/index.js +0 -4
- package/esm/formatter/index.js.map +0 -1
- package/esm/formatter/plainLogFormatter.d.ts +0 -3
- package/esm/formatter/plainLogFormatter.d.ts.map +0 -1
- package/esm/formatter/plainLogFormatter.js +0 -5
- package/esm/formatter/plainLogFormatter.js.map +0 -1
- package/esm/formatter/plainLogFormatter.spec.d.ts +0 -2
- package/esm/formatter/plainLogFormatter.spec.d.ts.map +0 -1
- package/esm/formatter/plainLogFormatter.spec.js +0 -7
- package/esm/formatter/plainLogFormatter.spec.js.map +0 -1
- package/esm/getDefaultReporter.browser.d.ts +0 -2
- package/esm/getDefaultReporter.browser.d.ts.map +0 -1
- package/esm/getDefaultReporter.browser.js +0 -11
- package/esm/getDefaultReporter.browser.js.map +0 -1
- package/esm/getDefaultReporter.d.ts +0 -2
- package/esm/getDefaultReporter.d.ts.map +0 -1
- package/esm/getDefaultReporter.js +0 -15
- package/esm/getDefaultReporter.js.map +0 -1
- package/esm/getLogModeFromEnvironment.browser.d.ts +0 -3
- package/esm/getLogModeFromEnvironment.browser.d.ts.map +0 -1
- package/esm/getLogModeFromEnvironment.browser.js +0 -5
- package/esm/getLogModeFromEnvironment.browser.js.map +0 -1
- package/esm/getLogModeFromEnvironment.d.ts +0 -3
- package/esm/getLogModeFromEnvironment.d.ts.map +0 -1
- package/esm/getLogModeFromEnvironment.js +0 -13
- package/esm/getLogModeFromEnvironment.js.map +0 -1
- package/esm/getLogModeFromEnvironment.spec.d.ts +0 -2
- package/esm/getLogModeFromEnvironment.spec.d.ts.map +0 -1
- package/esm/getLogModeFromEnvironment.spec.js +0 -20
- package/esm/getLogModeFromEnvironment.spec.js.map +0 -1
- package/esm/getLogger.d.ts +0 -9
- package/esm/getLogger.d.ts.map +0 -1
- package/esm/getLogger.js +0 -78
- package/esm/getLogger.js.map +0 -1
- package/esm/getLogger.spec.d.ts +0 -2
- package/esm/getLogger.spec.d.ts.map +0 -1
- package/esm/getLogger.spec.js +0 -385
- package/esm/getLogger.spec.js.map +0 -1
- package/esm/getLoggers.d.ts +0 -7
- package/esm/getLoggers.d.ts.map +0 -1
- package/esm/getLoggers.js +0 -11
- package/esm/getLoggers.js.map +0 -1
- package/esm/logLevel.d.ts +0 -106
- package/esm/logLevel.d.ts.map +0 -1
- package/esm/logLevel.js.map +0 -1
- package/esm/logLevel.spec.d.ts +0 -2
- package/esm/logLevel.spec.d.ts.map +0 -1
- package/esm/logLevel.spec.js +0 -148
- package/esm/logLevel.spec.js.map +0 -1
- package/esm/logLevelFn.d.ts +0 -20
- package/esm/logLevelFn.d.ts.map +0 -1
- package/esm/logLevelFn.js +0 -67
- package/esm/logLevelFn.js.map +0 -1
- package/esm/logReporter.d.ts +0 -7
- package/esm/logReporter.d.ts.map +0 -1
- package/esm/logReporter.js +0 -21
- package/esm/logReporter.js.map +0 -1
- package/esm/logReporter.spec.d.ts +0 -2
- package/esm/logReporter.spec.d.ts.map +0 -1
- package/esm/logReporter.spec.js +0 -93
- package/esm/logReporter.spec.js.map +0 -1
- package/esm/logReporterInternal.d.ts +0 -3
- package/esm/logReporterInternal.d.ts.map +0 -1
- package/esm/logReporterInternal.js +0 -19
- package/esm/logReporterInternal.js.map +0 -1
- package/esm/memory/MemoryLogReporter.d.ts.map +0 -1
- package/esm/memory/MemoryLogReporter.js +0 -51
- package/esm/memory/MemoryLogReporter.js.map +0 -1
- package/esm/memory/MemoryLogReporter.spec.d.ts +0 -2
- package/esm/memory/MemoryLogReporter.spec.d.ts.map +0 -1
- package/esm/memory/MemoryLogReporter.spec.js +0 -111
- package/esm/memory/MemoryLogReporter.spec.js.map +0 -1
- package/esm/memory/index.d.ts +0 -3
- package/esm/memory/index.d.ts.map +0 -1
- package/esm/memory/index.js +0 -3
- package/esm/memory/index.js.map +0 -1
- package/esm/memory/logEntriesToString.d.ts +0 -3
- package/esm/memory/logEntriesToString.d.ts.map +0 -1
- package/esm/memory/logEntriesToString.js +0 -6
- package/esm/memory/logEntriesToString.js.map +0 -1
- package/esm/memory/logEntriesToString.spec.d.ts +0 -2
- package/esm/memory/logEntriesToString.spec.d.ts.map +0 -1
- package/esm/memory/logEntriesToString.spec.js +0 -42
- package/esm/memory/logEntriesToString.spec.js.map +0 -1
- package/esm/memory/toInspectStringForObject.d.ts +0 -3
- package/esm/memory/toInspectStringForObject.d.ts.map +0 -1
- package/esm/memory/toInspectStringForObject.js +0 -11
- package/esm/memory/toInspectStringForObject.js.map +0 -1
- package/esm/shouldLog.d.ts +0 -8
- package/esm/shouldLog.d.ts.map +0 -1
- package/esm/shouldLog.js +0 -10
- package/esm/shouldLog.js.map +0 -1
- package/esm/store.d.ts +0 -3
- package/esm/store.d.ts.map +0 -1
- package/esm/store.js +0 -24
- package/esm/store.js.map +0 -1
- package/esm/suppressLogs.d.ts +0 -6
- package/esm/suppressLogs.d.ts.map +0 -1
- package/esm/suppressLogs.js +0 -9
- package/esm/suppressLogs.js.map +0 -1
- package/esm/suppressLogs.spec.d.ts +0 -2
- package/esm/suppressLogs.spec.d.ts.map +0 -1
- package/esm/suppressLogs.spec.js +0 -29
- package/esm/suppressLogs.spec.js.map +0 -1
- package/esm/typesInternal.d.ts +0 -20
- package/esm/typesInternal.d.ts.map +0 -1
- package/esm/typesInternal.js +0 -2
- package/esm/typesInternal.js.map +0 -1
- package/esm/utils.d.ts +0 -6
- package/esm/utils.d.ts.map +0 -1
- package/esm/utils.js +0 -11
- package/esm/utils.js.map +0 -1
- package/esm/writeToReporters.d.ts +0 -6
- package/esm/writeToReporters.d.ts.map +0 -1
- package/esm/writeToReporters.js +0 -18
- package/esm/writeToReporters.js.map +0 -1
- package/esm/writeToReporters.spec.d.ts +0 -2
- package/esm/writeToReporters.spec.d.ts.map +0 -1
- package/esm/writeToReporters.spec.js +0 -9
- package/esm/writeToReporters.spec.js.map +0 -1
- package/ts/LogEntry.ts +0 -7
- package/ts/captureLogs.ts +0 -35
- package/ts/config.ts +0 -57
- package/ts/configForTest.ts +0 -16
- package/ts/console/createConsoleLogReporter.ts +0 -48
- package/ts/console/index.ts +0 -3
- package/ts/console/isConsoleDebugAvailable.ts +0 -11
- package/ts/console/polyfilledConsole.ts +0 -34
- package/ts/console/semverGt.ts +0 -9
- package/ts/console/toConsoleMethod.ts +0 -18
- package/ts/console/types.ts +0 -3
- package/ts/customLogLevel.ts +0 -35
- package/ts/formatter/formatLogLevel.ts +0 -6
- package/ts/formatter/index.ts +0 -3
- package/ts/formatter/plainLogFormatter.ts +0 -6
- package/ts/getDefaultReporter.browser.ts +0 -13
- package/ts/getDefaultReporter.ts +0 -15
- package/ts/getLogModeFromEnvironment.browser.ts +0 -6
- package/ts/getLogModeFromEnvironment.ts +0 -16
- package/ts/getLogger.ts +0 -92
- package/ts/getLoggers.ts +0 -12
- package/ts/logLevelFn.ts +0 -72
- package/ts/logReporter.ts +0 -26
- package/ts/logReporterInternal.ts +0 -18
- package/ts/memory/MemoryLogReporter.ts +0 -72
- package/ts/memory/index.ts +0 -2
- package/ts/memory/logEntriesToString.ts +0 -7
- package/ts/memory/toInspectStringForObject.ts +0 -13
- package/ts/shouldLog.ts +0 -11
- package/ts/store.ts +0 -25
- package/ts/suppressLogs.ts +0 -14
- package/ts/typesInternal.ts +0 -21
- package/ts/utils.ts +0 -11
- package/ts/writeToReporters.ts +0 -20
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
import { createConsoleLogReporter } from './console/index.js';
|
|
3
|
-
export function getDefaultReporter() {
|
|
4
|
-
try {
|
|
5
|
-
return StandardLogColor.createColorLogReporter();
|
|
6
|
-
}
|
|
7
|
-
catch (e) {
|
|
8
|
-
return createConsoleLogReporter();
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=getDefaultReporter.browser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultReporter.browser.js","sourceRoot":"","sources":["../ts/getDefaultReporter.browser.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAI7D,MAAM,UAAU,kBAAkB;IAChC,IAAI;QACF,OAAO,gBAAgB,CAAC,sBAAsB,EAAE,CAAA;KACjD;IACD,OAAO,CAAC,EAAE;QACR,OAAO,wBAAwB,EAAE,CAAA;KAClC;AACH,CAAC","sourcesContent":["/* istanbul ignore file */\nimport { createConsoleLogReporter } from './console/index.js'\n\ndeclare const StandardLogColor: any\n\nexport function getDefaultReporter() {\n try {\n return StandardLogColor.createColorLogReporter()\n }\n catch (e) {\n return createConsoleLogReporter()\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultReporter.d.ts","sourceRoot":"","sources":["../ts/getDefaultReporter.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,QAYjC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createConsoleLogReporter } from './console/index.js';
|
|
2
|
-
export function getDefaultReporter() {
|
|
3
|
-
try {
|
|
4
|
-
// tricks webpack to not bundle standard-log-color
|
|
5
|
-
const c = '-color';
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
7
|
-
const colorModule = require('standard-log' + c);
|
|
8
|
-
return colorModule.createColorLogReporter();
|
|
9
|
-
}
|
|
10
|
-
catch (e) {
|
|
11
|
-
// istanbul ignore next
|
|
12
|
-
return createConsoleLogReporter();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=getDefaultReporter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultReporter.js","sourceRoot":"","sources":["../ts/getDefaultReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,MAAM,UAAU,kBAAkB;IAChC,IAAI;QACF,kDAAkD;QAClD,MAAM,CAAC,GAAG,QAAQ,CAAA;QAClB,8DAA8D;QAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,GAAG,CAAC,CAAC,CAAA;QAC/C,OAAO,WAAW,CAAC,sBAAsB,EAAE,CAAA;KAC5C;IACD,OAAO,CAAC,EAAE;QACR,uBAAuB;QACvB,OAAO,wBAAwB,EAAE,CAAA;KAClC;AACH,CAAC","sourcesContent":["import { createConsoleLogReporter } from './console/index.js'\n\nexport function getDefaultReporter() {\n try {\n // tricks webpack to not bundle standard-log-color\n const c = '-color'\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const colorModule = require('standard-log' + c)\n return colorModule.createColorLogReporter()\n }\n catch (e) {\n // istanbul ignore next\n return createConsoleLogReporter()\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLogModeFromEnvironment.browser.d.ts","sourceRoot":"","sources":["../ts/getLogModeFromEnvironment.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGpC,wBAAgB,yBAAyB,IAAI,OAAO,GAAG,SAAS,CAE/D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLogModeFromEnvironment.browser.js","sourceRoot":"","sources":["../ts/getLogModeFromEnvironment.browser.ts"],"names":[],"mappings":"AAEA,uBAAuB;AACvB,MAAM,UAAU,yBAAyB;IACvC,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["import { LogMode } from './types.js'\n\n// istanbul ignore next\nexport function getLogModeFromEnvironment(): LogMode | undefined {\n return undefined\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLogModeFromEnvironment.d.ts","sourceRoot":"","sources":["../ts/getLogModeFromEnvironment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAIpC,wBAAgB,yBAAyB,IAAI,OAAO,GAAG,SAAS,CAM/D"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { InvalidEnvVar } from './errors.js';
|
|
2
|
-
const logModeValues = ['production', 'development', 'test'];
|
|
3
|
-
export function getLogModeFromEnvironment() {
|
|
4
|
-
const mode = process.env.STANDARD_LOG;
|
|
5
|
-
if (mode === undefined || isLogMode(mode)) {
|
|
6
|
-
return mode;
|
|
7
|
-
}
|
|
8
|
-
throw new InvalidEnvVar('STANDARD_LOG', mode, logModeValues, { ssf: getLogModeFromEnvironment });
|
|
9
|
-
}
|
|
10
|
-
function isLogMode(mode) {
|
|
11
|
-
return logModeValues.indexOf(mode) !== -1;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=getLogModeFromEnvironment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLogModeFromEnvironment.js","sourceRoot":"","sources":["../ts/getLogModeFromEnvironment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAG3C,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,MAAM,CAAC,CAAA;AAE3D,MAAM,UAAU,yBAAyB;IACvC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAA;IACrC,IAAI,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE;QACzC,OAAO,IAAe,CAAA;KACvB;IACD,MAAM,IAAI,aAAa,CAAC,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,yBAAyB,EAAE,CAAC,CAAA;AAClG,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import { InvalidEnvVar } from './errors.js'\nimport { LogMode } from './types.js'\n\nconst logModeValues = ['production', 'development', 'test']\n\nexport function getLogModeFromEnvironment(): LogMode | undefined {\n const mode = process.env.STANDARD_LOG\n if (mode === undefined || isLogMode(mode)) {\n return mode as LogMode\n }\n throw new InvalidEnvVar('STANDARD_LOG', mode, logModeValues, { ssf: getLogModeFromEnvironment })\n}\n\nfunction isLogMode(mode: string): mode is LogMode {\n return logModeValues.indexOf(mode) !== -1\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLogModeFromEnvironment.spec.d.ts","sourceRoot":"","sources":["../ts/getLogModeFromEnvironment.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import a from 'assertron';
|
|
2
|
-
import { InvalidEnvVar } from './index.js';
|
|
3
|
-
import { getLogModeFromEnvironment } from './getLogModeFromEnvironment.js';
|
|
4
|
-
import { assertSSF } from './testUtil.js';
|
|
5
|
-
test('invalid value throws', () => {
|
|
6
|
-
process.env.STANDARD_LOG = 'unknown';
|
|
7
|
-
a.throws(() => getLogModeFromEnvironment(), InvalidEnvVar);
|
|
8
|
-
});
|
|
9
|
-
it('throws with ssf at call site', () => {
|
|
10
|
-
process.env.STANDARD_LOG = 'unknown';
|
|
11
|
-
const err = a.throws(() => getLogModeFromEnvironment(), InvalidEnvVar);
|
|
12
|
-
assertSSF(err, __filename);
|
|
13
|
-
});
|
|
14
|
-
test('valid values', () => {
|
|
15
|
-
process.env.STANDARD_LOG = 'production';
|
|
16
|
-
expect(getLogModeFromEnvironment()).toBe('production');
|
|
17
|
-
process.env.STANDARD_LOG = 'development';
|
|
18
|
-
expect(getLogModeFromEnvironment()).toBe('development');
|
|
19
|
-
});
|
|
20
|
-
//# sourceMappingURL=getLogModeFromEnvironment.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLogModeFromEnvironment.spec.js","sourceRoot":"","sources":["../ts/getLogModeFromEnvironment.spec.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,WAAW,CAAA;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAChC,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,SAAS,CAAA;IACpC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,yBAAyB,EAAE,EAAE,aAAa,CAAC,CAAA;AAC5D,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;IACtC,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,SAAS,CAAA;IACpC,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,yBAAyB,EAAE,EAAE,aAAa,CAAC,CAAA;IACtE,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;AAC5B,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,YAAY,CAAA;IACvC,MAAM,CAAC,yBAAyB,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAEtD,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,aAAa,CAAA;IACxC,MAAM,CAAC,yBAAyB,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;AACzD,CAAC,CAAC,CAAA","sourcesContent":["import a from 'assertron'\nimport { InvalidEnvVar } from './index.js'\nimport { getLogModeFromEnvironment } from './getLogModeFromEnvironment.js'\nimport { assertSSF } from './testUtil.js'\n\ntest('invalid value throws', () => {\n process.env.STANDARD_LOG = 'unknown'\n a.throws(() => getLogModeFromEnvironment(), InvalidEnvVar)\n})\n\nit('throws with ssf at call site', () => {\n process.env.STANDARD_LOG = 'unknown'\n const err = a.throws(() => getLogModeFromEnvironment(), InvalidEnvVar)\n assertSSF(err, __filename)\n})\n\ntest('valid values', () => {\n process.env.STANDARD_LOG = 'production'\n expect(getLogModeFromEnvironment()).toBe('production')\n\n process.env.STANDARD_LOG = 'development'\n expect(getLogModeFromEnvironment()).toBe('development')\n})\n"]}
|
package/esm/getLogger.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Logger, LogMethodNames, LogReporter, ReporterFilter } from './types.js';
|
|
2
|
-
export declare namespace getLogger {
|
|
3
|
-
type Options = {
|
|
4
|
-
level?: number;
|
|
5
|
-
writeTo?: LogReporter | ReporterFilter;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
export declare function getLogger<T extends string = LogMethodNames>(id: string, options?: getLogger.Options): Logger<T | LogMethodNames>;
|
|
9
|
-
//# sourceMappingURL=getLogger.d.ts.map
|
package/esm/getLogger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLogger.d.ts","sourceRoot":"","sources":["../ts/getLogger.ts"],"names":[],"mappings":"AAMA,OAAO,EAAyB,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAIvG,yBAAiB,SAAS,CAAC;IACzB,KAAY,OAAO,GAAG;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc,CAAA;KACvC,CAAA;CACF;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EACzD,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO,GACtC,MAAM,CAAC,CAAC,GAAG,cAAc,CAAC,CAM5B"}
|
package/esm/getLogger.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { InvalidId } from './errors.js';
|
|
2
|
-
import { logLevels } from './logLevel.js';
|
|
3
|
-
import { getAllLogLevels, toLogLevel, toLogLevelName } from './logLevelFn.js';
|
|
4
|
-
import { addLogReporterInternal } from './logReporterInternal.js';
|
|
5
|
-
import { shouldLog } from './shouldLog.js';
|
|
6
|
-
import { store } from './store.js';
|
|
7
|
-
import { writeToReporters } from './writeToReporters.js';
|
|
8
|
-
export function getLogger(id, options) {
|
|
9
|
-
validateId(id);
|
|
10
|
-
const loggerClosures = store.value.loggerClosures;
|
|
11
|
-
const loggerClosure = loggerClosures[id] ||
|
|
12
|
-
(loggerClosures[id] = createLoggerClosure(id, options));
|
|
13
|
-
return loggerClosure.logger;
|
|
14
|
-
}
|
|
15
|
-
function validateId(id) {
|
|
16
|
-
if (/[`~!#$%^&*()=+[\]{},|<>?]/.test(id))
|
|
17
|
-
throw new InvalidId(id, { ssf: getLogger });
|
|
18
|
-
}
|
|
19
|
-
function createLoggerClosure(id, { level, writeTo = () => true } = {}) {
|
|
20
|
-
const filter = typeof writeTo === 'string'
|
|
21
|
-
? id => id === writeTo
|
|
22
|
-
: writeTo instanceof RegExp
|
|
23
|
-
? id => writeTo.test(id)
|
|
24
|
-
: typeof writeTo === 'function'
|
|
25
|
-
? writeTo
|
|
26
|
-
: (addLogReporterInternal(writeTo), id => id === writeTo.id);
|
|
27
|
-
function write(entry) {
|
|
28
|
-
writeToReporters(entry, filter);
|
|
29
|
-
}
|
|
30
|
-
const logger = {
|
|
31
|
-
level,
|
|
32
|
-
write
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperties(logger, {
|
|
35
|
-
id: { value: id, writable: false },
|
|
36
|
-
count: {
|
|
37
|
-
writable: false,
|
|
38
|
-
value: ((counter) => (...args) => {
|
|
39
|
-
const level = logLevels.debug;
|
|
40
|
-
if (shouldLog(level, logger.level))
|
|
41
|
-
write({
|
|
42
|
-
id,
|
|
43
|
-
level,
|
|
44
|
-
args: [++counter, ...args],
|
|
45
|
-
timestamp: new Date()
|
|
46
|
-
});
|
|
47
|
-
})(0)
|
|
48
|
-
},
|
|
49
|
-
on: {
|
|
50
|
-
writable: false,
|
|
51
|
-
value: (level, logFn) => {
|
|
52
|
-
const logLevel = typeof level === 'string' ? toLogLevel(level) : level;
|
|
53
|
-
if (shouldLog(logLevel, logger.level)) {
|
|
54
|
-
const methodName = toLogLevelName(logLevel);
|
|
55
|
-
const bindedMethod = logger[methodName].bind(logger);
|
|
56
|
-
const result = logFn(bindedMethod);
|
|
57
|
-
if (result)
|
|
58
|
-
bindedMethod(result);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
const loggerClosure = {
|
|
64
|
-
addMethod(name, level) {
|
|
65
|
-
Object.defineProperty(logger, name, {
|
|
66
|
-
writable: false,
|
|
67
|
-
value: (...args) => {
|
|
68
|
-
if (shouldLog(level, logger.level))
|
|
69
|
-
write({ id, level, args, timestamp: new Date() });
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
logger
|
|
74
|
-
};
|
|
75
|
-
getAllLogLevels().forEach(({ name, level }) => loggerClosure.addMethod(name, level));
|
|
76
|
-
return loggerClosure;
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=getLogger.js.map
|
package/esm/getLogger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLogger.js","sourceRoot":"","sources":["../ts/getLogger.ts"],"names":[],"mappings":"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","sourcesContent":["import { InvalidId } from './errors.js'\nimport { logLevels } from './logLevel.js'\nimport { getAllLogLevels, toLogLevel, toLogLevelName } from './logLevelFn.js'\nimport { addLogReporterInternal } from './logReporterInternal.js'\nimport { shouldLog } from './shouldLog.js'\nimport { store } from './store.js'\nimport { LogEntry, LogFunction, Logger, LogMethodNames, LogReporter, ReporterFilter } from './types.js'\nimport { LoggerClosure } from './typesInternal.js'\nimport { writeToReporters } from './writeToReporters.js'\n\nexport namespace getLogger {\n export type Options = {\n level?: number,\n writeTo?: LogReporter | ReporterFilter\n }\n}\n\nexport function getLogger<T extends string = LogMethodNames>(\n id: string, options?: getLogger.Options\n): Logger<T | LogMethodNames> {\n validateId(id)\n const loggerClosures = store.value.loggerClosures\n const loggerClosure: any = loggerClosures[id] ||\n (loggerClosures[id] = createLoggerClosure<T | LogMethodNames>(id, options))\n return loggerClosure.logger\n}\n\nfunction validateId(id: string) {\n if (/[`~!#$%^&*()=+[\\]{},|<>?]/.test(id)) throw new InvalidId(id, { ssf: getLogger })\n}\n\nfunction createLoggerClosure<T extends string>(id: string, { level, writeTo = () => true }: getLogger.Options = {}): LoggerClosure<T> {\n const filter: (reporterId: string) => boolean = typeof writeTo === 'string'\n ? id => id === writeTo\n : writeTo instanceof RegExp\n ? id => writeTo.test(id)\n : typeof writeTo === 'function'\n ? writeTo\n : (addLogReporterInternal(writeTo), id => id === writeTo.id)\n\n function write(entry: LogEntry) {\n writeToReporters(entry, filter)\n }\n const logger = {\n level,\n write\n } as any\n\n Object.defineProperties(logger, {\n id: { value: id, writable: false },\n count: {\n writable: false,\n value: ((counter) => (...args: any[]) => {\n const level = logLevels.debug\n if (shouldLog(level, logger.level))\n write({\n id,\n level,\n args: [++counter, ...args],\n timestamp: new Date()\n })\n })(0)\n },\n on: {\n writable: false,\n value: (level: number | T, logFn: LogFunction) => {\n const logLevel = typeof level === 'string' ? toLogLevel(level)! : level\n if (shouldLog(logLevel, logger.level)) {\n const methodName = toLogLevelName(logLevel)\n const bindedMethod = logger[methodName].bind(logger)\n const result = logFn(bindedMethod)\n if (result) bindedMethod(result)\n }\n }\n }\n })\n const loggerClosure: LoggerClosure<T> = {\n addMethod(name, level) {\n Object.defineProperty(logger, name, {\n writable: false,\n value: (...args: any[]) => {\n if (shouldLog(level, logger.level)) write({ id, level, args, timestamp: new Date() })\n }\n })\n },\n logger\n }\n\n getAllLogLevels().forEach(({ name, level }) => loggerClosure.addMethod(name, level))\n\n return loggerClosure\n}\n"]}
|
package/esm/getLogger.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLogger.spec.d.ts","sourceRoot":"","sources":["../ts/getLogger.spec.ts"],"names":[],"mappings":""}
|
package/esm/getLogger.spec.js
DELETED
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import a from 'assertron';
|
|
2
|
-
import delay from 'delay';
|
|
3
|
-
import { addCustomLogLevel, clearCustomLogLevel, getLogger, InvalidId, logLevels, setLogLevel, toLogLevel, toLogLevelName } from './index.js';
|
|
4
|
-
import { config } from './config.js';
|
|
5
|
-
import { createMemoryLogReporter } from './memory/index.js';
|
|
6
|
-
import { store } from './store.js';
|
|
7
|
-
import { assertSSF, captureWrittenLog } from './testUtil.js';
|
|
8
|
-
afterEach(() => {
|
|
9
|
-
clearCustomLogLevel();
|
|
10
|
-
store.reset();
|
|
11
|
-
});
|
|
12
|
-
test('logger id supports alphanumeric and :_-.', () => {
|
|
13
|
-
getLogger('abcdefghijklmnopqrstuvwxyz:-_.1234567890');
|
|
14
|
-
});
|
|
15
|
-
test('logger id supports unicode', () => {
|
|
16
|
-
getLogger('ミク香港');
|
|
17
|
-
});
|
|
18
|
-
test('logger id supports @, \\ and /', () => {
|
|
19
|
-
getLogger('@unional/fixture');
|
|
20
|
-
getLogger(`a\\b\\c`);
|
|
21
|
-
});
|
|
22
|
-
test.each('`~!#$%^&*()=+|[]{}<>,?'.split(''))('throws if id has unsupported character %s', (char) => {
|
|
23
|
-
a.throws(() => getLogger(char), InvalidId);
|
|
24
|
-
});
|
|
25
|
-
it('throw InvalidId with ssf to the call site', () => {
|
|
26
|
-
const err = a.throws(() => getLogger('!'), InvalidId);
|
|
27
|
-
assertSSF(err, __filename);
|
|
28
|
-
});
|
|
29
|
-
test('get logger with same name gets the same instance', () => {
|
|
30
|
-
const expected = getLogger('same-inst');
|
|
31
|
-
const actual = getLogger('same-inst');
|
|
32
|
-
expect(actual).toBe(expected);
|
|
33
|
-
});
|
|
34
|
-
test('can specify local log level', () => {
|
|
35
|
-
const log = getLogger('local', { level: logLevels.trace });
|
|
36
|
-
expect(log.level).toBe(logLevels.trace);
|
|
37
|
-
});
|
|
38
|
-
test('new logger will get custom level', () => {
|
|
39
|
-
addCustomLogLevel('to_logger', 1234);
|
|
40
|
-
const actual = getLogger('to_logger_logger');
|
|
41
|
-
expect(typeof actual.to_logger).toBe('function');
|
|
42
|
-
});
|
|
43
|
-
test('existing logger will get custom level', () => {
|
|
44
|
-
const actual = getLogger('old_logger');
|
|
45
|
-
addCustomLogLevel('old_logger', 122);
|
|
46
|
-
expect(typeof actual.old_logger).toBe('function');
|
|
47
|
-
});
|
|
48
|
-
describe('validate write to reporters', () => {
|
|
49
|
-
let capture;
|
|
50
|
-
beforeEach(() => {
|
|
51
|
-
store.value.mode = 'test';
|
|
52
|
-
store.value.logLevel = logLevels.debug;
|
|
53
|
-
capture = captureWrittenLog();
|
|
54
|
-
});
|
|
55
|
-
afterEach(() => {
|
|
56
|
-
capture.reset();
|
|
57
|
-
});
|
|
58
|
-
test('logger with custom level', async () => {
|
|
59
|
-
addCustomLogLevel('cust_lvl', 100);
|
|
60
|
-
const logger = getLogger('cust');
|
|
61
|
-
logger.cust_lvl('a', 'b');
|
|
62
|
-
a.satisfies(capture.logs, [{ id: 'cust', level: 100, args: ['a', 'b'] }]);
|
|
63
|
-
});
|
|
64
|
-
describe('count()', () => {
|
|
65
|
-
test('will increment the counter', async () => {
|
|
66
|
-
const logger = getLogger('inc counter');
|
|
67
|
-
logger.count();
|
|
68
|
-
logger.count();
|
|
69
|
-
a.satisfies(capture.logs, [
|
|
70
|
-
{ id: 'inc counter', level: logLevels.debug, args: [1] },
|
|
71
|
-
{ id: 'inc counter', level: logLevels.debug, args: [2] }
|
|
72
|
-
]);
|
|
73
|
-
});
|
|
74
|
-
test('append args after the counter', async () => {
|
|
75
|
-
store.value.logLevel = logLevels.debug;
|
|
76
|
-
const id = 'inc with args';
|
|
77
|
-
const logger = getLogger(id);
|
|
78
|
-
logger.count('msg1', 'msg2');
|
|
79
|
-
a.satisfies(capture.logs, [
|
|
80
|
-
{ id, level: logLevels.debug, args: [1, 'msg1', 'msg2'] }
|
|
81
|
-
]);
|
|
82
|
-
});
|
|
83
|
-
test('not log if log level is less than debug', async () => {
|
|
84
|
-
store.value.logLevel = logLevels.debug - 1;
|
|
85
|
-
const id = 'inc with args';
|
|
86
|
-
const logger = getLogger(id);
|
|
87
|
-
logger.count('msg1', 'msg2');
|
|
88
|
-
expect(capture.logs.length).toBe(0);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
describe('log level tests', () => {
|
|
92
|
-
beforeEach(() => {
|
|
93
|
-
store.value.mode = 'test';
|
|
94
|
-
store.value.logLevel = logLevels.error;
|
|
95
|
-
});
|
|
96
|
-
afterEach(() => {
|
|
97
|
-
store.reset();
|
|
98
|
-
});
|
|
99
|
-
async function assertLoggedAtLevel(log, level) {
|
|
100
|
-
setLogLevel(level);
|
|
101
|
-
const msg = `should log on level: ${level}`;
|
|
102
|
-
log[log.id](msg);
|
|
103
|
-
a.satisfies(capture.logs, [{ id: log.id, level: toLogLevel(log.id), args: [msg] }]);
|
|
104
|
-
}
|
|
105
|
-
async function assertNotLoggedAtLevel(log, level) {
|
|
106
|
-
setLogLevel(level);
|
|
107
|
-
log[log.id](`should not log on level: ${level}`);
|
|
108
|
-
expect(capture.logs.length).toBe(0);
|
|
109
|
-
}
|
|
110
|
-
async function assertLoggedAtLocalLevel(log, globalLevel, localLevel) {
|
|
111
|
-
setLogLevel(globalLevel);
|
|
112
|
-
log.level = localLevel;
|
|
113
|
-
const msg = `should log on level: ${localLevel}`;
|
|
114
|
-
log[log.id](msg);
|
|
115
|
-
a.satisfies(capture.logs, [{ id: log.id, level: toLogLevel(log.id), args: [msg] }]);
|
|
116
|
-
}
|
|
117
|
-
async function assertNotLoggedAtLocalLevel(log, globalLevel, localLevel) {
|
|
118
|
-
setLogLevel(globalLevel);
|
|
119
|
-
log.level = localLevel;
|
|
120
|
-
log[log.id](`should not log on level: ${localLevel}`);
|
|
121
|
-
expect(capture.logs.length).toBe(0);
|
|
122
|
-
}
|
|
123
|
-
async function assertLogFunctionCalledAtLevel(log, callLevel, actualLevel) {
|
|
124
|
-
setLogLevel(actualLevel);
|
|
125
|
-
let actual = false;
|
|
126
|
-
log.on(callLevel, () => actual = true);
|
|
127
|
-
expect(actual).toBe(true);
|
|
128
|
-
}
|
|
129
|
-
async function assertLogFunctionCalledAtLocalLevel(log, callLevel, globalLevel, localLevel) {
|
|
130
|
-
setLogLevel(globalLevel);
|
|
131
|
-
log.level = localLevel;
|
|
132
|
-
let actual = false;
|
|
133
|
-
log.on(callLevel, () => actual = true);
|
|
134
|
-
expect(actual).toBe(true);
|
|
135
|
-
}
|
|
136
|
-
function assertLogFunctionNotCalledAtLevel(log, callLevel, actualLevel) {
|
|
137
|
-
setLogLevel(actualLevel);
|
|
138
|
-
log.on(callLevel, () => { throw new Error(`should not log at level ${actualLevel}`); });
|
|
139
|
-
}
|
|
140
|
-
function assertLogFunctionNotCalledAtLocalLevel(log, callLevel, globalLevel, localLevel) {
|
|
141
|
-
setLogLevel(globalLevel);
|
|
142
|
-
log.level = localLevel;
|
|
143
|
-
log.on(callLevel, () => { throw new Error(`should not log at local level ${localLevel}`); });
|
|
144
|
-
}
|
|
145
|
-
const shouldLog = wrapTest((test) => (method, level) => {
|
|
146
|
-
const name = toLogLevelName(level);
|
|
147
|
-
test(`${method}() should log on level: ${name} (${level})`, () => {
|
|
148
|
-
const log = getLogger(method);
|
|
149
|
-
return assertLoggedAtLevel(log, level);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
const shouldNotLog = wrapTest((test) => (method, level) => {
|
|
153
|
-
const name = toLogLevelName(level);
|
|
154
|
-
test(`${method}() should not log on level: ${name} (${level})`, () => {
|
|
155
|
-
const log = getLogger(method);
|
|
156
|
-
return assertNotLoggedAtLevel(log, level);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
const shouldLogWithLocalLevelOverride = wrapTest((test) => (method, localLevel) => {
|
|
160
|
-
const localName = toLogLevelName(localLevel);
|
|
161
|
-
[logLevels.none, logLevels.error, logLevels.warn, logLevels.info, logLevels.debug].forEach(globalLevel => {
|
|
162
|
-
const globalName = toLogLevelName(globalLevel) || 'none';
|
|
163
|
-
test(`${method}() should log on local level: ${localName} (${localLevel}) while global level: ${globalName} (${globalLevel})`, () => {
|
|
164
|
-
const log = getLogger(method);
|
|
165
|
-
return assertLoggedAtLocalLevel(log, globalLevel, localLevel);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
const shouldNotLogWithLocalLevelOverride = wrapTest((test) => (method, localLevel) => {
|
|
170
|
-
const localName = toLogLevelName(localLevel);
|
|
171
|
-
[logLevels.none, logLevels.error, logLevels.warn, logLevels.info, logLevels.debug].forEach(globalLevel => {
|
|
172
|
-
const globalName = toLogLevelName(globalLevel) || 'none';
|
|
173
|
-
test(`${method}() should not log on local level: ${localName} (${localLevel}) while global level: ${globalName} (${globalLevel})`, () => {
|
|
174
|
-
const log = getLogger(method);
|
|
175
|
-
return assertNotLoggedAtLocalLevel(log, globalLevel, localLevel);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
const shouldCallLogFunction = wrapTest((test) => (callLevel, actualLevel) => {
|
|
180
|
-
const method = toLogLevelName(callLevel);
|
|
181
|
-
const name = toLogLevelName(actualLevel);
|
|
182
|
-
test(`${method}() should call log function on level: ${name} (${actualLevel})`, () => {
|
|
183
|
-
const log = getLogger(method);
|
|
184
|
-
return assertLogFunctionCalledAtLevel(log, callLevel, actualLevel);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
const shouldNotCallLogFunction = wrapTest((test) => (callLevel, actualLevel) => {
|
|
188
|
-
const method = toLogLevelName(callLevel);
|
|
189
|
-
const name = toLogLevelName(actualLevel);
|
|
190
|
-
test(`${method}() should not call log function on level: ${name} (${actualLevel})`, () => {
|
|
191
|
-
const log = getLogger(method);
|
|
192
|
-
assertLogFunctionNotCalledAtLevel(log, callLevel, actualLevel);
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
const shouldCallLogFunctionWithLocalLevelOverride = wrapTest((test) => (callLevel, localLevel) => {
|
|
196
|
-
const method = toLogLevelName(callLevel);
|
|
197
|
-
const localName = toLogLevelName(localLevel);
|
|
198
|
-
[logLevels.none, logLevels.error, logLevels.warn, logLevels.info, logLevels.debug].forEach(globalLevel => {
|
|
199
|
-
const globalName = toLogLevelName(globalLevel) || 'none';
|
|
200
|
-
test(`${method}() should log on local level: ${localName} (${localLevel}) while global level: ${globalName} (${globalLevel})`, () => {
|
|
201
|
-
const log = getLogger(method);
|
|
202
|
-
return assertLogFunctionCalledAtLocalLevel(log, callLevel, globalLevel, localLevel);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
const shouldNotCallLogFunctionWithLocalLevelOverride = wrapTest((test) => (callLevel, localLevel) => {
|
|
207
|
-
const method = toLogLevelName(callLevel);
|
|
208
|
-
const localName = toLogLevelName(localLevel);
|
|
209
|
-
[logLevels.none, logLevels.error, logLevels.warn, logLevels.info, logLevels.debug].forEach(globalLevel => {
|
|
210
|
-
const globalName = toLogLevelName(globalLevel) || 'none';
|
|
211
|
-
test(`${method}() should not log on local level: ${localName} (${localLevel}) while global level: ${globalName} (${globalLevel})`, () => {
|
|
212
|
-
const log = getLogger(method);
|
|
213
|
-
assertLogFunctionNotCalledAtLocalLevel(log, callLevel, globalLevel, localLevel);
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
function wrapTest(fn) {
|
|
218
|
-
return Object.assign(fn(test), { only: fn(test.only), skip: fn(test.skip) });
|
|
219
|
-
}
|
|
220
|
-
shouldNotLog('error', logLevels.none);
|
|
221
|
-
shouldLog('error', logLevels.error);
|
|
222
|
-
shouldLog('error', logLevels.warn);
|
|
223
|
-
shouldLog('error', logLevels.info);
|
|
224
|
-
shouldLog('error', logLevels.debug);
|
|
225
|
-
shouldNotLogWithLocalLevelOverride('error', logLevels.none);
|
|
226
|
-
shouldLogWithLocalLevelOverride('error', logLevels.error);
|
|
227
|
-
shouldLogWithLocalLevelOverride('error', logLevels.warn);
|
|
228
|
-
shouldLogWithLocalLevelOverride('error', logLevels.info);
|
|
229
|
-
shouldLogWithLocalLevelOverride('error', logLevels.debug);
|
|
230
|
-
shouldNotLog('warn', logLevels.none);
|
|
231
|
-
shouldNotLog('warn', logLevels.error);
|
|
232
|
-
shouldLog('warn', logLevels.warn);
|
|
233
|
-
shouldLog('warn', logLevels.info);
|
|
234
|
-
shouldLog('warn', logLevels.debug);
|
|
235
|
-
shouldNotLogWithLocalLevelOverride('warn', logLevels.none);
|
|
236
|
-
shouldNotLogWithLocalLevelOverride('warn', logLevels.error);
|
|
237
|
-
shouldLogWithLocalLevelOverride('warn', logLevels.warn);
|
|
238
|
-
shouldLogWithLocalLevelOverride('warn', logLevels.info);
|
|
239
|
-
shouldLogWithLocalLevelOverride('warn', logLevels.debug);
|
|
240
|
-
shouldNotLog('info', logLevels.none);
|
|
241
|
-
shouldNotLog('info', logLevels.error);
|
|
242
|
-
shouldNotLog('info', logLevels.warn);
|
|
243
|
-
shouldLog('info', logLevels.info);
|
|
244
|
-
shouldLog('info', logLevels.debug);
|
|
245
|
-
shouldNotLogWithLocalLevelOverride('info', logLevels.none);
|
|
246
|
-
shouldNotLogWithLocalLevelOverride('info', logLevels.error);
|
|
247
|
-
shouldNotLogWithLocalLevelOverride('info', logLevels.warn);
|
|
248
|
-
shouldLogWithLocalLevelOverride('info', logLevels.info);
|
|
249
|
-
shouldLogWithLocalLevelOverride('info', logLevels.debug);
|
|
250
|
-
shouldNotLog('debug', logLevels.none);
|
|
251
|
-
shouldNotLog('debug', logLevels.error);
|
|
252
|
-
shouldNotLog('debug', logLevels.warn);
|
|
253
|
-
shouldNotLog('debug', logLevels.info);
|
|
254
|
-
shouldLog('debug', logLevels.debug);
|
|
255
|
-
shouldNotLogWithLocalLevelOverride('debug', logLevels.none);
|
|
256
|
-
shouldNotLogWithLocalLevelOverride('debug', logLevels.error);
|
|
257
|
-
shouldNotLogWithLocalLevelOverride('debug', logLevels.warn);
|
|
258
|
-
shouldNotLogWithLocalLevelOverride('debug', logLevels.info);
|
|
259
|
-
shouldLogWithLocalLevelOverride('debug', logLevels.debug);
|
|
260
|
-
shouldNotCallLogFunction(logLevels.error, logLevels.none);
|
|
261
|
-
shouldCallLogFunction(logLevels.error, logLevels.error);
|
|
262
|
-
shouldCallLogFunction(logLevels.error, logLevels.warn);
|
|
263
|
-
shouldCallLogFunction(logLevels.error, logLevels.info);
|
|
264
|
-
shouldCallLogFunction(logLevels.error, logLevels.debug);
|
|
265
|
-
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels.error, logLevels.none);
|
|
266
|
-
shouldCallLogFunctionWithLocalLevelOverride(logLevels.error, logLevels.error);
|
|
267
|
-
shouldCallLogFunctionWithLocalLevelOverride(logLevels.error, logLevels.warn);
|
|
268
|
-
shouldCallLogFunctionWithLocalLevelOverride(logLevels.error, logLevels.info);
|
|
269
|
-
shouldCallLogFunctionWithLocalLevelOverride(logLevels.error, logLevels.debug);
|
|
270
|
-
shouldNotCallLogFunction(logLevels.warn, logLevels.none);
|
|
271
|
-
shouldNotCallLogFunction(logLevels.warn, logLevels.error);
|
|
272
|
-
shouldCallLogFunction(logLevels.warn, logLevels.warn);
|
|
273
|
-
shouldCallLogFunction(logLevels.warn, logLevels.info);
|
|
274
|
-
shouldCallLogFunction(logLevels.warn, logLevels.debug);
|
|
275
|
-
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels.warn, logLevels.none);
|
|
276
|
-
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels.warn, logLevels.error);
|
|
277
|
-
shouldCallLogFunctionWithLocalLevelOverride(logLevels.warn, logLevels.warn);
|
|
278
|
-
shouldCallLogFunctionWithLocalLevelOverride(logLevels.warn, logLevels.info);
|
|
279
|
-
shouldCallLogFunctionWithLocalLevelOverride(logLevels.warn, logLevels.debug);
|
|
280
|
-
shouldNotCallLogFunction(logLevels.info, logLevels.none);
|
|
281
|
-
shouldNotCallLogFunction(logLevels.info, logLevels.error);
|
|
282
|
-
shouldNotCallLogFunction(logLevels.info, logLevels.warn);
|
|
283
|
-
shouldCallLogFunction(logLevels.info, logLevels.info);
|
|
284
|
-
shouldCallLogFunction(logLevels.info, logLevels.debug);
|
|
285
|
-
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels.info, logLevels.none);
|
|
286
|
-
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels.info, logLevels.error);
|
|
287
|
-
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels.info, logLevels.warn);
|
|
288
|
-
shouldCallLogFunctionWithLocalLevelOverride(logLevels.info, logLevels.info);
|
|
289
|
-
shouldCallLogFunctionWithLocalLevelOverride(logLevels.info, logLevels.debug);
|
|
290
|
-
shouldNotCallLogFunction(logLevels.debug, logLevels.none);
|
|
291
|
-
shouldNotCallLogFunction(logLevels.debug, logLevels.error);
|
|
292
|
-
shouldNotCallLogFunction(logLevels.debug, logLevels.warn);
|
|
293
|
-
shouldNotCallLogFunction(logLevels.debug, logLevels.info);
|
|
294
|
-
shouldCallLogFunction(logLevels.debug, logLevels.debug);
|
|
295
|
-
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels.debug, logLevels.none);
|
|
296
|
-
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels.debug, logLevels.error);
|
|
297
|
-
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels.debug, logLevels.warn);
|
|
298
|
-
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels.debug, logLevels.info);
|
|
299
|
-
shouldCallLogFunctionWithLocalLevelOverride(logLevels.debug, logLevels.debug);
|
|
300
|
-
});
|
|
301
|
-
test('on() log using log argument', () => {
|
|
302
|
-
store.value.mode = 'test';
|
|
303
|
-
store.value.logLevel = logLevels.debug;
|
|
304
|
-
const logger = getLogger('log on fn');
|
|
305
|
-
logger.on('error', log => { log('value'); });
|
|
306
|
-
a.satisfies(capture.logs, [
|
|
307
|
-
{ id: 'log on fn', level: logLevels.error, args: ['value'] }
|
|
308
|
-
]);
|
|
309
|
-
});
|
|
310
|
-
test('write entry directly', () => {
|
|
311
|
-
const log = getLogger('write-entry');
|
|
312
|
-
const entry = { id: 'write-entry', level: logLevels.info, args: ['abc'], timestamp: new Date() };
|
|
313
|
-
log.write(entry);
|
|
314
|
-
a.satisfies(capture.logs, [entry]);
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
test('on() can take log level name in first argument', () => {
|
|
318
|
-
const log = getLogger('string-on');
|
|
319
|
-
log.on('debug', () => { return; });
|
|
320
|
-
});
|
|
321
|
-
test('auto configure', async () => {
|
|
322
|
-
expect(store.value.configured).toBeFalsy();
|
|
323
|
-
const log = getLogger('auto config');
|
|
324
|
-
log.info('config is called automatically as expected');
|
|
325
|
-
await delay(10);
|
|
326
|
-
expect(store.value.configured).toBeTruthy();
|
|
327
|
-
});
|
|
328
|
-
describe('writeTo', () => {
|
|
329
|
-
let memReporter;
|
|
330
|
-
let specialReporter;
|
|
331
|
-
beforeEach(() => {
|
|
332
|
-
memReporter = createMemoryLogReporter();
|
|
333
|
-
specialReporter = createMemoryLogReporter({ id: 'special' });
|
|
334
|
-
config({ mode: 'test', reporters: [memReporter, specialReporter] });
|
|
335
|
-
});
|
|
336
|
-
test('specific reporter with string', () => {
|
|
337
|
-
const log = getLogger('writeTo-string', { writeTo: 'special' });
|
|
338
|
-
log.error('error message');
|
|
339
|
-
expect(memReporter.logs.length).toEqual(0);
|
|
340
|
-
expect(specialReporter.logs.length).toEqual(1);
|
|
341
|
-
});
|
|
342
|
-
test('specific reporter with regex', () => {
|
|
343
|
-
const log = getLogger('writeTo-regex', { writeTo: /^spec/ });
|
|
344
|
-
log.error('error message');
|
|
345
|
-
expect(memReporter.logs.length).toEqual(0);
|
|
346
|
-
expect(specialReporter.logs.length).toEqual(1);
|
|
347
|
-
});
|
|
348
|
-
test('specific reporter with RegExp', () => {
|
|
349
|
-
const log = getLogger('writeTo-RegExp', { writeTo: new RegExp('^spec') });
|
|
350
|
-
log.error('error message');
|
|
351
|
-
expect(memReporter.logs.length).toEqual(0);
|
|
352
|
-
expect(specialReporter.logs.length).toEqual(1);
|
|
353
|
-
});
|
|
354
|
-
test('specific reporter with function', () => {
|
|
355
|
-
const log = getLogger('writeTo-fn', { writeTo: id => id === 'special' });
|
|
356
|
-
log.error('error message');
|
|
357
|
-
expect(memReporter.logs.length).toEqual(0);
|
|
358
|
-
expect(specialReporter.logs.length).toEqual(1);
|
|
359
|
-
});
|
|
360
|
-
test('custom reporter', () => {
|
|
361
|
-
const reporter = createMemoryLogReporter({ id: 'custom mem' });
|
|
362
|
-
const log = getLogger('writeTo-reporter', { writeTo: reporter });
|
|
363
|
-
log.error('error message');
|
|
364
|
-
expect(reporter.logs.length).toEqual(1);
|
|
365
|
-
});
|
|
366
|
-
test('custom reporter cannot override added console reporter', () => {
|
|
367
|
-
// if not, it would be a security issue as the new reporter
|
|
368
|
-
// can capture the logs from other logger and send it elsewhere
|
|
369
|
-
const reporter = createMemoryLogReporter({ id: 'custom mem' });
|
|
370
|
-
reporter.isConsoleReporter = true;
|
|
371
|
-
getLogger('writeTo-reporter-no-override', { writeTo: reporter });
|
|
372
|
-
const log = getLogger('writeTo-reporter-no-override-2');
|
|
373
|
-
log.error('error message');
|
|
374
|
-
expect(reporter.logs.length).toEqual(0);
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
test('id is readonly', () => {
|
|
378
|
-
const log = getLogger('id is readonly');
|
|
379
|
-
a.throws(() => log.id = 'b');
|
|
380
|
-
});
|
|
381
|
-
test.each(['on', 'count', 'error', 'warn', 'info', 'debug'])('method %s is readonly', name => {
|
|
382
|
-
const log = getLogger(`${name} is readonly`);
|
|
383
|
-
a.throws(() => log[name] = true);
|
|
384
|
-
});
|
|
385
|
-
//# sourceMappingURL=getLogger.spec.js.map
|