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
|
@@ -0,0 +1,548 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var assertron_1 = require("assertron");
|
|
40
|
+
var errors_js_1 = require("./errors.js");
|
|
41
|
+
var logLevels_js_1 = require("./logLevels.js");
|
|
42
|
+
var memory_js_1 = require("./memory.js");
|
|
43
|
+
var standardLog_js_1 = require("./standardLog.js");
|
|
44
|
+
var testUtil_js_1 = require("./testUtil.js");
|
|
45
|
+
describe('createStandardLog()', function () {
|
|
46
|
+
describe('logLevel', function () {
|
|
47
|
+
it('is default to info', function () {
|
|
48
|
+
var actual = (0, standardLog_js_1.createStandardLog)();
|
|
49
|
+
expect(actual.logLevel).toBe(logLevels_js_1.logLevels.info);
|
|
50
|
+
});
|
|
51
|
+
it('is readonly', function () {
|
|
52
|
+
var actual = (0, standardLog_js_1.createStandardLog)();
|
|
53
|
+
assertron_1.assertron.throws(function () { return actual.logLevel = logLevels_js_1.logLevels.planck; }, function (err) { return /only a getter/.test(err); });
|
|
54
|
+
});
|
|
55
|
+
it('set logLevel from options', function () {
|
|
56
|
+
var actual = (0, standardLog_js_1.createStandardLog)({ logLevel: logLevels_js_1.logLevels.planck });
|
|
57
|
+
expect(actual.logLevel).toBe(logLevels_js_1.logLevels.planck);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe('custom levels', function () {
|
|
61
|
+
it('can define custom levels', function () {
|
|
62
|
+
var actual = (0, standardLog_js_1.createStandardLog)({ customLevels: { urgent: 80 } });
|
|
63
|
+
expect(actual.toLogLevelName(80)).toBe('urgent');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
describe('reporters', function () {
|
|
67
|
+
it('can specify reporter', function () {
|
|
68
|
+
var mem = (0, memory_js_1.createMemoryLogReporter)();
|
|
69
|
+
var sl = (0, standardLog_js_1.createStandardLog)({ reporters: [mem] });
|
|
70
|
+
var log = sl.getLogger(['x']);
|
|
71
|
+
log.info('abc');
|
|
72
|
+
expect(mem.logs.length).toBe(1);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('createStandardLogForTest()', function () {
|
|
77
|
+
it('returns with memory reporter', function () {
|
|
78
|
+
var reporter = (0, standardLog_js_1.createStandardLogForTest)().reporter;
|
|
79
|
+
expect(reporter.getLogMessageWithLevel()).toBe('');
|
|
80
|
+
});
|
|
81
|
+
it('defaults to debug', function () {
|
|
82
|
+
var store = (0, standardLog_js_1.createStandardLogForTest)();
|
|
83
|
+
expect(store.logLevel).toBe(logLevels_js_1.logLevels.debug);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
describe('getLogger()', function () {
|
|
87
|
+
it('supports id with alphanumeric and :_-.', function () {
|
|
88
|
+
var sl = (0, standardLog_js_1.createStandardLog)();
|
|
89
|
+
sl.getLogger(['abcdefghijklmnopqrstuvwxyz:-_.1234567890']);
|
|
90
|
+
});
|
|
91
|
+
it('supports id with unicode', function () {
|
|
92
|
+
var sl = (0, standardLog_js_1.createStandardLog)();
|
|
93
|
+
sl.getLogger(['ミク香港']);
|
|
94
|
+
});
|
|
95
|
+
it('supports id with @, \\ and /', function () {
|
|
96
|
+
var sl = (0, standardLog_js_1.createStandardLog)();
|
|
97
|
+
sl.getLogger(['@unional/fixture']);
|
|
98
|
+
sl.getLogger(["a\\b\\c"]);
|
|
99
|
+
});
|
|
100
|
+
it.each('`~!#$%^&*()=+|[]{}<>,?'.split(''))('throws if id has unsupported character %s', function (char) {
|
|
101
|
+
var sl = (0, standardLog_js_1.createStandardLog)();
|
|
102
|
+
assertron_1.assertron.throws(function () { return sl.getLogger([char]); }, errors_js_1.InvalidId);
|
|
103
|
+
});
|
|
104
|
+
it('throw InvalidId with ssf to the call site', function () {
|
|
105
|
+
var sl = (0, standardLog_js_1.createStandardLog)();
|
|
106
|
+
var err = assertron_1.assertron.throws(function () { return sl.getLogger(['!']); }, errors_js_1.InvalidId);
|
|
107
|
+
(0, testUtil_js_1.assertSSF)(err, __filename);
|
|
108
|
+
});
|
|
109
|
+
test('id is readonly', function () {
|
|
110
|
+
var sl = (0, standardLog_js_1.createStandardLog)();
|
|
111
|
+
var log = sl.getLogger(['id is readonly']);
|
|
112
|
+
assertron_1.assertron.throws(function () { return log.id = 'b'; });
|
|
113
|
+
});
|
|
114
|
+
test('get logger with same name gets the same instance', function () {
|
|
115
|
+
var sl = (0, standardLog_js_1.createStandardLog)();
|
|
116
|
+
var expected = sl.getLogger(['same-inst']);
|
|
117
|
+
var actual = sl.getLogger(['same-inst']);
|
|
118
|
+
expect(actual).toBe(expected);
|
|
119
|
+
});
|
|
120
|
+
it('can specify local log level', function () {
|
|
121
|
+
var sl = (0, standardLog_js_1.createStandardLog)();
|
|
122
|
+
var log = sl.getLogger(['local', { level: logLevels_js_1.logLevels.trace }]);
|
|
123
|
+
expect(log.level).toBe(logLevels_js_1.logLevels.trace);
|
|
124
|
+
});
|
|
125
|
+
test('new logger will get custom level', function () {
|
|
126
|
+
var sl = (0, standardLog_js_1.createStandardLog)({ customLevels: { 'to_logger': 1234 } });
|
|
127
|
+
var actual = sl.getLogger(['to_logger_logger']);
|
|
128
|
+
expect(typeof actual.to_logger).toBe('function');
|
|
129
|
+
});
|
|
130
|
+
it('Logger have at least the default log method names', function () {
|
|
131
|
+
function wrapper(options) {
|
|
132
|
+
var sl = (0, standardLog_js_1.createStandardLog)(options);
|
|
133
|
+
// since `N` is generic, just `Logger<N>` will not have the default log method names.
|
|
134
|
+
var log = sl.getLogger(['local']);
|
|
135
|
+
expect(log.info).toBeDefined();
|
|
136
|
+
return sl;
|
|
137
|
+
}
|
|
138
|
+
var sl = wrapper({ customLevels: { 'cust': 123 } });
|
|
139
|
+
var actual = sl.getLogger(['c']);
|
|
140
|
+
expect(actual.cust).toBeDefined();
|
|
141
|
+
});
|
|
142
|
+
describe('log levels', function () {
|
|
143
|
+
function assertLoggedAtLevel(sl, method, level) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
+
var log, msg;
|
|
146
|
+
return __generator(this, function (_a) {
|
|
147
|
+
log = sl.getLogger([method]);
|
|
148
|
+
msg = "should log on level: ".concat(level);
|
|
149
|
+
log[method](msg);
|
|
150
|
+
assertron_1.assertron.satisfies(sl.reporter.logs, [{ id: method, level: sl.toLogLevel(method), args: [msg] }]);
|
|
151
|
+
return [2 /*return*/];
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function assertNotLoggedAtLevel(sl, method, level) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
157
|
+
var log;
|
|
158
|
+
return __generator(this, function (_a) {
|
|
159
|
+
log = sl.getLogger([method]);
|
|
160
|
+
log[method]("should not log on level: ".concat(level));
|
|
161
|
+
expect(sl.reporter.logs.length).toBe(0);
|
|
162
|
+
return [2 /*return*/];
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function assertLoggedAtLocalLevel(sl, method, localLevel) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var log, msg;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
log = sl.getLogger([method, { level: localLevel }]);
|
|
171
|
+
msg = "should log on level: ".concat(localLevel);
|
|
172
|
+
log[method](msg);
|
|
173
|
+
assertron_1.assertron.satisfies(sl.reporter.logs, [{ id: log.id, level: sl.toLogLevel(method), args: [msg] }]);
|
|
174
|
+
return [2 /*return*/];
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function assertNotLoggedAtLocalLevel(sl, method, localLevel) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
180
|
+
var log;
|
|
181
|
+
return __generator(this, function (_a) {
|
|
182
|
+
log = sl.getLogger([method, { level: localLevel }]);
|
|
183
|
+
log[method]("should not log on level: ".concat(localLevel));
|
|
184
|
+
expect(sl.reporter.logs.length).toBe(0);
|
|
185
|
+
return [2 /*return*/];
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function assertLoggedAtCallLevel(sl, method, callLevel) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
+
var log, actual;
|
|
192
|
+
return __generator(this, function (_a) {
|
|
193
|
+
log = sl.getLogger([method]);
|
|
194
|
+
actual = false;
|
|
195
|
+
log.on(callLevel, function () { return actual = true; });
|
|
196
|
+
expect(actual).toBe(true);
|
|
197
|
+
return [2 /*return*/];
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function assertNotLoggedAtCallLevel(sl, method, callLevel, actualLevel) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
203
|
+
var log;
|
|
204
|
+
return __generator(this, function (_a) {
|
|
205
|
+
log = sl.getLogger([method]);
|
|
206
|
+
log.on(callLevel, function () { throw new Error("should not log at level ".concat(actualLevel)); });
|
|
207
|
+
return [2 /*return*/];
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function assertLoggedAtCallLevelOverrideLocalLevel(sl, method, localLevel, callLevel) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
var log, actual;
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
log = sl.getLogger([method, { level: localLevel }]);
|
|
216
|
+
actual = false;
|
|
217
|
+
log.on(callLevel, function () { return actual = true; });
|
|
218
|
+
expect(actual).toBe(true);
|
|
219
|
+
return [2 /*return*/];
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function assertNotLoggedAtCallLevelOverrideLocalLevel(sl, method, localLevel, callLevel) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
+
var log;
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
log = sl.getLogger([method, { level: localLevel }]);
|
|
228
|
+
log.on(callLevel, function () { throw new Error("should not log at level ".concat(localLevel)); });
|
|
229
|
+
return [2 /*return*/];
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
var shouldLog = (0, testUtil_js_1.wrapTest)(function (test) { return function (method, level) {
|
|
234
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)(level);
|
|
235
|
+
var name = sl.toLogLevelName(level);
|
|
236
|
+
test("".concat(method, "() should log on level: ").concat(name, " (").concat(level, ")"), function () {
|
|
237
|
+
return assertLoggedAtLevel(sl, method, level);
|
|
238
|
+
});
|
|
239
|
+
}; });
|
|
240
|
+
var shouldNotLog = (0, testUtil_js_1.wrapTest)(function (test) { return function (method, level) {
|
|
241
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)(level);
|
|
242
|
+
var name = sl.toLogLevelName(level);
|
|
243
|
+
test("".concat(method, "() should not log on level: ").concat(name, " (").concat(level, ")"), function () {
|
|
244
|
+
return assertNotLoggedAtLevel(sl, method, level);
|
|
245
|
+
});
|
|
246
|
+
}; });
|
|
247
|
+
var shouldLogWithLocalLevelOverride = (0, testUtil_js_1.wrapTest)(function (test) { return function (method, localLevel) {
|
|
248
|
+
var localName = (0, logLevels_js_1.toLogLevelName)(localLevel);
|
|
249
|
+
[logLevels_js_1.logLevels.none, logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.debug].forEach(function (globalLevel) {
|
|
250
|
+
var globalName = (0, logLevels_js_1.toLogLevelName)(globalLevel) || 'none';
|
|
251
|
+
test("".concat(method, "() should log on local level: ").concat(localName, " (").concat(localLevel, ") while global level: ").concat(globalName, " (").concat(globalLevel, ")"), function () {
|
|
252
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)(globalLevel);
|
|
253
|
+
return assertLoggedAtLocalLevel(sl, method, localLevel);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}; });
|
|
257
|
+
var shouldNotLogWithLocalLevelOverride = (0, testUtil_js_1.wrapTest)(function (test) { return function (method, localLevel) {
|
|
258
|
+
var localName = (0, logLevels_js_1.toLogLevelName)(localLevel);
|
|
259
|
+
[logLevels_js_1.logLevels.none, logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.debug].forEach(function (globalLevel) {
|
|
260
|
+
var globalName = (0, logLevels_js_1.toLogLevelName)(globalLevel) || 'none';
|
|
261
|
+
test("".concat(method, "() should not log on local level: ").concat(localName, " (").concat(localLevel, ") while global level: ").concat(globalName, " (").concat(globalLevel, ")"), function () {
|
|
262
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)(globalLevel);
|
|
263
|
+
return assertNotLoggedAtLocalLevel(sl, method, localLevel);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
}; });
|
|
267
|
+
var shouldCallLogFunction = (0, testUtil_js_1.wrapTest)(function (test) { return function (callLevel, actualLevel) {
|
|
268
|
+
var method = (0, logLevels_js_1.toLogLevelName)(callLevel);
|
|
269
|
+
var name = (0, logLevels_js_1.toLogLevelName)(actualLevel);
|
|
270
|
+
test("".concat(method, "() should call log function on level: ").concat(name, " (").concat(actualLevel, ")"), function () {
|
|
271
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)(actualLevel);
|
|
272
|
+
return assertLoggedAtCallLevel(sl, method, callLevel);
|
|
273
|
+
});
|
|
274
|
+
}; });
|
|
275
|
+
var shouldNotCallLogFunction = (0, testUtil_js_1.wrapTest)(function (test) { return function (callLevel, actualLevel) {
|
|
276
|
+
var method = (0, logLevels_js_1.toLogLevelName)(callLevel);
|
|
277
|
+
var name = (0, logLevels_js_1.toLogLevelName)(actualLevel);
|
|
278
|
+
test("".concat(method, "() should not call log function on level: ").concat(name, " (").concat(actualLevel, ")"), function () {
|
|
279
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)(actualLevel);
|
|
280
|
+
return assertNotLoggedAtCallLevel(sl, method, callLevel, actualLevel);
|
|
281
|
+
});
|
|
282
|
+
}; });
|
|
283
|
+
var shouldCallLogFunctionWithLocalLevelOverride = (0, testUtil_js_1.wrapTest)(function (test) { return function (callLevel, localLevel) {
|
|
284
|
+
var method = (0, logLevels_js_1.toLogLevelName)(callLevel);
|
|
285
|
+
var localName = (0, logLevels_js_1.toLogLevelName)(localLevel);
|
|
286
|
+
[logLevels_js_1.logLevels.none, logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.debug].forEach(function (globalLevel) {
|
|
287
|
+
var globalName = (0, logLevels_js_1.toLogLevelName)(globalLevel) || 'none';
|
|
288
|
+
test("".concat(method, "() should log on local level: ").concat(localName, " (").concat(localLevel, ") while global level: ").concat(globalName, " (").concat(globalLevel, ")"), function () {
|
|
289
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)(globalLevel);
|
|
290
|
+
return assertLoggedAtCallLevelOverrideLocalLevel(sl, method, localLevel, callLevel);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}; });
|
|
294
|
+
var shouldNotCallLogFunctionWithLocalLevelOverride = (0, testUtil_js_1.wrapTest)(function (test) { return function (callLevel, localLevel) {
|
|
295
|
+
var method = (0, logLevels_js_1.toLogLevelName)(callLevel);
|
|
296
|
+
var localName = (0, logLevels_js_1.toLogLevelName)(localLevel);
|
|
297
|
+
[logLevels_js_1.logLevels.none, logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.debug].forEach(function (globalLevel) {
|
|
298
|
+
var globalName = (0, logLevels_js_1.toLogLevelName)(globalLevel) || 'none';
|
|
299
|
+
test("".concat(method, "() should not log on local level: ").concat(localName, " (").concat(localLevel, ") while global level: ").concat(globalName, " (").concat(globalLevel, ")"), function () {
|
|
300
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)(globalLevel);
|
|
301
|
+
return assertNotLoggedAtCallLevelOverrideLocalLevel(sl, method, localLevel, callLevel);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}; });
|
|
305
|
+
shouldNotLog('error', logLevels_js_1.logLevels.none);
|
|
306
|
+
shouldLog('error', logLevels_js_1.logLevels.error);
|
|
307
|
+
shouldLog('error', logLevels_js_1.logLevels.warn);
|
|
308
|
+
shouldLog('error', logLevels_js_1.logLevels.info);
|
|
309
|
+
shouldLog('error', logLevels_js_1.logLevels.debug);
|
|
310
|
+
shouldNotLogWithLocalLevelOverride('error', logLevels_js_1.logLevels.none);
|
|
311
|
+
shouldLogWithLocalLevelOverride('error', logLevels_js_1.logLevels.error);
|
|
312
|
+
shouldLogWithLocalLevelOverride('error', logLevels_js_1.logLevels.warn);
|
|
313
|
+
shouldLogWithLocalLevelOverride('error', logLevels_js_1.logLevels.info);
|
|
314
|
+
shouldLogWithLocalLevelOverride('error', logLevels_js_1.logLevels.debug);
|
|
315
|
+
shouldNotLog('warn', logLevels_js_1.logLevels.none);
|
|
316
|
+
shouldNotLog('warn', logLevels_js_1.logLevels.error);
|
|
317
|
+
shouldLog('warn', logLevels_js_1.logLevels.warn);
|
|
318
|
+
shouldLog('warn', logLevels_js_1.logLevels.info);
|
|
319
|
+
shouldLog('warn', logLevels_js_1.logLevels.debug);
|
|
320
|
+
shouldNotLogWithLocalLevelOverride('warn', logLevels_js_1.logLevels.none);
|
|
321
|
+
shouldNotLogWithLocalLevelOverride('warn', logLevels_js_1.logLevels.error);
|
|
322
|
+
shouldLogWithLocalLevelOverride('warn', logLevels_js_1.logLevels.warn);
|
|
323
|
+
shouldLogWithLocalLevelOverride('warn', logLevels_js_1.logLevels.info);
|
|
324
|
+
shouldLogWithLocalLevelOverride('warn', logLevels_js_1.logLevels.debug);
|
|
325
|
+
shouldNotLog('info', logLevels_js_1.logLevels.none);
|
|
326
|
+
shouldNotLog('info', logLevels_js_1.logLevels.error);
|
|
327
|
+
shouldNotLog('info', logLevels_js_1.logLevels.warn);
|
|
328
|
+
shouldLog('info', logLevels_js_1.logLevels.info);
|
|
329
|
+
shouldLog('info', logLevels_js_1.logLevels.debug);
|
|
330
|
+
shouldNotLogWithLocalLevelOverride('info', logLevels_js_1.logLevels.none);
|
|
331
|
+
shouldNotLogWithLocalLevelOverride('info', logLevels_js_1.logLevels.error);
|
|
332
|
+
shouldNotLogWithLocalLevelOverride('info', logLevels_js_1.logLevels.warn);
|
|
333
|
+
shouldLogWithLocalLevelOverride('info', logLevels_js_1.logLevels.info);
|
|
334
|
+
shouldLogWithLocalLevelOverride('info', logLevels_js_1.logLevels.debug);
|
|
335
|
+
shouldNotLog('debug', logLevels_js_1.logLevels.none);
|
|
336
|
+
shouldNotLog('debug', logLevels_js_1.logLevels.error);
|
|
337
|
+
shouldNotLog('debug', logLevels_js_1.logLevels.warn);
|
|
338
|
+
shouldNotLog('debug', logLevels_js_1.logLevels.info);
|
|
339
|
+
shouldLog('debug', logLevels_js_1.logLevels.debug);
|
|
340
|
+
shouldNotLogWithLocalLevelOverride('debug', logLevels_js_1.logLevels.none);
|
|
341
|
+
shouldNotLogWithLocalLevelOverride('debug', logLevels_js_1.logLevels.error);
|
|
342
|
+
shouldNotLogWithLocalLevelOverride('debug', logLevels_js_1.logLevels.warn);
|
|
343
|
+
shouldNotLogWithLocalLevelOverride('debug', logLevels_js_1.logLevels.info);
|
|
344
|
+
shouldLogWithLocalLevelOverride('debug', logLevels_js_1.logLevels.debug);
|
|
345
|
+
shouldNotCallLogFunction(logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.none);
|
|
346
|
+
shouldCallLogFunction(logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.error);
|
|
347
|
+
shouldCallLogFunction(logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.warn);
|
|
348
|
+
shouldCallLogFunction(logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.info);
|
|
349
|
+
shouldCallLogFunction(logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.debug);
|
|
350
|
+
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.none);
|
|
351
|
+
shouldCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.error);
|
|
352
|
+
shouldCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.warn);
|
|
353
|
+
shouldCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.info);
|
|
354
|
+
shouldCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.error, logLevels_js_1.logLevels.debug);
|
|
355
|
+
shouldNotCallLogFunction(logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.none);
|
|
356
|
+
shouldNotCallLogFunction(logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.error);
|
|
357
|
+
shouldCallLogFunction(logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.warn);
|
|
358
|
+
shouldCallLogFunction(logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.info);
|
|
359
|
+
shouldCallLogFunction(logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.debug);
|
|
360
|
+
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.none);
|
|
361
|
+
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.error);
|
|
362
|
+
shouldCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.warn);
|
|
363
|
+
shouldCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.info);
|
|
364
|
+
shouldCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.warn, logLevels_js_1.logLevels.debug);
|
|
365
|
+
shouldNotCallLogFunction(logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.none);
|
|
366
|
+
shouldNotCallLogFunction(logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.error);
|
|
367
|
+
shouldNotCallLogFunction(logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.warn);
|
|
368
|
+
shouldCallLogFunction(logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.info);
|
|
369
|
+
shouldCallLogFunction(logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.debug);
|
|
370
|
+
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.none);
|
|
371
|
+
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.error);
|
|
372
|
+
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.warn);
|
|
373
|
+
shouldCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.info);
|
|
374
|
+
shouldCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.info, logLevels_js_1.logLevels.debug);
|
|
375
|
+
shouldNotCallLogFunction(logLevels_js_1.logLevels.debug, logLevels_js_1.logLevels.none);
|
|
376
|
+
shouldNotCallLogFunction(logLevels_js_1.logLevels.debug, logLevels_js_1.logLevels.error);
|
|
377
|
+
shouldNotCallLogFunction(logLevels_js_1.logLevels.debug, logLevels_js_1.logLevels.warn);
|
|
378
|
+
shouldNotCallLogFunction(logLevels_js_1.logLevels.debug, logLevels_js_1.logLevels.info);
|
|
379
|
+
shouldCallLogFunction(logLevels_js_1.logLevels.debug, logLevels_js_1.logLevels.debug);
|
|
380
|
+
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.debug, logLevels_js_1.logLevels.none);
|
|
381
|
+
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.debug, logLevels_js_1.logLevels.error);
|
|
382
|
+
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.debug, logLevels_js_1.logLevels.warn);
|
|
383
|
+
shouldNotCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.debug, logLevels_js_1.logLevels.info);
|
|
384
|
+
shouldCallLogFunctionWithLocalLevelOverride(logLevels_js_1.logLevels.debug, logLevels_js_1.logLevels.debug);
|
|
385
|
+
});
|
|
386
|
+
it('writes entry directly', function () {
|
|
387
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)();
|
|
388
|
+
var log = sl.getLogger(['write-entry']);
|
|
389
|
+
var entry = { id: 'write-entry', level: logLevels_js_1.logLevels.info, args: ['abc'], timestamp: new Date() };
|
|
390
|
+
log.write(entry);
|
|
391
|
+
assertron_1.assertron.satisfies(sl.reporter.logs, [entry]);
|
|
392
|
+
});
|
|
393
|
+
test.each(['on', 'count', 'error', 'warn', 'info', 'debug'])('method %s is readonly', function (name) {
|
|
394
|
+
var sl = (0, standardLog_js_1.createStandardLog)();
|
|
395
|
+
var log = sl.getLogger(["".concat(name, " is readonly")]);
|
|
396
|
+
assertron_1.assertron.throws(function () { return log[name] = true; });
|
|
397
|
+
});
|
|
398
|
+
describe('on()', function () {
|
|
399
|
+
it('log using log argument', function () {
|
|
400
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)();
|
|
401
|
+
var logger = sl.getLogger(['log on fn']);
|
|
402
|
+
logger.on('error', function (log) { log('value'); });
|
|
403
|
+
assertron_1.assertron.satisfies(sl.reporter.logs, [
|
|
404
|
+
{ id: 'log on fn', level: logLevels_js_1.logLevels.error, args: ['value'] }
|
|
405
|
+
]);
|
|
406
|
+
});
|
|
407
|
+
it('can take log level name in first argument', function () {
|
|
408
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)();
|
|
409
|
+
var log = sl.getLogger(['string-on']);
|
|
410
|
+
log.on('debug', function () { return; });
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
describe('count()', function () {
|
|
414
|
+
test('will increment the counter', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
415
|
+
var sl, logger;
|
|
416
|
+
return __generator(this, function (_a) {
|
|
417
|
+
sl = (0, standardLog_js_1.createStandardLogForTest)();
|
|
418
|
+
logger = sl.getLogger(['inc counter']);
|
|
419
|
+
logger.count();
|
|
420
|
+
logger.count();
|
|
421
|
+
assertron_1.assertron.satisfies(sl.reporter.logs, [
|
|
422
|
+
{ id: 'inc counter', level: logLevels_js_1.logLevels.debug, args: [1] },
|
|
423
|
+
{ id: 'inc counter', level: logLevels_js_1.logLevels.debug, args: [2] }
|
|
424
|
+
]);
|
|
425
|
+
return [2 /*return*/];
|
|
426
|
+
});
|
|
427
|
+
}); });
|
|
428
|
+
test('append args after the counter', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
429
|
+
var sl, id, logger;
|
|
430
|
+
return __generator(this, function (_a) {
|
|
431
|
+
sl = (0, standardLog_js_1.createStandardLogForTest)(logLevels_js_1.logLevels.debug);
|
|
432
|
+
id = 'inc with args';
|
|
433
|
+
logger = sl.getLogger([id]);
|
|
434
|
+
logger.count('msg1', 'msg2');
|
|
435
|
+
assertron_1.assertron.satisfies(sl.reporter.logs, [
|
|
436
|
+
{ id: id, level: logLevels_js_1.logLevels.debug, args: [1, 'msg1', 'msg2'] }
|
|
437
|
+
]);
|
|
438
|
+
return [2 /*return*/];
|
|
439
|
+
});
|
|
440
|
+
}); });
|
|
441
|
+
test('not log if log level is less than debug', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
442
|
+
var sl, id, logger;
|
|
443
|
+
return __generator(this, function (_a) {
|
|
444
|
+
sl = (0, standardLog_js_1.createStandardLogForTest)(logLevels_js_1.logLevels.debug - 1);
|
|
445
|
+
id = 'inc with args';
|
|
446
|
+
logger = sl.getLogger([id]);
|
|
447
|
+
logger.count('msg1', 'msg2');
|
|
448
|
+
expect(sl.reporter.logs.length).toBe(0);
|
|
449
|
+
return [2 /*return*/];
|
|
450
|
+
});
|
|
451
|
+
}); });
|
|
452
|
+
});
|
|
453
|
+
test('logger with custom level', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
454
|
+
var mem, sl, logger;
|
|
455
|
+
return __generator(this, function (_a) {
|
|
456
|
+
mem = (0, memory_js_1.createMemoryLogReporter)();
|
|
457
|
+
sl = (0, standardLog_js_1.createStandardLog)({ customLevels: { 'cust_lvl': 100 }, reporters: [mem] });
|
|
458
|
+
logger = sl.getLogger(['cust']);
|
|
459
|
+
logger.cust_lvl('a', 'b');
|
|
460
|
+
assertron_1.assertron.satisfies(mem.logs, [{ id: 'cust', level: 100, args: ['a', 'b'] }]);
|
|
461
|
+
return [2 /*return*/];
|
|
462
|
+
});
|
|
463
|
+
}); });
|
|
464
|
+
describe('getLogger([,{ writeTo }])', function () {
|
|
465
|
+
function testWriteTo(loggerParams, handler) {
|
|
466
|
+
var memReporter = (0, memory_js_1.createMemoryLogReporter)();
|
|
467
|
+
var specialReporter = (0, memory_js_1.createMemoryLogReporter)({ id: 'special' });
|
|
468
|
+
var sl = (0, standardLog_js_1.createStandardLog)({ reporters: [memReporter, specialReporter] });
|
|
469
|
+
var log = sl.getLogger(loggerParams);
|
|
470
|
+
handler(log, memReporter.logs, specialReporter.logs, sl);
|
|
471
|
+
}
|
|
472
|
+
it('can specify which reporter to use by name', function () {
|
|
473
|
+
testWriteTo(['writeTo-string', { writeTo: 'special' }], function (log, memLogs, specialLogs) {
|
|
474
|
+
log.error('error message');
|
|
475
|
+
expect(memLogs.length).toEqual(0);
|
|
476
|
+
expect(specialLogs.length).toEqual(1);
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
it('can specify which reporter to use by regex', function () {
|
|
480
|
+
testWriteTo(['writeTo-regex', { writeTo: /^spec/ }], function (log, memLogs, specialLogs) {
|
|
481
|
+
log.error('error message');
|
|
482
|
+
expect(memLogs.length).toEqual(0);
|
|
483
|
+
expect(specialLogs.length).toEqual(1);
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
it('can specify which reporter to use by RegExp', function () {
|
|
487
|
+
testWriteTo(['writeTo-RegExp', { writeTo: new RegExp('^spec') }], function (log, memLogs, specialLogs) {
|
|
488
|
+
log.error('error message');
|
|
489
|
+
expect(memLogs.length).toEqual(0);
|
|
490
|
+
expect(specialLogs.length).toEqual(1);
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
it('can specify which reporter to use by function', function () {
|
|
494
|
+
testWriteTo(['writeTo-fn', { writeTo: function (id) { return id === 'special'; } }], function (log, memLogs, specialLogs) {
|
|
495
|
+
log.error('error message');
|
|
496
|
+
expect(memLogs.length).toEqual(0);
|
|
497
|
+
expect(specialLogs.length).toEqual(1);
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
it('can specify custom reporter', function () {
|
|
501
|
+
var reporter = (0, memory_js_1.createMemoryLogReporter)({ id: 'custom mem' });
|
|
502
|
+
testWriteTo(['writeTo-reporter', { writeTo: reporter }], function (log, memLogs, specialLogs) {
|
|
503
|
+
log.error('error message');
|
|
504
|
+
expect(memLogs.length).toEqual(0);
|
|
505
|
+
expect(specialLogs.length).toEqual(0);
|
|
506
|
+
expect(reporter.logs.length).toEqual(1);
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
test('the custom console reporter cannot pick up logs from other loggers', function () {
|
|
510
|
+
// if not, it would be a security issue as the new reporter
|
|
511
|
+
// can capture the logs from other logger and send it elsewhere
|
|
512
|
+
var reporter = (0, memory_js_1.createMemoryLogReporter)({ id: 'custom mem' });
|
|
513
|
+
testWriteTo(['writeTo-reporter-no-override', { writeTo: reporter }], function (_, memLogs, specialLogs, sl) {
|
|
514
|
+
var log = sl.getLogger(['writeTo-reporter-no-override-2']);
|
|
515
|
+
log.error('error message');
|
|
516
|
+
expect(reporter.logs.length).toEqual(0);
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
describe('suppressLogs()', function () {
|
|
522
|
+
test('suppress log', function () {
|
|
523
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)();
|
|
524
|
+
var log = sl.getLogger(['l']);
|
|
525
|
+
(0, standardLog_js_1.suppressLogs)(function () {
|
|
526
|
+
log.alert('should not see me');
|
|
527
|
+
}, log);
|
|
528
|
+
expect(sl.reporter.getLogMessageWithLevel()).toBe('');
|
|
529
|
+
});
|
|
530
|
+
test('suppress multiple logs', function () {
|
|
531
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)();
|
|
532
|
+
var log1 = sl.getLogger(['l1']);
|
|
533
|
+
var log2 = sl.getLogger(['l2']);
|
|
534
|
+
(0, standardLog_js_1.suppressLogs)(function () {
|
|
535
|
+
log1.alert('should not see me');
|
|
536
|
+
log2.alert('should not see me too');
|
|
537
|
+
}, log1, log2);
|
|
538
|
+
expect(sl.reporter.getLogMessageWithLevel()).toBe('');
|
|
539
|
+
});
|
|
540
|
+
test('return block result', function () {
|
|
541
|
+
var sl = (0, standardLog_js_1.createStandardLogForTest)();
|
|
542
|
+
var log1 = sl.getLogger(['l']);
|
|
543
|
+
var log2 = sl.getLogger(['l2']);
|
|
544
|
+
var a = (0, standardLog_js_1.suppressLogs)(function () { return 1; }, log1, log2);
|
|
545
|
+
expect(a).toBe(1);
|
|
546
|
+
});
|
|
547
|
+
});
|
|
548
|
+
//# sourceMappingURL=standardLog.spec.js.map
|