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
|
@@ -1,30 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
describe('
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { createStandardLog } from './standardLog.js';
|
|
2
|
+
import { createConsoleLogReporter, logLevels, plainLogFormatter, toConsoleMethod } from './index.js';
|
|
3
|
+
import { polyfill } from './platform.js';
|
|
4
|
+
describe('toConsoleMethod()', () => {
|
|
5
|
+
it('converts any level to standard console method names: debug, info, warn, error', () => {
|
|
6
|
+
expect(toConsoleMethod(1)).toEqual('error');
|
|
7
|
+
expect(toConsoleMethod(399)).toEqual('error');
|
|
8
|
+
expect(toConsoleMethod(400)).toEqual('error');
|
|
9
|
+
expect(toConsoleMethod(401)).toEqual('warn');
|
|
10
|
+
expect(toConsoleMethod(499)).toEqual('warn');
|
|
11
|
+
expect(toConsoleMethod(500)).toEqual('warn');
|
|
12
|
+
expect(toConsoleMethod(501)).toEqual('info');
|
|
13
|
+
expect(toConsoleMethod(700)).toEqual('info');
|
|
14
|
+
expect(toConsoleMethod(701)).toEqual('debug');
|
|
15
|
+
expect(toConsoleMethod(800)).toEqual('debug');
|
|
16
|
+
expect(toConsoleMethod(801)).toEqual('debug');
|
|
17
|
+
expect(toConsoleMethod(Infinity)).toEqual('debug');
|
|
10
18
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
it('converts to debug for 0 (none) or negative (not valid) level', () => {
|
|
20
|
+
// these are invalid input.
|
|
21
|
+
// so instead of hiding them and not logged,
|
|
22
|
+
// log them so that it is easier to discover.
|
|
23
|
+
expect(toConsoleMethod(-1)).toEqual('debug');
|
|
24
|
+
expect(toConsoleMethod(0)).toEqual('debug');
|
|
16
25
|
});
|
|
17
26
|
});
|
|
18
|
-
describe('
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
['emergency', 'info', 'warn', 'debug'].forEach(level => {
|
|
24
|
-
reporter.write({ id: 'plain', level: logLevels[level], args: ['hello', 'world'], timestamp: new Date() });
|
|
25
|
-
});
|
|
27
|
+
describe('rendering tests', () => {
|
|
28
|
+
test('plain rendering', () => {
|
|
29
|
+
const reporter = createConsoleLogReporter({ formatter: plainLogFormatter });
|
|
30
|
+
['emergency', 'info', 'warn', 'debug'].forEach(level => {
|
|
31
|
+
reporter.write({ id: 'plain', level: logLevels[level], args: ['hello', 'world'], timestamp: new Date() });
|
|
26
32
|
});
|
|
27
33
|
});
|
|
34
|
+
});
|
|
35
|
+
describe('createConsoleLogReporter', () => {
|
|
36
|
+
let fakeConsole = createFakeConsole();
|
|
37
|
+
beforeEach(() => polyfill.console = fakeConsole = createFakeConsole());
|
|
28
38
|
describe('id', () => {
|
|
29
39
|
test('default is "console"', () => {
|
|
30
40
|
const reporter = createConsoleLogReporter();
|
|
@@ -39,7 +49,6 @@ describe('unit tests', () => {
|
|
|
39
49
|
test('error, alert, critical and emergency logs are written to console.error', () => {
|
|
40
50
|
const id = 'log';
|
|
41
51
|
const reporter = createConsoleLogReporter();
|
|
42
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
43
52
|
reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
44
53
|
reporter.write({ id, level: logLevels.critical, args: ['critical'], timestamp: new Date() });
|
|
45
54
|
reporter.write({ id, level: logLevels.alert, args: ['alert'], timestamp: new Date() });
|
|
@@ -49,14 +58,12 @@ describe('unit tests', () => {
|
|
|
49
58
|
test('warn logs are written to console.warn', () => {
|
|
50
59
|
const id = 'log';
|
|
51
60
|
const reporter = createConsoleLogReporter();
|
|
52
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
53
61
|
reporter.write({ id, level: logLevels.warn, args: ['warn'], timestamp: new Date() });
|
|
54
62
|
expect(fakeConsole.warns.length).toBe(1);
|
|
55
63
|
});
|
|
56
64
|
test('notice and info logs are written to console.info', () => {
|
|
57
65
|
const id = 'log';
|
|
58
66
|
const reporter = createConsoleLogReporter();
|
|
59
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
60
67
|
reporter.write({ id, level: logLevels.notice, args: ['notice'], timestamp: new Date() });
|
|
61
68
|
reporter.write({ id, level: logLevels.info, args: ['info'], timestamp: new Date() });
|
|
62
69
|
expect(fakeConsole.infos.length).toBe(2);
|
|
@@ -64,7 +71,6 @@ describe('unit tests', () => {
|
|
|
64
71
|
test('debug, trace, and planck logs are written to console.debug', () => {
|
|
65
72
|
const id = 'log';
|
|
66
73
|
const reporter = createConsoleLogReporter();
|
|
67
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
68
74
|
reporter.write({ id, level: logLevels.debug, args: ['debug'], timestamp: new Date() });
|
|
69
75
|
reporter.write({ id, level: logLevels.trace, args: ['trace'], timestamp: new Date() });
|
|
70
76
|
reporter.write({ id, level: logLevels.planck, args: ['planck'], timestamp: new Date() });
|
|
@@ -72,19 +78,24 @@ describe('unit tests', () => {
|
|
|
72
78
|
});
|
|
73
79
|
});
|
|
74
80
|
describe('custom logs', () => {
|
|
75
|
-
afterEach(() => clearCustomLogLevel());
|
|
76
81
|
test('are written according to their log level value', () => {
|
|
77
|
-
addCustomLogLevel('high', 50);
|
|
78
|
-
addCustomLogLevel('important', 450);
|
|
79
|
-
addCustomLogLevel('interest', 650);
|
|
80
|
-
addCustomLogLevel('silly', 1000);
|
|
81
82
|
const id = 'log';
|
|
82
83
|
const reporter = createConsoleLogReporter();
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
const sl = createStandardLog({
|
|
85
|
+
logLevel: logLevels.all,
|
|
86
|
+
customLevels: {
|
|
87
|
+
'high': 50,
|
|
88
|
+
'important': 450,
|
|
89
|
+
'interest': 650,
|
|
90
|
+
'silly': 1000
|
|
91
|
+
},
|
|
92
|
+
reporters: [reporter]
|
|
93
|
+
});
|
|
94
|
+
const log = sl.getLogger([id]);
|
|
95
|
+
log.high('a');
|
|
96
|
+
log.important('b');
|
|
97
|
+
log.interest('c');
|
|
98
|
+
log.silly('d');
|
|
88
99
|
expect(fakeConsole.errors.length).toBe(1);
|
|
89
100
|
expect(fakeConsole.warns.length).toBe(1);
|
|
90
101
|
expect(fakeConsole.infos.length).toBe(1);
|
|
@@ -96,37 +107,24 @@ describe('unit tests', () => {
|
|
|
96
107
|
test('use specific formatter', () => {
|
|
97
108
|
const id = 'id-only';
|
|
98
109
|
const reporter = createConsoleLogReporter({ formatter: idFormatter });
|
|
99
|
-
|
|
110
|
+
expect(reporter.formatter).toBe(idFormatter);
|
|
100
111
|
reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
101
112
|
expect(fakeConsole.errors).toEqual([['id-only']]);
|
|
102
113
|
});
|
|
103
|
-
test('formatter can be changed afterward', () => {
|
|
104
|
-
const reporter = createConsoleLogReporter();
|
|
105
|
-
const formatter = reporter.formatter;
|
|
106
|
-
reporter.formatter = idFormatter;
|
|
107
|
-
expect(reporter.formatter).not.toEqual(formatter);
|
|
108
|
-
});
|
|
109
114
|
});
|
|
110
115
|
describe('filter', () => {
|
|
111
116
|
const filter = (entry) => entry.id !== 'secret';
|
|
112
117
|
test('use specific filter', () => {
|
|
113
118
|
const reporter = createConsoleLogReporter({ formatter: idFormatter, filter });
|
|
114
|
-
|
|
119
|
+
expect(reporter.filter).toBe(filter);
|
|
115
120
|
reporter.write({ id: 'normal', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
116
121
|
reporter.write({ id: 'secret', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
117
122
|
expect(fakeConsole.errors).toEqual([['normal']]);
|
|
118
123
|
});
|
|
119
|
-
test('can change filter', () => {
|
|
120
|
-
const reporter = createConsoleLogReporter();
|
|
121
|
-
const filter = reporter.filter;
|
|
122
|
-
reporter.filter = entry => entry.id !== 'secret';
|
|
123
|
-
expect(reporter.filter).not.toEqual(filter);
|
|
124
|
-
});
|
|
125
124
|
});
|
|
126
125
|
test('write log entry with multiple arguments', () => {
|
|
127
126
|
const id = 'log';
|
|
128
127
|
const reporter = createConsoleLogReporter({ formatter: plainLogFormatter });
|
|
129
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
130
128
|
const entry = { id, level: logLevels.info, args: ['a', 'b', 'c'], timestamp: new Date() };
|
|
131
129
|
reporter.write(entry);
|
|
132
130
|
expect(fakeConsole.infos).toEqual([
|
|
@@ -150,4 +148,4 @@ function createFakeConsole() {
|
|
|
150
148
|
debug(...args) { debugs.push(args); }
|
|
151
149
|
};
|
|
152
150
|
}
|
|
153
|
-
//# sourceMappingURL=
|
|
151
|
+
//# sourceMappingURL=console.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.spec.js","sourceRoot":"","sources":["../ts/console.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EACgB,wBAAwB,EAClC,SAAS,E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M,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;YAChC,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;SAChE,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,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 { createStandardLog } from './standardLog.js'\nimport {\n ConsoleLogFormatter, createConsoleLogReporter,\n LogFilter, logLevels, plainLogFormatter, toConsoleMethod\n} from './index.js'\nimport { polyfill } from './platform.js'\n\ndescribe('toConsoleMethod()', () => {\n it('converts any level to standard console method names: debug, info, warn, error', () => {\n expect(toConsoleMethod(1)).toEqual('error')\n expect(toConsoleMethod(399)).toEqual('error')\n expect(toConsoleMethod(400)).toEqual('error')\n\n expect(toConsoleMethod(401)).toEqual('warn')\n expect(toConsoleMethod(499)).toEqual('warn')\n expect(toConsoleMethod(500)).toEqual('warn')\n\n expect(toConsoleMethod(501)).toEqual('info')\n expect(toConsoleMethod(700)).toEqual('info')\n\n expect(toConsoleMethod(701)).toEqual('debug')\n expect(toConsoleMethod(800)).toEqual('debug')\n expect(toConsoleMethod(801)).toEqual('debug')\n expect(toConsoleMethod(Infinity)).toEqual('debug')\n })\n it('converts to debug for 0 (none) or negative (not valid) level', () => {\n // these are invalid input.\n // so instead of hiding them and not logged,\n // log them so that it is easier to discover.\n expect(toConsoleMethod(-1)).toEqual('debug')\n expect(toConsoleMethod(0)).toEqual('debug')\n })\n})\ndescribe('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\ndescribe('createConsoleLogReporter', () => {\n let fakeConsole = createFakeConsole()\n beforeEach(() => polyfill.console = fakeConsole = createFakeConsole())\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\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 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 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\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 test('are written according to their log level value', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter()\n\n const sl = createStandardLog({\n logLevel: logLevels.all,\n customLevels: {\n 'high': 50,\n 'important': 450,\n 'interest': 650,\n 'silly': 1000\n },\n reporters: [reporter]\n })\n const log = sl.getLogger([id])\n log.high('a')\n log.important('b')\n log.interest('c')\n log.silly('d')\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 expect(reporter.formatter).toBe(idFormatter)\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['id-only']])\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 expect(reporter.filter).toBe(filter)\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\n test('write log entry with multiple arguments', () => {\n const id = 'log'\n const reporter = createConsoleLogReporter({ formatter: plainLogFormatter })\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\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/errors.d.ts
CHANGED
|
@@ -4,16 +4,6 @@ export declare class StandardLogError extends ModuleError {
|
|
|
4
4
|
}
|
|
5
5
|
export declare class InvalidId extends StandardLogError {
|
|
6
6
|
id: string;
|
|
7
|
-
constructor(id: string);
|
|
8
|
-
}
|
|
9
|
-
export declare class ProhibitedDuringProduction extends StandardLogError {
|
|
10
|
-
action: string;
|
|
11
|
-
constructor(action: string);
|
|
12
|
-
}
|
|
13
|
-
export declare class InvalidEnvVar extends StandardLogError {
|
|
14
|
-
name: string;
|
|
15
|
-
value: string;
|
|
16
|
-
possibleValues: string[];
|
|
17
|
-
constructor(name: string, value: string, possibleValues: string[]);
|
|
7
|
+
constructor(id: string, options?: IsoError.Options);
|
|
18
8
|
}
|
|
19
9
|
//# sourceMappingURL=errors.d.ts.map
|
package/esm/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG5D;AACD,qBAAa,SAAU,SAAQ,gBAAgB;IAC1B,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG5D;AACD,qBAAa,SAAU,SAAQ,gBAAgB;IAC1B,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG1D"}
|
package/esm/errors.js
CHANGED
|
@@ -5,8 +5,8 @@ export class StandardLogError extends ModuleError {
|
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
export class InvalidId extends StandardLogError {
|
|
8
|
-
constructor(id) {
|
|
9
|
-
super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}
|
|
8
|
+
constructor(id, options) {
|
|
9
|
+
super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options);
|
|
10
10
|
Object.defineProperty(this, "id", {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
configurable: true,
|
|
@@ -15,38 +15,4 @@ export class InvalidId extends StandardLogError {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
export class ProhibitedDuringProduction extends StandardLogError {
|
|
19
|
-
constructor(action) {
|
|
20
|
-
super(`Cannot perform ${action} during production`);
|
|
21
|
-
Object.defineProperty(this, "action", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
writable: true,
|
|
25
|
-
value: action
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export class InvalidEnvVar extends StandardLogError {
|
|
30
|
-
constructor(name, value, possibleValues) {
|
|
31
|
-
super(`${name} contains invalid value '${value}'${` valid values: [${possibleValues.join()}]`}`);
|
|
32
|
-
Object.defineProperty(this, "name", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true,
|
|
36
|
-
value: name
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(this, "value", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: value
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(this, "possibleValues", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true,
|
|
48
|
-
value: possibleValues
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
18
|
//# sourceMappingURL=errors.js.map
|
package/esm/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C,YAAY,WAAmB,EAAE,OAA0B;QACzD,KAAK,CAAC,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;CACF;AACD,MAAM,OAAO,SAAU,SAAQ,gBAAgB;IAC7C,YAAmB,EAAU;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C,YAAY,WAAmB,EAAE,OAA0B;QACzD,KAAK,CAAC,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;CACF;AACD,MAAM,OAAO,SAAU,SAAQ,gBAAgB;IAC7C,YAAmB,EAAU,EAAE,OAA0B;QACvD,KAAK,CAAC,kFAAkF,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;;;;;mBADrF;;IAEnB,CAAC;CACF","sourcesContent":["import { IsoError, ModuleError } from 'iso-error'\n\nexport class StandardLogError extends ModuleError {\n constructor(description: string, options?: IsoError.Options) {\n super('standard-log', description, options)\n }\n}\nexport class InvalidId extends StandardLogError {\n constructor(public id: string, options?: IsoError.Options) {\n super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options)\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LogEntry } from './types.js';
|
|
2
|
+
export declare type TimestampFormat = 'none' | 'iso' | 'elapsed';
|
|
3
|
+
export declare function createTimestampFormatter(format: TimestampFormat): ((_timestamp: Date) => undefined) | ((timestamp: Date) => string);
|
|
4
|
+
export declare function formatLogLevel(level: number): string;
|
|
5
|
+
export declare function plainLogFormatter({ id, level, args, timestamp }: LogEntry): any[];
|
|
6
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,oBAAY,eAAe,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAA;AAExD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,iBAGtC,IAAI,+BAEL,IAAI,aAW5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAE3C;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,SAEzE"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import ms from 'ms';
|
|
2
|
+
import { upperCase } from 'upper-case';
|
|
3
|
+
import { toLogLevelName } from './logLevels.js';
|
|
2
4
|
export function createTimestampFormatter(format) {
|
|
3
5
|
switch (format) {
|
|
4
6
|
case 'none':
|
|
@@ -6,7 +8,7 @@ export function createTimestampFormatter(format) {
|
|
|
6
8
|
case 'iso':
|
|
7
9
|
return (timestamp) => timestamp.toISOString();
|
|
8
10
|
case 'elapsed': {
|
|
9
|
-
let lastTick
|
|
11
|
+
let lastTick;
|
|
10
12
|
return (timestamp) => {
|
|
11
13
|
const newTick = timestamp.getTime();
|
|
12
14
|
const result = ms(lastTick === undefined ? 0 : newTick - lastTick);
|
|
@@ -16,4 +18,10 @@ export function createTimestampFormatter(format) {
|
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
|
-
|
|
21
|
+
export function formatLogLevel(level) {
|
|
22
|
+
return `(${upperCase(toLogLevelName(level))})`;
|
|
23
|
+
}
|
|
24
|
+
export function plainLogFormatter({ id, level, args, timestamp }) {
|
|
25
|
+
return [timestamp.toISOString(), id, formatLogLevel(level), ...args];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAK/C,MAAM,UAAU,wBAAwB,CAAC,MAAuB;IAC9D,QAAQ,MAAM,EAAE;QACd,KAAK,MAAM;YACT,OAAO,CAAC,UAAgB,EAAE,EAAE,CAAC,SAAS,CAAA;QACxC,KAAK,KAAK;YACR,OAAO,CAAC,SAAe,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,CAAA;QACrD,KAAK,SAAS,CAAC,CAAC;YACd,IAAI,QAAgB,CAAA;YACpB,OAAO,CAAC,SAAe,EAAE,EAAE;gBACzB,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,EAAE,CAAA;gBACnC,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAA;gBAClE,QAAQ,GAAG,OAAO,CAAA;gBAClB,OAAO,MAAM,CAAA;YACf,CAAC,CAAA;SACF;KACF;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,IAAI,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,GAAG,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAY;IACxE,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import ms from 'ms'\nimport { upperCase } from 'upper-case'\nimport { toLogLevelName } from './logLevels.js'\nimport type { LogEntry } from './types.js'\n\nexport type TimestampFormat = 'none' | 'iso' | 'elapsed'\n\nexport function createTimestampFormatter(format: TimestampFormat) {\n switch (format) {\n case 'none':\n return (_timestamp: Date) => undefined\n case 'iso':\n return (timestamp: Date) => timestamp.toISOString()\n case 'elapsed': {\n let lastTick: number\n return (timestamp: Date) => {\n const newTick = timestamp.getTime()\n const result = ms(lastTick === undefined ? 0 : newTick - lastTick)\n lastTick = newTick\n return result\n }\n }\n }\n}\n\nexport function formatLogLevel(level: number) {\n return `(${upperCase(toLogLevelName(level))})`\n}\n\nexport function plainLogFormatter({ id, level, args, timestamp }: LogEntry) {\n return [timestamp.toISOString(), id, formatLogLevel(level), ...args]\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.spec.d.ts","sourceRoot":"","sources":["../ts/formatter.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createTimestampFormatter, logLevels, plainLogFormatter } from './index.js';
|
|
2
|
+
describe('plainLogFormatter()', () => {
|
|
3
|
+
it('convert log entries to string', () => {
|
|
4
|
+
const timestamp = new Date(2019, 6);
|
|
5
|
+
const actual = plainLogFormatter({ id: 'plain', level: logLevels.emergency, args: ['emergency'], timestamp });
|
|
6
|
+
expect(actual).toEqual([timestamp.toISOString(), 'plain', `(EMERGENCY)`, `emergency`]);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
describe('createTimestampFormatter()', () => {
|
|
10
|
+
test('none', () => {
|
|
11
|
+
const formatter = createTimestampFormatter('none');
|
|
12
|
+
const now = new Date();
|
|
13
|
+
const actual = [formatter(now)];
|
|
14
|
+
expect(actual).toEqual([undefined]);
|
|
15
|
+
});
|
|
16
|
+
test('iso', () => {
|
|
17
|
+
const formatter = createTimestampFormatter('iso');
|
|
18
|
+
const now = new Date();
|
|
19
|
+
const actual = [formatter(now)];
|
|
20
|
+
expect(actual).toEqual([now.toISOString()]);
|
|
21
|
+
});
|
|
22
|
+
test('elapsed', () => {
|
|
23
|
+
const formatter = createTimestampFormatter('elapsed');
|
|
24
|
+
const now = new Date();
|
|
25
|
+
const next = new Date(now.getTime() + 10);
|
|
26
|
+
const actual = [formatter(now), formatter(next)];
|
|
27
|
+
expect(actual).toEqual(['0ms', '10ms']);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=formatter.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.spec.js","sourceRoot":"","sources":["../ts/formatter.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,+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C,CAAA;QACrD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;QAEhD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { createTimestampFormatter, logLevels, plainLogFormatter } from './index.js'\n\ndescribe('plainLogFormatter()', () => {\n it('convert log entries to string', () => {\n const timestamp = new Date(2019, 6)\n const actual = plainLogFormatter({ id: 'plain', level: logLevels.emergency, args: ['emergency'], timestamp })\n\n expect(actual).toEqual([timestamp.toISOString(), 'plain', `(EMERGENCY)`, `emergency`])\n })\n})\n\ndescribe('createTimestampFormatter()', () => {\n test('none', () => {\n const formatter = createTimestampFormatter('none')\n const now = new Date()\n const actual = [formatter(now)]\n expect(actual).toEqual([undefined])\n })\n\n test('iso', () => {\n const formatter = createTimestampFormatter('iso')\n const now = new Date()\n const actual = [formatter(now)]\n expect(actual).toEqual([now.toISOString()])\n })\n\n test('elapsed', () => {\n const formatter = createTimestampFormatter('elapsed')\n const now = new Date()\n const next = new Date(now.getTime() + 10)\n const actual = [formatter(now), formatter(next)]\n\n expect(actual).toEqual(['0ms', '10ms'])\n })\n})\n"]}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './config.js';
|
|
3
|
-
export * from './configForTest.js';
|
|
4
|
-
export * from './console/index.js';
|
|
5
|
-
export * from './customLogLevel.js';
|
|
1
|
+
export * from './console.js';
|
|
6
2
|
export * from './errors.js';
|
|
7
|
-
export * from './formatter
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './logReporter.js';
|
|
12
|
-
export * from './memory/index.js';
|
|
13
|
-
export * from './shouldLog.js';
|
|
14
|
-
export * from './suppressLogs.js';
|
|
3
|
+
export * from './formatter.js';
|
|
4
|
+
export * from './logLevels.js';
|
|
5
|
+
export * from './memory.js';
|
|
6
|
+
export * from './standardLog.js';
|
|
15
7
|
export * from './types.js';
|
|
16
|
-
export * from './utils.js';
|
|
17
8
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}
|
package/esm/index.js
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './config.js';
|
|
3
|
-
export * from './configForTest.js';
|
|
4
|
-
export * from './console/index.js';
|
|
5
|
-
export * from './customLogLevel.js';
|
|
1
|
+
export * from './console.js';
|
|
6
2
|
export * from './errors.js';
|
|
7
|
-
export * from './formatter
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './logReporter.js';
|
|
12
|
-
export * from './memory/index.js';
|
|
13
|
-
export * from './shouldLog.js';
|
|
14
|
-
export * from './suppressLogs.js';
|
|
3
|
+
export * from './formatter.js';
|
|
4
|
+
export * from './logLevels.js';
|
|
5
|
+
export * from './memory.js';
|
|
6
|
+
export * from './standardLog.js';
|
|
15
7
|
export * from './types.js';
|
|
16
|
-
export * from './utils.js';
|
|
17
8
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA","sourcesContent":["export * from './console.js'\nexport * from './errors.js'\nexport * from './formatter.js'\nexport * from './logLevels.js'\nexport * from './memory.js'\nexport * from './standardLog.js'\nexport * from './types.js'\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare const logLevels: {
|
|
2
|
+
/**
|
|
3
|
+
* none: 0
|
|
4
|
+
*/
|
|
5
|
+
none: number;
|
|
6
|
+
/**
|
|
7
|
+
* emergency: 100
|
|
8
|
+
*/
|
|
9
|
+
emergency: number;
|
|
10
|
+
/**
|
|
11
|
+
* alert: 200
|
|
12
|
+
*/
|
|
13
|
+
alert: number;
|
|
14
|
+
/**
|
|
15
|
+
* critical: 300
|
|
16
|
+
*/
|
|
17
|
+
critical: number;
|
|
18
|
+
/**
|
|
19
|
+
* error: 400
|
|
20
|
+
*/
|
|
21
|
+
error: number;
|
|
22
|
+
/**
|
|
23
|
+
* warn: 500
|
|
24
|
+
*/
|
|
25
|
+
warn: number;
|
|
26
|
+
/**
|
|
27
|
+
* notice: 600
|
|
28
|
+
*/
|
|
29
|
+
notice: number;
|
|
30
|
+
/**
|
|
31
|
+
* info: 700
|
|
32
|
+
*/
|
|
33
|
+
info: number;
|
|
34
|
+
/**
|
|
35
|
+
* debug: 800
|
|
36
|
+
*/
|
|
37
|
+
debug: number;
|
|
38
|
+
/**
|
|
39
|
+
* trace: 900
|
|
40
|
+
*/
|
|
41
|
+
trace: number;
|
|
42
|
+
/**
|
|
43
|
+
* planck: Infinity
|
|
44
|
+
* `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.
|
|
45
|
+
*/
|
|
46
|
+
planck: number;
|
|
47
|
+
/**
|
|
48
|
+
* all: Infinity
|
|
49
|
+
*/
|
|
50
|
+
all: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Convert default log level value to log level name.
|
|
54
|
+
*/
|
|
55
|
+
export declare function toLogLevelName(level: number): "emergency" | "alert" | "critical" | "error" | "warn" | "notice" | "info" | "debug" | "trace" | "planck";
|
|
56
|
+
/**
|
|
57
|
+
* Convert default log level name to log level value.
|
|
58
|
+
*/
|
|
59
|
+
export declare function toLogLevel(name: string): any;
|
|
60
|
+
//# sourceMappingURL=logLevels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logLevels.d.ts","sourceRoot":"","sources":["../ts/logLevels.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;IACpB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;CAEJ,CAAA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,4GAW3C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,OAEtC"}
|
|
@@ -50,7 +50,33 @@ export const logLevels = {
|
|
|
50
50
|
all: Infinity
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Convert default log level value to log level name.
|
|
54
54
|
*/
|
|
55
|
-
export
|
|
56
|
-
|
|
55
|
+
export function toLogLevelName(level) {
|
|
56
|
+
if (level <= 100)
|
|
57
|
+
return 'emergency';
|
|
58
|
+
if (level <= 200)
|
|
59
|
+
return 'alert';
|
|
60
|
+
if (level <= 300)
|
|
61
|
+
return 'critical';
|
|
62
|
+
if (level <= 400)
|
|
63
|
+
return 'error';
|
|
64
|
+
if (level <= 500)
|
|
65
|
+
return 'warn';
|
|
66
|
+
if (level <= 600)
|
|
67
|
+
return 'notice';
|
|
68
|
+
if (level <= 700)
|
|
69
|
+
return 'info';
|
|
70
|
+
if (level <= 800)
|
|
71
|
+
return 'debug';
|
|
72
|
+
if (level <= 900)
|
|
73
|
+
return 'trace';
|
|
74
|
+
return 'planck';
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Convert default log level name to log level value.
|
|
78
|
+
*/
|
|
79
|
+
export function toLogLevel(name) {
|
|
80
|
+
return logLevels[name.toLocaleLowerCase()];
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=logLevels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logLevels.js","sourceRoot":"","sources":["../ts/logLevels.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,CAAC;IACP;;OAEG;IACH,SAAS,EAAE,GAAG;IACd;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;OAEG;IACH,QAAQ,EAAE,GAAG;IACb;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;OAEG;IACH,IAAI,EAAE,GAAG;IACT;;OAEG;IACH,MAAM,EAAE,GAAG;IACX;;OAEG;IACH,IAAI,EAAE,GAAG;IACT;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;;OAGG;IACH,MAAM,EAAE,QAAQ;IAChB;;OAEG;IACH,GAAG,EAAE,QAAQ;CACd,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,WAAW,CAAA;IACpC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,UAAU,CAAA;IACnC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,QAAQ,CAAA;IACjC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAQ,SAAiB,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;AACrD,CAAC","sourcesContent":["export const logLevels = {\n /**\n * none: 0\n */\n none: 0,\n /**\n * emergency: 100\n */\n emergency: 100,\n /**\n * alert: 200\n */\n alert: 200,\n /**\n * critical: 300\n */\n critical: 300,\n /**\n * error: 400\n */\n error: 400,\n /**\n * warn: 500\n */\n warn: 500,\n /**\n * notice: 600\n */\n notice: 600,\n /**\n * info: 700\n */\n info: 700,\n /**\n * debug: 800\n */\n debug: 800,\n /**\n * trace: 900\n */\n trace: 900,\n /**\n * planck: Infinity\n * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.\n */\n planck: Infinity,\n /**\n * all: Infinity\n */\n all: Infinity\n}\n\n/**\n * Convert default log level value to log level name.\n */\nexport function toLogLevelName(level: number) {\n if (level <= 100) return 'emergency'\n if (level <= 200) return 'alert'\n if (level <= 300) return 'critical'\n if (level <= 400) return 'error'\n if (level <= 500) return 'warn'\n if (level <= 600) return 'notice'\n if (level <= 700) return 'info'\n if (level <= 800) return 'debug'\n if (level <= 900) return 'trace'\n return 'planck'\n}\n\n/**\n * Convert default log level name to log level value.\n */\nexport function toLogLevel(name: string) {\n return (logLevels as any)[name.toLocaleLowerCase()]\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Logger, LogLevel, LogReporter, StandardLogOptions } from './types.js';
|
|
2
|
+
export declare function createLogStore(options: StandardLogOptions): LogStore;
|
|
3
|
+
export interface LogStore {
|
|
4
|
+
loggers: Record<string, Logger>;
|
|
5
|
+
reporters: LogReporter[];
|
|
6
|
+
logLevel: LogLevel;
|
|
7
|
+
logLevelStore: ReturnType<typeof logLevelStore>;
|
|
8
|
+
}
|
|
9
|
+
export interface LogLevelStoreOptions {
|
|
10
|
+
customLevels?: Record<string, number>;
|
|
11
|
+
}
|
|
12
|
+
export declare function logLevelStore(options: LogLevelStoreOptions): {
|
|
13
|
+
getName(level: number): string;
|
|
14
|
+
getLevel(name: string): number;
|
|
15
|
+
getAllLevels(): {
|
|
16
|
+
name: string;
|
|
17
|
+
level: number;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=logStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../ts/logStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEnF,wBAAgB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,QAAQ,CAOpE;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;CAChD;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACtC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB;mBAWxC,MAAM;mBAGN,MAAM;;;;;EAWxB"}
|
package/esm/logStore.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { mapKey, reduceByKey, reduceKey } from 'type-plus';
|
|
2
|
+
import { createConsoleLogReporter } from './console.js';
|
|
3
|
+
import { logLevels, toLogLevel, toLogLevelName } from './logLevels.js';
|
|
4
|
+
export function createLogStore(options) {
|
|
5
|
+
return {
|
|
6
|
+
loggers: {},
|
|
7
|
+
reporters: options.reporters || [createConsoleLogReporter()],
|
|
8
|
+
logLevel: options.logLevel,
|
|
9
|
+
logLevelStore: logLevelStore(options)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function logLevelStore(options) {
|
|
13
|
+
const customLevels = options.customLevels || {};
|
|
14
|
+
const store = {
|
|
15
|
+
customLevels,
|
|
16
|
+
customLevelsReverse: reduceByKey(customLevels, (p, k) => {
|
|
17
|
+
p[customLevels[k]] = k;
|
|
18
|
+
return p;
|
|
19
|
+
}, {})
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
getName(level) {
|
|
23
|
+
return store.customLevelsReverse[level] ?? toLogLevelName(level);
|
|
24
|
+
},
|
|
25
|
+
getLevel(name) {
|
|
26
|
+
return store.customLevels[name] ?? toLogLevel(name);
|
|
27
|
+
},
|
|
28
|
+
getAllLevels() {
|
|
29
|
+
return reduceKey(logLevels, (result, name) => {
|
|
30
|
+
if (name !== 'none' && name !== 'all')
|
|
31
|
+
result.push({ name, level: logLevels[name] });
|
|
32
|
+
return result;
|
|
33
|
+
}, mapKey(store.customLevels, name => ({ name, level: store.customLevels[name] })));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=logStore.js.map
|