standard-log 8.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +76 -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 -55
- package/cjs/console.spec.js.map +1 -0
- package/cjs/errors.d.ts +1 -11
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js +3 -45
- 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/index.d.ts +5 -14
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +5 -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 +6 -0
- package/cjs/logger.d.ts.map +1 -0
- package/cjs/logger.js +97 -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 +7 -0
- package/cjs/platform.browser.d.ts.map +1 -0
- package/cjs/platform.browser.js +11 -0
- package/cjs/platform.browser.js.map +1 -0
- package/cjs/platform.d.ts +8 -0
- package/cjs/platform.d.ts.map +1 -0
- package/cjs/platform.js +26 -0
- package/cjs/platform.js.map +1 -0
- package/cjs/platform.spec.d.ts +2 -0
- package/cjs/platform.spec.d.ts.map +1 -0
- package/cjs/platform.spec.js +22 -0
- package/cjs/platform.spec.js.map +1 -0
- package/cjs/standardLog.d.ts +21 -0
- package/cjs/standardLog.d.ts.map +1 -0
- package/cjs/standardLog.js +59 -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 -4
- package/cjs/testUtil.d.ts.map +1 -1
- package/cjs/testUtil.js +16 -13
- 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 +326 -1079
- 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 +309 -1146
- 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/polyfilledConsole.js → console.js} +36 -4
- 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 -52
- package/esm/console.spec.js.map +1 -0
- package/esm/errors.d.ts +1 -11
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js +2 -36
- 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/index.d.ts +5 -14
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +5 -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 +6 -0
- package/esm/logger.d.ts.map +1 -0
- package/esm/logger.js +74 -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 +7 -0
- package/esm/platform.browser.d.ts.map +1 -0
- package/esm/platform.browser.js +6 -0
- package/esm/platform.browser.js.map +1 -0
- package/esm/platform.d.ts +8 -0
- package/esm/platform.d.ts.map +1 -0
- package/esm/platform.js +20 -0
- package/esm/platform.js.map +1 -0
- package/esm/platform.spec.d.ts +2 -0
- package/esm/platform.spec.d.ts.map +1 -0
- package/esm/{console/semverGt.spec.js → platform.spec.js} +2 -2
- package/esm/platform.spec.js.map +1 -0
- package/esm/standardLog.d.ts +21 -0
- package/esm/standardLog.d.ts.map +1 -0
- package/esm/standardLog.js +36 -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 -4
- package/esm/testUtil.d.ts.map +1 -1
- package/esm/testUtil.js +11 -11
- 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 +12 -20
- package/ts/console.ts +72 -0
- package/ts/errors.ts +2 -14
- package/ts/{formatter/createTimestampFormatter.ts → formatter.ts} +12 -1
- package/ts/index.ts +5 -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 +8 -0
- package/ts/platform.ts +25 -0
- package/ts/standardLog.ts +54 -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 -66
- 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 -19
- 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 -481
- 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 -86
- 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 -111
- 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 -5
- package/cjs/utils.d.ts.map +0 -1
- package/cjs/utils.js +0 -14
- 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 -61
- 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.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.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 -14
- 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 -381
- 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 -81
- 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 -98
- 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 -5
- package/esm/utils.d.ts.map +0 -1
- package/esm/utils.js +0 -10
- 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 -42
- 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 -66
- 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/testUtil.ts +0 -19
- package/ts/typesInternal.ts +0 -21
- package/ts/utils.ts +0 -9
- package/ts/writeToReporters.ts +0 -20
package/cjs/typesInternal.js
DELETED
package/cjs/typesInternal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typesInternal.js","sourceRoot":"","sources":["../ts/typesInternal.ts"],"names":[],"mappings":"","sourcesContent":["import { Logger, LogLevel, LogLevelListener, LogMode, LogReporter } from './types.js'\n\nexport type LoggerClosure<T extends string> = {\n addMethod(name: string, level: number): void,\n logger: Logger<T>\n}\n\nexport type LogStore = {\n mode: LogMode,\n logLevel: LogLevel,\n loggerClosures: Record<string, LoggerClosure<any>>,\n /**\n * redirects logger to specific reporter.\n */\n redirects: Record<string, LogReporter[]>,\n reporters: LogReporter[],\n customLevels: Record<string, number>,\n customLevelsReverse: string[],\n addCustomLogLevelListeners: LogLevelListener[],\n configured: boolean\n}\n"]}
|
package/cjs/utils.d.ts
DELETED
package/cjs/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../ts/utils.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,QAE1D"}
|
package/cjs/utils.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertLogModeIsNotProduction = void 0;
|
|
4
|
-
var errors_js_1 = require("./errors.js");
|
|
5
|
-
var store_js_1 = require("./store.js");
|
|
6
|
-
/**
|
|
7
|
-
* Helper function to assert the system is not in production mode.
|
|
8
|
-
*/
|
|
9
|
-
function assertLogModeIsNotProduction(action) {
|
|
10
|
-
if (store_js_1.store.value.mode === 'production')
|
|
11
|
-
throw new errors_js_1.ProhibitedDuringProduction(action);
|
|
12
|
-
}
|
|
13
|
-
exports.assertLogModeIsNotProduction = assertLogModeIsNotProduction;
|
|
14
|
-
//# sourceMappingURL=utils.js.map
|
package/cjs/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../ts/utils.ts"],"names":[],"mappings":";;;AAAA,yCAAwD;AACxD,uCAAkC;AAElC;;GAEG;AACH,SAAgB,4BAA4B,CAAC,MAAc;IACzD,IAAI,gBAAK,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY;QAAE,MAAM,IAAI,sCAA0B,CAAC,MAAM,CAAC,CAAA;AACrF,CAAC;AAFD,oEAEC","sourcesContent":["import { ProhibitedDuringProduction } from './errors.js'\nimport { store } from './store.js'\n\n/**\n * Helper function to assert the system is not in production mode.\n */\nexport function assertLogModeIsNotProduction(action: string) {\n if (store.value.mode === 'production') throw new ProhibitedDuringProduction(action)\n}\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { LogEntry } from './types.js';
|
|
2
|
-
export declare function writeToReporters(logEntry: LogEntry, filter: (reporterId: string) => boolean): void;
|
|
3
|
-
export declare namespace writeToReporters {
|
|
4
|
-
var fn: (logEntry: LogEntry, filter: (reporterId: string) => boolean) => void;
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=writeToReporters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writeToReporters.d.ts","sourceRoot":"","sources":["../ts/writeToReporters.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,QAE3F;yBAFe,gBAAgB"}
|
package/cjs/writeToReporters.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.writeToReporters = void 0;
|
|
4
|
-
var config_js_1 = require("./config.js");
|
|
5
|
-
var store_js_1 = require("./store.js");
|
|
6
|
-
function writeToReporters(logEntry, filter) {
|
|
7
|
-
writeToReporters.fn(logEntry, filter);
|
|
8
|
-
}
|
|
9
|
-
exports.writeToReporters = writeToReporters;
|
|
10
|
-
// istanbul ignore next
|
|
11
|
-
writeToReporters.fn = function (logEntry, filter) {
|
|
12
|
-
var store = getConfiguredStore();
|
|
13
|
-
var redirect = store.value.redirects[logEntry.id];
|
|
14
|
-
var reporters = redirect && redirect.length > 0 ? redirect : store.value.reporters;
|
|
15
|
-
reporters.filter(function (r) { return filter(r.id); }).forEach(function (r) { return r.write(logEntry); });
|
|
16
|
-
};
|
|
17
|
-
function getConfiguredStore() {
|
|
18
|
-
if (!store_js_1.store.value.configured)
|
|
19
|
-
(0, config_js_1.config)();
|
|
20
|
-
return store_js_1.store;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=writeToReporters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writeToReporters.js","sourceRoot":"","sources":["../ts/writeToReporters.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,uCAAkC;AAGlC,SAAgB,gBAAgB,CAAC,QAAkB,EAAE,MAAuC;IAC1F,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;AACvC,CAAC;AAFD,4CAEC;AAED,uBAAuB;AACvB,gBAAgB,CAAC,EAAE,GAAG,UAAC,QAAkB,EAAE,MAAuC;IAChF,IAAM,KAAK,GAAG,kBAAkB,EAAE,CAAA;IAClC,IAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IACnD,IAAM,SAAS,GAAG,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAA;IACpF,SAAS,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAZ,CAAY,CAAC,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,CAAC,QAAS,CAAC,EAAlB,CAAkB,CAAC,CAAA;AACtE,CAAC,CAAA;AAED,SAAS,kBAAkB;IACzB,IAAI,CAAC,gBAAK,CAAC,KAAK,CAAC,UAAU;QAAE,IAAA,kBAAM,GAAE,CAAA;IACrC,OAAO,gBAAK,CAAA;AACd,CAAC","sourcesContent":["import { config } from './config.js'\nimport { store } from './store.js'\nimport { LogEntry } from './types.js'\n\nexport function writeToReporters(logEntry: LogEntry, filter: (reporterId: string) => boolean) {\n writeToReporters.fn(logEntry, filter)\n}\n\n// istanbul ignore next\nwriteToReporters.fn = (logEntry: LogEntry, filter: (reporterId: string) => boolean) => {\n const store = getConfiguredStore()\n const redirect = store.value.redirects[logEntry.id]\n const reporters = redirect && redirect.length > 0 ? redirect : store.value.reporters\n reporters.filter(r => filter(r.id)).forEach(r => r.write(logEntry!))\n}\n\nfunction getConfiguredStore() {\n if (!store.value.configured) config()\n return store\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writeToReporters.spec.d.ts","sourceRoot":"","sources":["../ts/writeToReporters.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var delay_1 = __importDefault(require("delay"));
|
|
43
|
-
var getLogger_js_1 = require("./getLogger.js");
|
|
44
|
-
test('auto config in first write', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var log;
|
|
46
|
-
return __generator(this, function (_a) {
|
|
47
|
-
switch (_a.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
log = (0, getLogger_js_1.getLogger)('config-in-first-write');
|
|
50
|
-
log.emergency('first: should see this message');
|
|
51
|
-
log.emergency('second: should see this message');
|
|
52
|
-
return [4 /*yield*/, (0, delay_1.default)(10)];
|
|
53
|
-
case 1:
|
|
54
|
-
_a.sent();
|
|
55
|
-
return [2 /*return*/];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}); });
|
|
59
|
-
//# sourceMappingURL=writeToReporters.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writeToReporters.spec.js","sourceRoot":"","sources":["../ts/writeToReporters.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAyB;AACzB,+CAA0C;AAE1C,IAAI,CAAC,4BAA4B,EAAE;;;;;gBAC3B,GAAG,GAAG,IAAA,wBAAS,EAAC,uBAAuB,CAAC,CAAA;gBAC9C,GAAG,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAA;gBAC/C,GAAG,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAA;gBAChD,qBAAM,IAAA,eAAK,EAAC,EAAE,CAAC,EAAA;;gBAAf,SAAe,CAAA;;;;KAChB,CAAC,CAAA","sourcesContent":["import delay from 'delay'\nimport { getLogger } from './getLogger.js'\n\ntest('auto config in first write', async () => {\n const log = getLogger('config-in-first-write')\n log.emergency('first: should see this message')\n log.emergency('second: should see this message')\n await delay(10)\n})\n"]}
|
package/esm/LogEntry.d.ts
DELETED
package/esm/LogEntry.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LogEntry.d.ts","sourceRoot":"","sources":["../ts/LogEntry.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IAEd,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,SAAS,EAAE,IAAI,CAAA;CAChB,CAAA"}
|
package/esm/LogEntry.js
DELETED
package/esm/LogEntry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LogEntry.js","sourceRoot":"","sources":["../ts/LogEntry.ts"],"names":[],"mappings":"","sourcesContent":["export type LogEntry = {\n id: string,\n level: number,\n // args instead of messages because it is `any[]` instead of `string[]`\n args: any[],\n timestamp: Date\n}\n"]}
|
package/esm/captureLogs.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { LogEntry, Logger } from './types.js';
|
|
2
|
-
export declare function captureLogs<R>(logger: Logger, funcBlock: () => Promise<R>): Promise<[R, LogEntry[]]>;
|
|
3
|
-
export declare function captureLogs<R>(logger: Logger, funcBlock: () => R): [R, LogEntry[]];
|
|
4
|
-
//# sourceMappingURL=captureLogs.d.ts.map
|
package/esm/captureLogs.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"captureLogs.d.ts","sourceRoot":"","sources":["../ts/captureLogs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,YAAY,CAAA;AAE1D,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AACrG,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA"}
|
package/esm/captureLogs.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { isPromise } from 'type-plus';
|
|
2
|
-
import { createMemoryLogReporter } from './memory/index.js';
|
|
3
|
-
import { store } from './store.js';
|
|
4
|
-
export function captureLogs(logger, funcBlock) {
|
|
5
|
-
const reporter = createMemoryLogReporter();
|
|
6
|
-
addRedirect(logger.id, reporter);
|
|
7
|
-
try {
|
|
8
|
-
const result = funcBlock();
|
|
9
|
-
if (isPromise(result)) {
|
|
10
|
-
return result.then((r) => [r, reporter.logs])
|
|
11
|
-
.finally(() => removeRedirect(logger.id, reporter));
|
|
12
|
-
}
|
|
13
|
-
removeRedirect(logger.id, reporter);
|
|
14
|
-
return [result, reporter.logs];
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
removeRedirect(logger.id, reporter);
|
|
18
|
-
throw e;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function addRedirect(id, reporter) {
|
|
22
|
-
const redirect = store.value.redirects[id] || [];
|
|
23
|
-
redirect.push(reporter);
|
|
24
|
-
store.value.redirects[id] = redirect;
|
|
25
|
-
}
|
|
26
|
-
function removeRedirect(id, reporter) {
|
|
27
|
-
store.value.redirects[id] = store.value.redirects[id].filter(r => r !== reporter);
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=captureLogs.js.map
|
package/esm/captureLogs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"captureLogs.js","sourceRoot":"","sources":["../ts/captureLogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKlC,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,SAAsB;IAChE,MAAM,QAAQ,GAAG,uBAAuB,EAAE,CAAA;IAC1C,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;IAEhC,IAAI;QACF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE;YACrB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;iBAC1C,OAAO,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAA;SACtD;QACD,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACnC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;KAC/B;IACD,OAAO,CAAC,EAAE;QACR,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACnC,MAAM,CAAC,CAAA;KACR;AACH,CAAC;AAED,SAAS,WAAW,CAAC,EAAU,EAAE,QAAqB;IACpD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAA;IAChD,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACvB,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAA;AACtC,CAAC;AAED,SAAS,cAAc,CAAC,EAAU,EAAE,QAAqB;IACvD,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAA;AACnF,CAAC","sourcesContent":["import { AnyFunction, isPromise } from 'type-plus'\nimport { createMemoryLogReporter } from './memory/index.js'\nimport { store } from './store.js'\nimport { LogEntry, Logger, LogReporter } from './types.js'\n\nexport function captureLogs<R>(logger: Logger, funcBlock: () => Promise<R>): Promise<[R, LogEntry[]]>\nexport function captureLogs<R>(logger: Logger, funcBlock: () => R): [R, LogEntry[]]\nexport function captureLogs(logger: Logger, funcBlock: AnyFunction) {\n const reporter = createMemoryLogReporter()\n addRedirect(logger.id, reporter)\n\n try {\n const result = funcBlock()\n if (isPromise(result)) {\n return result.then((r) => [r, reporter.logs])\n .finally(() => removeRedirect(logger.id, reporter))\n }\n removeRedirect(logger.id, reporter)\n return [result, reporter.logs]\n }\n catch (e) {\n removeRedirect(logger.id, reporter)\n throw e\n }\n}\n\nfunction addRedirect(id: string, reporter: LogReporter) {\n const redirect = store.value.redirects[id] || []\n redirect.push(reporter)\n store.value.redirects[id] = redirect\n}\n\nfunction removeRedirect(id: string, reporter: LogReporter) {\n store.value.redirects[id] = store.value.redirects[id].filter(r => r !== reporter)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"captureLogs.spec.d.ts","sourceRoot":"","sources":["../ts/captureLogs.spec.ts"],"names":[],"mappings":""}
|
package/esm/captureLogs.spec.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import a from 'assertron';
|
|
2
|
-
import delay from 'delay';
|
|
3
|
-
import { captureLogs, getLogger } from './index.js';
|
|
4
|
-
import { toMessageWithLevel } from './memory/index.js';
|
|
5
|
-
import { store } from './store.js';
|
|
6
|
-
describe('captureLogs()', () => {
|
|
7
|
-
test('gets empty object if no log are written', () => {
|
|
8
|
-
const log = getLogger('capture');
|
|
9
|
-
const [, actual] = captureLogs(log, () => { });
|
|
10
|
-
expect(actual).toEqual([]);
|
|
11
|
-
});
|
|
12
|
-
test('gets logs', () => {
|
|
13
|
-
const log = getLogger('capture');
|
|
14
|
-
const [, actual] = captureLogs(log, () => log.error('err msg'));
|
|
15
|
-
expect(toMessageWithLevel(actual)).toEqual('(ERROR) err msg');
|
|
16
|
-
a.satisfies(actual, [{ args: ['err msg'] }]);
|
|
17
|
-
});
|
|
18
|
-
test('get logs for async block', async () => {
|
|
19
|
-
const log = getLogger('capture');
|
|
20
|
-
const [, actual] = await captureLogs(log, async () => {
|
|
21
|
-
await delay(1);
|
|
22
|
-
log.error('err msg');
|
|
23
|
-
});
|
|
24
|
-
a.satisfies(actual, [{ args: ['err msg'] }]);
|
|
25
|
-
});
|
|
26
|
-
test('redirect is reset even if the block throws', () => {
|
|
27
|
-
const log = getLogger('capture');
|
|
28
|
-
a.throws(() => captureLogs(log, () => { throw new Error('some error'); }));
|
|
29
|
-
expect(store.value.redirects[log.id].length).toBe(0);
|
|
30
|
-
});
|
|
31
|
-
test('redirect is reset even if the block rejects', async () => {
|
|
32
|
-
const log = getLogger('capture');
|
|
33
|
-
await a.throws(() => captureLogs(log, async () => {
|
|
34
|
-
await delay(1);
|
|
35
|
-
throw new Error('some error');
|
|
36
|
-
}));
|
|
37
|
-
expect(store.value.redirects[log.id].length).toBe(0);
|
|
38
|
-
});
|
|
39
|
-
test('receive sync result', () => {
|
|
40
|
-
const log = getLogger('capture');
|
|
41
|
-
const [a] = captureLogs(log, () => 123);
|
|
42
|
-
expect(a).toEqual(123);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=captureLogs.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"captureLogs.spec.js","sourceRoot":"","sources":["../ts/captureLogs.spec.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,WAAW,CAAA;AACzB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACnD,MAAM,GAAG,GAAG,SAAS,CAAC,SAAS,CAAC,CAAA;QAChC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;QAE9C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;QACrB,MAAM,GAAG,GAAG,SAAS,CAAC,SAAS,CAAC,CAAA;QAChC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA;QAE/D,MAAM,CAAC,kBAAkB,CAAC,M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,KAAK,IAAI,EAAE;YAC/C,MAAM,KAAK,CAAC,CAAC,CAAC,CAAA;YACd,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;QAC/B,CAAC,CAAC,CAAC,CAAA;QACH,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC/B,MAAM,GAAG,GAAG,SAAS,CAAC,SAAS,CAAC,CAAA;QAChC,MAAM,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;QACvC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import a from 'assertron'\nimport delay from 'delay'\nimport { captureLogs, getLogger } from './index.js'\nimport { toMessageWithLevel } from './memory/index.js'\nimport { store } from './store.js'\n\ndescribe('captureLogs()', () => {\n test('gets empty object if no log are written', () => {\n const log = getLogger('capture')\n const [, actual] = captureLogs(log, () => { })\n\n expect(actual).toEqual([])\n })\n\n test('gets logs', () => {\n const log = getLogger('capture')\n const [, actual] = captureLogs(log, () => log.error('err msg'))\n\n expect(toMessageWithLevel(actual)).toEqual('(ERROR) err msg')\n a.satisfies(actual, [{ args: ['err msg'] }])\n })\n\n test('get logs for async block', async () => {\n const log = getLogger('capture')\n const [, actual] = await captureLogs(log, async () => {\n await delay(1)\n log.error('err msg')\n })\n a.satisfies(actual, [{ args: ['err msg'] }])\n })\n\n test('redirect is reset even if the block throws', () => {\n const log = getLogger('capture')\n a.throws(() => captureLogs(log, () => { throw new Error('some error') }))\n expect(store.value.redirects[log.id].length).toBe(0)\n })\n\n test('redirect is reset even if the block rejects', async () => {\n const log = getLogger('capture')\n await a.throws(() => captureLogs(log, async () => {\n await delay(1)\n throw new Error('some error')\n }))\n expect(store.value.redirects[log.id].length).toBe(0)\n })\n\n test('receive sync result', () => {\n const log = getLogger('capture')\n const [a] = captureLogs(log, () => 123)\n expect(a).toEqual(123)\n })\n})\n"]}
|
package/esm/config.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { LogMode, LogReporter } from './types.js';
|
|
2
|
-
export declare type ConfigOptions = {
|
|
3
|
-
mode: LogMode;
|
|
4
|
-
customLevels: Record<string, number>;
|
|
5
|
-
logLevel: number;
|
|
6
|
-
reporters: LogReporter[];
|
|
7
|
-
};
|
|
8
|
-
export declare const config: {
|
|
9
|
-
(options?: Partial<ConfigOptions>): void;
|
|
10
|
-
readonly isLocked: boolean;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=config.d.ts.map
|
package/esm/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../ts/config.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEjD,oBAAY,aAAa,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,WAAW,EAAE,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAgCnF,CAAA"}
|
package/esm/config.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { forEachKey } from 'type-plus';
|
|
2
|
-
import { addCustomLogLevel } from './customLogLevel.js';
|
|
3
|
-
import { ProhibitedDuringProduction } from './errors.js';
|
|
4
|
-
import { getDefaultReporter } from './getDefaultReporter.js';
|
|
5
|
-
import { getLogger } from './getLogger.js';
|
|
6
|
-
import { store } from './store.js';
|
|
7
|
-
export const config = function config(options = {}) {
|
|
8
|
-
if (store.value.configured) {
|
|
9
|
-
if (store.value.mode === 'production') {
|
|
10
|
-
throw new ProhibitedDuringProduction('config');
|
|
11
|
-
}
|
|
12
|
-
if (store.value.mode === 'test' && options.mode !== 'test') {
|
|
13
|
-
const log = getLogger('standard-log');
|
|
14
|
-
log.warn(`already configured for test, ignoring config() call`);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
if (options.mode)
|
|
19
|
-
store.value.mode = options.mode;
|
|
20
|
-
store.value.logLevel = options.logLevel !== undefined ? options.logLevel : store.value.logLevel;
|
|
21
|
-
if (options.customLevels) {
|
|
22
|
-
const customLevels = options.customLevels;
|
|
23
|
-
forEachKey(customLevels, k => {
|
|
24
|
-
addCustomLogLevel(k, customLevels[k]);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
store.value.reporters = options.reporters || [getDefaultReporter()];
|
|
28
|
-
store.value.configured = true;
|
|
29
|
-
if (store.value.mode === 'production') {
|
|
30
|
-
store.freeze({ ...store.value, reporters: Object.freeze(store.value.reporters) });
|
|
31
|
-
}
|
|
32
|
-
else if (store.value.mode === 'development') {
|
|
33
|
-
console.warn(`'standard-log' is running in 'development' mode. Configuration is not protected.`);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
Object.defineProperty(config, 'isLocked', {
|
|
37
|
-
/**
|
|
38
|
-
* Gets if the config has already been locked
|
|
39
|
-
*/
|
|
40
|
-
get() {
|
|
41
|
-
return store.value.configured;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=config.js.map
|
package/esm/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../ts/config.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AC,CAAC,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;KACH;IAED,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAA;IACnE,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAA;IAE7B,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE;QACrC,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;KAClF;SACI,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,aAAa,EAAE;QAC3C,OAAO,CAAC,IAAI,CAAC,kFAAkF,CAAC,CAAA;KACjG;AACH,CAAQ,CAAA;AAER,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE;IACxC;;OAEG;IACH,GAAG;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,UAAU,CAAA;IAC/B,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { forEachKey } from 'type-plus'\nimport { addCustomLogLevel } from './customLogLevel.js'\nimport { ProhibitedDuringProduction } from './errors.js'\nimport { getDefaultReporter } from './getDefaultReporter.js'\nimport { getLogger } from './getLogger.js'\nimport { store } from './store.js'\nimport { LogMode, LogReporter } from './types.js'\n\nexport type ConfigOptions = {\n mode: LogMode,\n customLevels: Record<string, number>,\n logLevel: number,\n reporters: LogReporter[]\n}\n\nexport const config: { (options?: Partial<ConfigOptions>): void, readonly isLocked: boolean } = function config(options: Partial<ConfigOptions> = {}) {\n if (store.value.configured) {\n if (store.value.mode === 'production') {\n throw new ProhibitedDuringProduction('config')\n }\n if (store.value.mode === 'test' && options.mode !== 'test') {\n const log = getLogger('standard-log')\n log.warn(`already configured for test, ignoring config() call`)\n return\n }\n }\n\n if (options.mode) store.value.mode = options.mode\n\n store.value.logLevel = options.logLevel !== undefined ? options.logLevel : store.value.logLevel\n\n if (options.customLevels) {\n const customLevels = options.customLevels\n forEachKey(customLevels, k => {\n addCustomLogLevel(k, customLevels[k])\n })\n }\n\n store.value.reporters = options.reporters || [getDefaultReporter()]\n store.value.configured = true\n\n if (store.value.mode === 'production') {\n store.freeze({ ...store.value, reporters: Object.freeze(store.value.reporters) })\n }\n else if (store.value.mode === 'development') {\n console.warn(`'standard-log' is running in 'development' mode. Configuration is not protected.`)\n }\n} as any\n\nObject.defineProperty(config, 'isLocked', {\n /**\n * Gets if the config has already been locked\n */\n get() {\n return store.value.configured\n }\n})\n"]}
|
package/esm/config.spec.d.ts
DELETED
package/esm/config.spec.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.spec.d.ts","sourceRoot":"","sources":["../ts/config.spec.ts"],"names":[],"mappings":""}
|
package/esm/config.spec.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import a from 'assertron';
|
|
2
|
-
import { config, createMemoryLogReporter, logLevels, ProhibitedDuringProduction, toLogLevelName } from './index.js';
|
|
3
|
-
import { configForTest } from './configForTest.js';
|
|
4
|
-
import { store } from './store.js';
|
|
5
|
-
beforeEach(() => store.reset());
|
|
6
|
-
afterEach(() => store.reset());
|
|
7
|
-
test('in production mode by default', () => {
|
|
8
|
-
expect(store.value.mode).toBe('production');
|
|
9
|
-
});
|
|
10
|
-
test('default logLevel is info', () => {
|
|
11
|
-
expect(store.value.logLevel).toBe(logLevels.info);
|
|
12
|
-
});
|
|
13
|
-
test('configure default logLevel', () => {
|
|
14
|
-
config({ logLevel: logLevels.planck });
|
|
15
|
-
expect(store.value.logLevel).toBe(logLevels.planck);
|
|
16
|
-
});
|
|
17
|
-
test('calling config twice throws ProhibitedDuringProduction in production mode', () => {
|
|
18
|
-
config({ mode: 'production' });
|
|
19
|
-
a.throws(() => config({ mode: 'development' }), ProhibitedDuringProduction);
|
|
20
|
-
});
|
|
21
|
-
test('allow calling config with non-test mode while already running in test mode, but emit a warning', () => {
|
|
22
|
-
const { reporter } = configForTest();
|
|
23
|
-
config({ mode: 'production' });
|
|
24
|
-
expect(reporter.getLogMessageWithLevel()).toEqual('(WARN) already configured for test, ignoring config() call');
|
|
25
|
-
});
|
|
26
|
-
test('allow calling config in test mode again while in test mode. Emit no warning', () => {
|
|
27
|
-
const { reporter } = configForTest();
|
|
28
|
-
config({ mode: 'test' });
|
|
29
|
-
expect(reporter.getLogMessageWithLevel()).toEqual('');
|
|
30
|
-
});
|
|
31
|
-
test('add custom levels', () => {
|
|
32
|
-
config({
|
|
33
|
-
customLevels: {
|
|
34
|
-
'urgent': 80
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
expect(toLogLevelName(80)).toBe('urgent');
|
|
38
|
-
});
|
|
39
|
-
test('configure to use a reporter instance', () => {
|
|
40
|
-
config({
|
|
41
|
-
reporters: [
|
|
42
|
-
createMemoryLogReporter()
|
|
43
|
-
]
|
|
44
|
-
});
|
|
45
|
-
a.satisfies(store.value.reporters, [{ id: 'memory' }]);
|
|
46
|
-
expect(store.value.reporters.length).toBe(1);
|
|
47
|
-
});
|
|
48
|
-
test('configure as development will emit warning', () => {
|
|
49
|
-
const warn = console.warn;
|
|
50
|
-
let actual;
|
|
51
|
-
console.warn = message => actual = message;
|
|
52
|
-
config({ mode: 'development' });
|
|
53
|
-
expect(actual).toBe(`'standard-log' is running in 'development' mode. Configuration is not protected.`);
|
|
54
|
-
console.warn = warn;
|
|
55
|
-
});
|
|
56
|
-
test('config.configured', () => {
|
|
57
|
-
expect(config.isLocked).toBeFalsy();
|
|
58
|
-
config({ mode: 'test' });
|
|
59
|
-
expect(config.isLocked).toBe(true);
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=config.spec.js.map
|
package/esm/config.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.spec.js","sourceRoot":"","sources":["../ts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G,OAAO,CAAC,IAAI,CAAA;IACzB,IAAI,MAAc,CAAA;IAClB,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,OAAO,CAAA;IAC1C,MAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAA;IAE/B,MAAM,CAAC,MAAO,CAAC,CAAC,IAAI,CAAC,kFAAkF,CAAC,CAAA;IAExG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;AACrB,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC7B,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAA;IACnC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IACxB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACpC,CAAC,CAAC,CAAA","sourcesContent":["import a from 'assertron'\nimport {\n config, createMemoryLogReporter,\n logLevels, ProhibitedDuringProduction, toLogLevelName\n} from './index.js'\nimport { configForTest } from './configForTest.js'\nimport { store } from './store.js'\n\nbeforeEach(() => store.reset())\n\nafterEach(() => store.reset())\n\ntest('in production mode by default', () => {\n expect(store.value.mode).toBe('production')\n})\n\ntest('default logLevel is info', () => {\n expect(store.value.logLevel).toBe(logLevels.info)\n})\n\ntest('configure default logLevel', () => {\n config({ logLevel: logLevels.planck })\n\n expect(store.value.logLevel).toBe(logLevels.planck)\n})\n\ntest('calling config twice throws ProhibitedDuringProduction in production mode', () => {\n config({ mode: 'production' })\n a.throws(() => config({ mode: 'development' }), ProhibitedDuringProduction)\n})\n\ntest('allow calling config with non-test mode while already running in test mode, but emit a warning', () => {\n const { reporter } = configForTest()\n config({ mode: 'production' })\n expect(reporter.getLogMessageWithLevel()).toEqual('(WARN) already configured for test, ignoring config() call')\n})\n\ntest('allow calling config in test mode again while in test mode. Emit no warning', () => {\n const { reporter } = configForTest()\n config({ mode: 'test' })\n expect(reporter.getLogMessageWithLevel()).toEqual('')\n})\n\n\ntest('add custom levels', () => {\n config({\n customLevels: {\n 'urgent': 80\n }\n })\n\n expect(toLogLevelName(80)).toBe('urgent')\n})\n\ntest('configure to use a reporter instance', () => {\n config({\n reporters: [\n createMemoryLogReporter()\n ]\n })\n a.satisfies(store.value.reporters, [{ id: 'memory' }])\n expect(store.value.reporters.length).toBe(1)\n})\n\ntest('configure as development will emit warning', () => {\n const warn = console.warn\n let actual: string\n console.warn = message => actual = message\n config({ mode: 'development' })\n\n expect(actual!).toBe(`'standard-log' is running in 'development' mode. Configuration is not protected.`)\n\n console.warn = warn\n})\n\ntest('config.configured', () => {\n expect(config.isLocked).toBeFalsy()\n config({ mode: 'test' })\n expect(config.isLocked).toBe(true)\n})\n"]}
|
package/esm/configForTest.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configForTest.d.ts","sourceRoot":"","sources":["../ts/configForTest.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAGrC,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,QAAQ;;EAShD"}
|
package/esm/configForTest.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { config } from './config.js';
|
|
2
|
-
import { createMemoryLogReporter } from './memory/index.js';
|
|
3
|
-
import { store } from './store.js';
|
|
4
|
-
export function configForTest(logLevel) {
|
|
5
|
-
store.reset();
|
|
6
|
-
const reporter = createMemoryLogReporter();
|
|
7
|
-
config({
|
|
8
|
-
reporters: [reporter],
|
|
9
|
-
mode: 'test',
|
|
10
|
-
logLevel
|
|
11
|
-
});
|
|
12
|
-
return { reporter };
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=configForTest.js.map
|
package/esm/configForTest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configForTest.js","sourceRoot":"","sources":["../ts/configForTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAIlC,MAAM,UAAU,aAAa,CAAC,QAAmB;IAC/C,KAAK,CAAC,KAAK,EAAE,CAAA;IACb,MAAM,QAAQ,GAAG,uBAAuB,EAAE,CAAA;IAC1C,MAAM,CAAC;QACL,SAAS,EAAE,CAAC,QAAQ,CAAC;QACrB,IAAI,EAAE,MAAM;QACZ,QAAQ;KACT,CAAC,CAAA;IACF,OAAO,EAAE,QAAQ,EAAE,CAAA;AACrB,CAAC","sourcesContent":["import { config } from './config.js'\nimport { createMemoryLogReporter } from './memory/index.js'\nimport { store } from './store.js'\nimport { LogLevel } from './types.js'\n\n\nexport function configForTest(logLevel?: LogLevel) {\n store.reset()\n const reporter = createMemoryLogReporter()\n config({\n reporters: [reporter],\n mode: 'test',\n logLevel\n })\n return { reporter }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configForTest.spec.d.ts","sourceRoot":"","sources":["../ts/configForTest.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { configForTest } from './index.js';
|
|
2
|
-
import { getLogger } from './getLogger.js';
|
|
3
|
-
import { logLevels } from './logLevel.js';
|
|
4
|
-
test('config in test mode and return the memory reporter', () => {
|
|
5
|
-
const { reporter } = configForTest();
|
|
6
|
-
getLogger('config-for-test').info('ha');
|
|
7
|
-
expect(reporter.getLogMessage()).toEqual('ha');
|
|
8
|
-
});
|
|
9
|
-
test('set log level', () => {
|
|
10
|
-
const { reporter } = configForTest(logLevels.warn);
|
|
11
|
-
getLogger('config-for-test').info('no');
|
|
12
|
-
getLogger('config-for-test').warn('yes');
|
|
13
|
-
expect(reporter.getLogMessage()).toEqual('yes');
|
|
14
|
-
});
|
|
15
|
-
//# sourceMappingURL=configForTest.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configForTest.spec.js","sourceRoot":"","sources":["../ts/configForTest.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,IAAI,CAAC,oDAAoD,EAAE,GAAG,EAAE;IAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAA;IACpC,SAAS,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvC,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAChD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;IACzB,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAClD,SAAS,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvC,SAAS,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACxC,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA","sourcesContent":["import { configForTest } from './index.js'\nimport { getLogger } from './getLogger.js'\nimport { logLevels } from './logLevel.js'\n\ntest('config in test mode and return the memory reporter', () => {\n const { reporter } = configForTest()\n getLogger('config-for-test').info('ha')\n expect(reporter.getLogMessage()).toEqual('ha')\n})\n\ntest('set log level', () => {\n const { reporter } = configForTest(logLevels.warn)\n getLogger('config-for-test').info('no')\n getLogger('config-for-test').warn('yes')\n expect(reporter.getLogMessage()).toEqual('yes')\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createConsoleLogReporter.d.ts","sourceRoot":"","sources":["../../ts/console/createConsoleLogReporter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAa,MAAM,aAAa,CAAA;AAItF,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,oBAAY,kBAAkB,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAA;AAC1E,oBAAY,mBAAmB,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC,CAAA;AACrD,oBAAY,yBAAyB,GAAG,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAA;AAEjE,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,CA6BhG"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { required } from 'type-plus';
|
|
2
|
-
import { plainLogFormatter } from '../formatter/index.js';
|
|
3
|
-
import { assertLogModeIsNotProduction } from '../utils.js';
|
|
4
|
-
import { polyfilledConsole } from './polyfilledConsole.js';
|
|
5
|
-
import { toConsoleMethod } from './toConsoleMethod.js';
|
|
6
|
-
export function createConsoleLogReporter(options) {
|
|
7
|
-
const opts = required({ id: 'console', formatter: plainLogFormatter }, options);
|
|
8
|
-
const { id } = opts;
|
|
9
|
-
let { formatter, filter } = opts;
|
|
10
|
-
return {
|
|
11
|
-
id,
|
|
12
|
-
isConsoleReporter: true,
|
|
13
|
-
get formatter() {
|
|
14
|
-
return formatter;
|
|
15
|
-
},
|
|
16
|
-
set formatter(value) {
|
|
17
|
-
assertLogModeIsNotProduction('set Reporter.formatter');
|
|
18
|
-
formatter = value;
|
|
19
|
-
},
|
|
20
|
-
get filter() {
|
|
21
|
-
return filter;
|
|
22
|
-
},
|
|
23
|
-
set filter(value) {
|
|
24
|
-
assertLogModeIsNotProduction('set Reporter.filter');
|
|
25
|
-
filter = value;
|
|
26
|
-
},
|
|
27
|
-
console: polyfilledConsole,
|
|
28
|
-
write(entry) {
|
|
29
|
-
if (filter && !filter(entry))
|
|
30
|
-
return;
|
|
31
|
-
const values = formatter(entry);
|
|
32
|
-
const method = toConsoleMethod(entry.level);
|
|
33
|
-
this.console[method](...values);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=createConsoleLogReporter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createConsoleLogReporter.js","sourceRoot":"","sources":["../../ts/console/createConsoleLogReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAOtD,MAAM,UAAU,wBAAwB,CAAC,OAAmC;IAC1E,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,EAAE,OAAO,CAAC,CAAA;IAC/E,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAChC,OAAO;QACL,EAAE;QACF,iBAAiB,EAAE,IAAI;QACvB,IAAI,SAAS;YACX,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,IAAI,SAAS,CAAC,KAA0B;YACtC,4BAA4B,CAAC,wBAAwB,CAAC,CAAA;YACtD,SAAS,GAAG,KAAK,CAAA;QACnB,CAAC;QACD,IAAI,MAAM;YACR,OAAO,MAAM,CAAA;QACf,CAAC;QACD,IAAI,MAAM,CAAC,KAAgB;YACzB,4BAA4B,CAAC,qBAAqB,CAAC,CAAA;YACnD,MAAM,GAAG,KAAK,CAAA;QAChB,CAAC;QACD,OAAO,EAAE,iBAAiB;QAC1B,KAAK,CAAC,KAAK;YACT,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAE,OAAM;YACpC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;YAC/B,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YAC3C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAA;QACjC,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { required } from 'type-plus'\nimport { plainLogFormatter } from '../formatter/index.js'\nimport { LogFormatter, LogReporter, LogReporterOptions, LogFilter } from '../types.js'\nimport { assertLogModeIsNotProduction } from '../utils.js'\nimport { polyfilledConsole } from './polyfilledConsole.js'\nimport { toConsoleMethod } from './toConsoleMethod.js'\nimport { Console } from './types.js'\n\nexport type ConsoleLogReporter = LogReporter<any[]> & { console: Console }\nexport type ConsoleLogFormatter = LogFormatter<any[]>\nexport type ConsoleLogReporterOptions = LogReporterOptions<any[]>\n\nexport function createConsoleLogReporter(options?: ConsoleLogReporterOptions): ConsoleLogReporter {\n const opts = required({ id: 'console', formatter: plainLogFormatter }, options)\n const { id } = opts\n let { formatter, filter } = opts\n return {\n id,\n isConsoleReporter: true,\n get formatter() {\n return formatter\n },\n set formatter(value: ConsoleLogFormatter) {\n assertLogModeIsNotProduction('set Reporter.formatter')\n formatter = value\n },\n get filter() {\n return filter\n },\n set filter(value: LogFilter) {\n assertLogModeIsNotProduction('set Reporter.filter')\n filter = value\n },\n console: polyfilledConsole,\n write(entry) {\n if (filter && !filter(entry)) return\n const values = formatter(entry)\n const method = toConsoleMethod(entry.level)\n this.console[method](...values)\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createConsoleLogReporter.spec.d.ts","sourceRoot":"","sources":["../../ts/console/createConsoleLogReporter.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createConsoleLogReporter.spec.js","sourceRoot":"","sources":["../../ts/console/createConsoleLogReporter.spec.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,WAAW,CAAA;AACzB,OAAO,EACL,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,EACxC,wBAAwB,EAClC,SAAS,EAAE,iBAAiB,EAAE,0BAA0B,EACpE,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;IAE/B,IAAI,CAAC,0CAA0C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAA;QAC9B,MAAM,QAAQ,GAAG,wBAAwB,EAAE,CAAA;QAC3C,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,CAAA,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAA;IAC9E,CAAC,CAAC,CAAA;IAEF,MAAM,WAAW,GAAwB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC9D,IAAI,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAA;QAC9B,MAAM,QAAQ,GAAG,wBAAwB,EAAE,CAAA;QAC3C,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,GA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AQ,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;SAChE,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAGF,SAAS,iBAAiB;IACxB,MAAM,MAAM,GAAU,EAAE,CAAA;IACxB,MAAM,KAAK,GAAU,EAAE,CAAA;IACvB,MAAM,KAAK,GAAU,EAAE,CAAA;IACvB,MAAM,MAAM,GAAU,EAAE,CAAA;IACxB,OAAO;QACL,MAAM;QACN,KAAK;QACL,KAAK;QACL,MAAM;QACN,KAAK,CAAC,GAAG,IAAW,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,IAAW,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,IAAW,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QACzC,KAAK,CAAC,GAAG,IAAW,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;KAC5C,CAAA;AACH,CAAC","sourcesContent":["import a from 'assertron'\nimport {\n addCustomLogLevel, clearCustomLogLevel, config, configForTest,\n ConsoleLogFormatter, createConsoleLogReporter,\n LogFilter, logLevels, plainLogFormatter, ProhibitedDuringProduction\n} from '../index.js'\nimport { store } from '../store.js'\n\ndescribe('production checks', () => {\n beforeEach(() => store.reset())\n\n test('set filter during production mode throws', () => {\n config({ mode: 'production' })\n const reporter = createConsoleLogReporter()\n a.throws(() => { reporter.filter = () => true }, ProhibitedDuringProduction)\n })\n\n const idFormatter: ConsoleLogFormatter = (entry) => [entry.id]\n test('set formatter during production mode throws', () => {\n config({ mode: 'production' })\n const reporter = createConsoleLogReporter()\n a.throws(() => reporter.formatter = idFormatter, ProhibitedDuringProduction)\n })\n})\n\n\ndescribe('unit tests', () => {\n beforeEach(() => configForTest())\n\n describe('rendering tests', () => {\n test('plain rendering', () => {\n const reporter = createConsoleLogReporter({ formatter: plainLogFormatter });\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'plain', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n })\n\n describe('id', () => {\n test('default is \"console\"', () => {\n const reporter = createConsoleLogReporter()\n expect(reporter.id).toBe('console')\n })\n test('can be overridden', () => {\n const reporter = createConsoleLogReporter({ id: 'neo-console' })\n expect(reporter.id).toBe('neo-console')\n })\n })\n\n describe('log level', () => {\n test('error, alert, critical and emergency logs are written to console.error', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.critical, args: ['critical'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.alert, args: ['alert'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.error, args: ['error'], timestamp: new Date() })\n\n expect(fakeConsole.errors.length).toBe(4)\n })\n\n test('warn logs are written to console.warn', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.warn, args: ['warn'], timestamp: new Date() })\n\n expect(fakeConsole.warns.length).toBe(1)\n })\n\n test('notice and info logs are written to console.info', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.notice, args: ['notice'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.info, args: ['info'], timestamp: new Date() })\n\n expect(fakeConsole.infos.length).toBe(2)\n })\n\n\n test('debug, trace, and planck logs are written to console.debug', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.debug, args: ['debug'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.trace, args: ['trace'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.planck, args: ['planck'], timestamp: new Date() })\n\n expect(fakeConsole.debugs.length).toBe(3)\n })\n })\n\n describe('custom logs', () => {\n afterEach(() => clearCustomLogLevel())\n\n test('are written according to their log level value', () => {\n addCustomLogLevel('high', 50)\n addCustomLogLevel('important', 450)\n addCustomLogLevel('interest', 650)\n addCustomLogLevel('silly', 1000)\n\n const id = 'log'\n const reporter = createConsoleLogReporter()\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: 50, args: ['a'], timestamp: new Date() })\n reporter.write({ id, level: 450, args: ['b'], timestamp: new Date() })\n reporter.write({ id, level: 650, args: ['c'], timestamp: new Date() })\n reporter.write({ id, level: 1000, args: ['d'], timestamp: new Date() })\n\n expect(fakeConsole.errors.length).toBe(1)\n expect(fakeConsole.warns.length).toBe(1)\n expect(fakeConsole.infos.length).toBe(1)\n expect(fakeConsole.debugs.length).toBe(1)\n })\n })\n\n const idFormatter: ConsoleLogFormatter = (entry) => [entry.id]\n\n describe('formatter', () => {\n test('use specific formatter', () => {\n const id = 'id-only'\n const reporter = createConsoleLogReporter({ formatter: idFormatter })\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['id-only']])\n })\n\n test('formatter can be changed afterward', () => {\n const reporter = createConsoleLogReporter()\n const formatter = reporter.formatter\n reporter.formatter = idFormatter\n expect(reporter.formatter).not.toEqual(formatter)\n })\n })\n\n describe('filter', () => {\n const filter: LogFilter = (entry) => entry.id !== 'secret'\n test('use specific filter', () => {\n const reporter = createConsoleLogReporter({ formatter: idFormatter, filter })\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id: 'normal', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n reporter.write({ id: 'secret', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['normal']])\n })\n\n test('can change filter', () => {\n const reporter = createConsoleLogReporter()\n const filter = reporter.filter\n reporter.filter = entry => entry.id !== 'secret'\n expect(reporter.filter).not.toEqual(filter)\n })\n })\n\n test('write log entry with multiple arguments', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter({ formatter: plainLogFormatter })\n const fakeConsole = reporter.console = createFakeConsole()\n\n const entry = { id, level: logLevels.info, args: ['a', 'b', 'c'], timestamp: new Date() }\n\n reporter.write(entry)\n\n expect(fakeConsole.infos).toEqual([\n [entry.timestamp.toISOString(), 'log', '(INFO)', 'a', 'b', 'c']\n ])\n })\n})\n\n\nfunction createFakeConsole() {\n const errors: any[] = []\n const infos: any[] = []\n const warns: any[] = []\n const debugs: any[] = []\n return {\n errors,\n infos,\n warns,\n debugs,\n error(...args: any[]) { errors.push(args) },\n info(...args: any[]) { infos.push(args) },\n warn(...args: any[]) { warns.push(args) },\n debug(...args: any[]) { debugs.push(args) }\n }\n}\n"]}
|
package/esm/console/index.d.ts
DELETED