standard-log 8.0.1 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -133
- package/{esm/console/createConsoleLogReporter.d.ts → cjs/console.d.ts} +5 -5
- package/cjs/console.d.ts.map +1 -0
- package/cjs/console.js +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 -68
- package/cjs/console.spec.js.map +1 -0
- package/cjs/errors.d.ts +0 -10
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js +1 -43
- package/cjs/errors.js.map +1 -1
- package/cjs/formatter.d.ts +6 -0
- package/cjs/formatter.d.ts.map +1 -0
- package/cjs/formatter.js +46 -0
- package/cjs/formatter.js.map +1 -0
- package/cjs/formatter.spec.d.ts +2 -0
- package/cjs/formatter.spec.d.ts.map +1 -0
- package/cjs/formatter.spec.js +32 -0
- package/cjs/formatter.spec.js.map +1 -0
- package/cjs/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 +536 -0
- package/cjs/standardLog.spec.js.map +1 -0
- package/cjs/testUtil.d.ts +7 -5
- package/cjs/testUtil.d.ts.map +1 -1
- package/cjs/testUtil.js +11 -14
- package/cjs/testUtil.js.map +1 -1
- package/cjs/types.d.ts +33 -24
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js.map +1 -1
- package/dist/standard-log.es5.js +324 -1078
- 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 +307 -1145
- 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 -65
- package/esm/console.spec.js.map +1 -0
- package/esm/errors.d.ts +0 -10
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js +0 -34
- package/esm/errors.js.map +1 -1
- package/esm/formatter.d.ts +6 -0
- package/esm/formatter.d.ts.map +1 -0
- package/esm/{formatter/createTimestampFormatter.js → formatter.js} +10 -2
- package/esm/formatter.js.map +1 -0
- package/esm/formatter.spec.d.ts +2 -0
- package/esm/formatter.spec.d.ts.map +1 -0
- package/esm/formatter.spec.js +30 -0
- package/esm/formatter.spec.js.map +1 -0
- package/esm/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 +434 -0
- package/esm/standardLog.spec.js.map +1 -0
- package/esm/testUtil.d.ts +7 -5
- package/esm/testUtil.d.ts.map +1 -1
- package/esm/testUtil.js +8 -12
- package/esm/testUtil.js.map +1 -1
- package/esm/types.d.ts +33 -24
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/package.json +10 -19
- package/ts/console.ts +72 -0
- package/ts/errors.ts +0 -12
- 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 -72
- package/cjs/config.spec.js.map +0 -1
- package/cjs/configForTest.d.ts +0 -5
- package/cjs/configForTest.d.ts.map +0 -1
- package/cjs/configForTest.js +0 -18
- package/cjs/configForTest.js.map +0 -1
- package/cjs/configForTest.spec.d.ts +0 -2
- package/cjs/configForTest.spec.d.ts.map +0 -1
- package/cjs/configForTest.spec.js +0 -17
- package/cjs/configForTest.spec.js.map +0 -1
- package/cjs/console/createConsoleLogReporter.d.ts.map +0 -1
- package/cjs/console/createConsoleLogReporter.js +0 -42
- package/cjs/console/createConsoleLogReporter.js.map +0 -1
- package/cjs/console/createConsoleLogReporter.spec.d.ts +0 -2
- package/cjs/console/createConsoleLogReporter.spec.d.ts.map +0 -1
- package/cjs/console/createConsoleLogReporter.spec.js.map +0 -1
- package/cjs/console/index.d.ts +0 -4
- package/cjs/console/index.d.ts.map +0 -1
- package/cjs/console/index.js +0 -20
- package/cjs/console/index.js.map +0 -1
- package/cjs/console/isConsoleDebugAvailable.d.ts +0 -2
- package/cjs/console/isConsoleDebugAvailable.d.ts.map +0 -1
- package/cjs/console/isConsoleDebugAvailable.js +0 -20
- package/cjs/console/isConsoleDebugAvailable.js.map +0 -1
- package/cjs/console/polyfilledConsole.d.ts +0 -7
- package/cjs/console/polyfilledConsole.d.ts.map +0 -1
- package/cjs/console/polyfilledConsole.js +0 -41
- package/cjs/console/polyfilledConsole.js.map +0 -1
- package/cjs/console/semverGt.d.ts +0 -2
- package/cjs/console/semverGt.d.ts.map +0 -1
- package/cjs/console/semverGt.js +0 -13
- package/cjs/console/semverGt.js.map +0 -1
- package/cjs/console/semverGt.spec.d.ts +0 -2
- package/cjs/console/semverGt.spec.d.ts.map +0 -1
- package/cjs/console/semverGt.spec.js +0 -22
- package/cjs/console/semverGt.spec.js.map +0 -1
- package/cjs/console/toConsoleMethod.d.ts +0 -2
- package/cjs/console/toConsoleMethod.d.ts.map +0 -1
- package/cjs/console/toConsoleMethod.js +0 -22
- package/cjs/console/toConsoleMethod.js.map +0 -1
- package/cjs/console/types.d.ts +0 -3
- package/cjs/console/types.d.ts.map +0 -1
- package/cjs/console/types.js +0 -3
- package/cjs/console/types.js.map +0 -1
- package/cjs/customLogLevel.d.ts +0 -11
- package/cjs/customLogLevel.d.ts.map +0 -1
- package/cjs/customLogLevel.js +0 -38
- package/cjs/customLogLevel.js.map +0 -1
- package/cjs/customLogLevel.spec.d.ts +0 -2
- package/cjs/customLogLevel.spec.d.ts.map +0 -1
- package/cjs/customLogLevel.spec.js +0 -37
- package/cjs/customLogLevel.spec.js.map +0 -1
- package/cjs/formatter/createTimestampFormatter.d.ts +0 -3
- package/cjs/formatter/createTimestampFormatter.d.ts.map +0 -1
- package/cjs/formatter/createTimestampFormatter.js +0 -26
- package/cjs/formatter/createTimestampFormatter.js.map +0 -1
- package/cjs/formatter/createTimestampFormatter.spec.d.ts +0 -2
- package/cjs/formatter/createTimestampFormatter.spec.d.ts.map +0 -1
- package/cjs/formatter/createTimestampFormatter.spec.js +0 -23
- package/cjs/formatter/createTimestampFormatter.spec.js.map +0 -1
- package/cjs/formatter/formatLogLevel.d.ts +0 -2
- package/cjs/formatter/formatLogLevel.d.ts.map +0 -1
- package/cjs/formatter/formatLogLevel.js +0 -10
- package/cjs/formatter/formatLogLevel.js.map +0 -1
- package/cjs/formatter/index.d.ts +0 -4
- package/cjs/formatter/index.d.ts.map +0 -1
- package/cjs/formatter/index.js +0 -20
- package/cjs/formatter/index.js.map +0 -1
- package/cjs/formatter/plainLogFormatter.d.ts +0 -3
- package/cjs/formatter/plainLogFormatter.d.ts.map +0 -1
- package/cjs/formatter/plainLogFormatter.js +0 -19
- package/cjs/formatter/plainLogFormatter.js.map +0 -1
- package/cjs/formatter/plainLogFormatter.spec.d.ts +0 -2
- package/cjs/formatter/plainLogFormatter.spec.d.ts.map +0 -1
- package/cjs/formatter/plainLogFormatter.spec.js +0 -9
- package/cjs/formatter/plainLogFormatter.spec.js.map +0 -1
- package/cjs/getDefaultReporter.browser.d.ts +0 -2
- package/cjs/getDefaultReporter.browser.d.ts.map +0 -1
- package/cjs/getDefaultReporter.browser.js +0 -15
- package/cjs/getDefaultReporter.browser.js.map +0 -1
- package/cjs/getDefaultReporter.d.ts +0 -2
- package/cjs/getDefaultReporter.d.ts.map +0 -1
- package/cjs/getDefaultReporter.js +0 -19
- package/cjs/getDefaultReporter.js.map +0 -1
- package/cjs/getLogModeFromEnvironment.browser.d.ts +0 -3
- package/cjs/getLogModeFromEnvironment.browser.d.ts.map +0 -1
- package/cjs/getLogModeFromEnvironment.browser.js +0 -9
- package/cjs/getLogModeFromEnvironment.browser.js.map +0 -1
- package/cjs/getLogModeFromEnvironment.d.ts +0 -3
- package/cjs/getLogModeFromEnvironment.d.ts.map +0 -1
- package/cjs/getLogModeFromEnvironment.js +0 -17
- package/cjs/getLogModeFromEnvironment.js.map +0 -1
- package/cjs/getLogModeFromEnvironment.spec.d.ts +0 -2
- package/cjs/getLogModeFromEnvironment.spec.d.ts.map +0 -1
- package/cjs/getLogModeFromEnvironment.spec.js +0 -25
- package/cjs/getLogModeFromEnvironment.spec.js.map +0 -1
- package/cjs/getLogger.d.ts +0 -9
- package/cjs/getLogger.d.ts.map +0 -1
- package/cjs/getLogger.js +0 -103
- package/cjs/getLogger.js.map +0 -1
- package/cjs/getLogger.spec.d.ts +0 -2
- package/cjs/getLogger.spec.d.ts.map +0 -1
- package/cjs/getLogger.spec.js +0 -485
- package/cjs/getLogger.spec.js.map +0 -1
- package/cjs/getLoggers.d.ts +0 -7
- package/cjs/getLoggers.d.ts.map +0 -1
- package/cjs/getLoggers.js +0 -15
- package/cjs/getLoggers.js.map +0 -1
- package/cjs/logLevel.d.ts +0 -106
- package/cjs/logLevel.d.ts.map +0 -1
- package/cjs/logLevel.js +0 -59
- package/cjs/logLevel.js.map +0 -1
- package/cjs/logLevel.spec.d.ts +0 -2
- package/cjs/logLevel.spec.d.ts.map +0 -1
- package/cjs/logLevel.spec.js +0 -195
- package/cjs/logLevel.spec.js.map +0 -1
- package/cjs/logLevelFn.d.ts +0 -20
- package/cjs/logLevelFn.d.ts.map +0 -1
- package/cjs/logLevelFn.js +0 -76
- package/cjs/logLevelFn.js.map +0 -1
- package/cjs/logReporter.d.ts +0 -7
- package/cjs/logReporter.d.ts.map +0 -1
- package/cjs/logReporter.js +0 -29
- package/cjs/logReporter.js.map +0 -1
- package/cjs/logReporter.spec.d.ts +0 -2
- package/cjs/logReporter.spec.d.ts.map +0 -1
- package/cjs/logReporter.spec.js +0 -98
- package/cjs/logReporter.spec.js.map +0 -1
- package/cjs/logReporterInternal.d.ts +0 -3
- package/cjs/logReporterInternal.d.ts.map +0 -1
- package/cjs/logReporterInternal.js +0 -23
- package/cjs/logReporterInternal.js.map +0 -1
- package/cjs/memory/MemoryLogReporter.d.ts.map +0 -1
- package/cjs/memory/MemoryLogReporter.js +0 -56
- package/cjs/memory/MemoryLogReporter.js.map +0 -1
- package/cjs/memory/MemoryLogReporter.spec.d.ts +0 -2
- package/cjs/memory/MemoryLogReporter.spec.d.ts.map +0 -1
- package/cjs/memory/MemoryLogReporter.spec.js +0 -124
- package/cjs/memory/MemoryLogReporter.spec.js.map +0 -1
- package/cjs/memory/index.d.ts +0 -3
- package/cjs/memory/index.d.ts.map +0 -1
- package/cjs/memory/index.js +0 -19
- package/cjs/memory/index.js.map +0 -1
- package/cjs/memory/logEntriesToString.d.ts +0 -3
- package/cjs/memory/logEntriesToString.d.ts.map +0 -1
- package/cjs/memory/logEntriesToString.js +0 -10
- package/cjs/memory/logEntriesToString.js.map +0 -1
- package/cjs/memory/logEntriesToString.spec.d.ts +0 -2
- package/cjs/memory/logEntriesToString.spec.d.ts.map +0 -1
- package/cjs/memory/logEntriesToString.spec.js +0 -36
- package/cjs/memory/logEntriesToString.spec.js.map +0 -1
- package/cjs/memory/toInspectStringForObject.d.ts +0 -3
- package/cjs/memory/toInspectStringForObject.d.ts.map +0 -1
- package/cjs/memory/toInspectStringForObject.js +0 -17
- package/cjs/memory/toInspectStringForObject.js.map +0 -1
- package/cjs/shouldLog.d.ts +0 -8
- package/cjs/shouldLog.d.ts.map +0 -1
- package/cjs/shouldLog.js +0 -14
- package/cjs/shouldLog.js.map +0 -1
- package/cjs/store.d.ts +0 -3
- package/cjs/store.d.ts.map +0 -1
- package/cjs/store.js +0 -27
- package/cjs/store.js.map +0 -1
- package/cjs/suppressLogs.d.ts +0 -6
- package/cjs/suppressLogs.d.ts.map +0 -1
- package/cjs/suppressLogs.js +0 -17
- package/cjs/suppressLogs.js.map +0 -1
- package/cjs/suppressLogs.spec.d.ts +0 -2
- package/cjs/suppressLogs.spec.d.ts.map +0 -1
- package/cjs/suppressLogs.spec.js +0 -31
- package/cjs/suppressLogs.spec.js.map +0 -1
- package/cjs/typesInternal.d.ts +0 -20
- package/cjs/typesInternal.d.ts.map +0 -1
- package/cjs/typesInternal.js +0 -3
- package/cjs/typesInternal.js.map +0 -1
- package/cjs/utils.d.ts +0 -6
- package/cjs/utils.d.ts.map +0 -1
- package/cjs/utils.js +0 -15
- package/cjs/utils.js.map +0 -1
- package/cjs/writeToReporters.d.ts +0 -6
- package/cjs/writeToReporters.d.ts.map +0 -1
- package/cjs/writeToReporters.js +0 -22
- package/cjs/writeToReporters.js.map +0 -1
- package/cjs/writeToReporters.spec.d.ts +0 -2
- package/cjs/writeToReporters.spec.d.ts.map +0 -1
- package/cjs/writeToReporters.spec.js +0 -59
- package/cjs/writeToReporters.spec.js.map +0 -1
- package/esm/LogEntry.d.ts +0 -7
- package/esm/LogEntry.d.ts.map +0 -1
- package/esm/LogEntry.js +0 -2
- package/esm/LogEntry.js.map +0 -1
- package/esm/captureLogs.d.ts +0 -4
- package/esm/captureLogs.d.ts.map +0 -1
- package/esm/captureLogs.js +0 -29
- package/esm/captureLogs.js.map +0 -1
- package/esm/captureLogs.spec.d.ts +0 -2
- package/esm/captureLogs.spec.d.ts.map +0 -1
- package/esm/captureLogs.spec.js +0 -45
- package/esm/captureLogs.spec.js.map +0 -1
- package/esm/config.d.ts +0 -12
- package/esm/config.d.ts.map +0 -1
- package/esm/config.js +0 -44
- package/esm/config.js.map +0 -1
- package/esm/config.spec.d.ts +0 -2
- package/esm/config.spec.d.ts.map +0 -1
- package/esm/config.spec.js +0 -67
- package/esm/config.spec.js.map +0 -1
- package/esm/configForTest.d.ts +0 -5
- package/esm/configForTest.d.ts.map +0 -1
- package/esm/configForTest.js +0 -14
- package/esm/configForTest.js.map +0 -1
- package/esm/configForTest.spec.d.ts +0 -2
- package/esm/configForTest.spec.d.ts.map +0 -1
- package/esm/configForTest.spec.js +0 -15
- package/esm/configForTest.spec.js.map +0 -1
- package/esm/console/createConsoleLogReporter.d.ts.map +0 -1
- package/esm/console/createConsoleLogReporter.js +0 -37
- package/esm/console/createConsoleLogReporter.js.map +0 -1
- package/esm/console/createConsoleLogReporter.spec.d.ts +0 -2
- package/esm/console/createConsoleLogReporter.spec.d.ts.map +0 -1
- package/esm/console/createConsoleLogReporter.spec.js.map +0 -1
- package/esm/console/index.d.ts +0 -4
- package/esm/console/index.d.ts.map +0 -1
- package/esm/console/index.js +0 -4
- package/esm/console/index.js.map +0 -1
- package/esm/console/isConsoleDebugAvailable.d.ts +0 -2
- package/esm/console/isConsoleDebugAvailable.d.ts.map +0 -1
- package/esm/console/isConsoleDebugAvailable.js +0 -13
- package/esm/console/isConsoleDebugAvailable.js.map +0 -1
- package/esm/console/polyfilledConsole.d.ts +0 -7
- package/esm/console/polyfilledConsole.d.ts.map +0 -1
- package/esm/console/polyfilledConsole.js.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 -20
- package/esm/getLogModeFromEnvironment.spec.js.map +0 -1
- package/esm/getLogger.d.ts +0 -9
- package/esm/getLogger.d.ts.map +0 -1
- package/esm/getLogger.js +0 -78
- package/esm/getLogger.js.map +0 -1
- package/esm/getLogger.spec.d.ts +0 -2
- package/esm/getLogger.spec.d.ts.map +0 -1
- package/esm/getLogger.spec.js +0 -385
- package/esm/getLogger.spec.js.map +0 -1
- package/esm/getLoggers.d.ts +0 -7
- package/esm/getLoggers.d.ts.map +0 -1
- package/esm/getLoggers.js +0 -11
- package/esm/getLoggers.js.map +0 -1
- package/esm/logLevel.d.ts +0 -106
- package/esm/logLevel.d.ts.map +0 -1
- package/esm/logLevel.js.map +0 -1
- package/esm/logLevel.spec.d.ts +0 -2
- package/esm/logLevel.spec.d.ts.map +0 -1
- package/esm/logLevel.spec.js +0 -148
- package/esm/logLevel.spec.js.map +0 -1
- package/esm/logLevelFn.d.ts +0 -20
- package/esm/logLevelFn.d.ts.map +0 -1
- package/esm/logLevelFn.js +0 -67
- package/esm/logLevelFn.js.map +0 -1
- package/esm/logReporter.d.ts +0 -7
- package/esm/logReporter.d.ts.map +0 -1
- package/esm/logReporter.js +0 -21
- package/esm/logReporter.js.map +0 -1
- package/esm/logReporter.spec.d.ts +0 -2
- package/esm/logReporter.spec.d.ts.map +0 -1
- package/esm/logReporter.spec.js +0 -93
- package/esm/logReporter.spec.js.map +0 -1
- package/esm/logReporterInternal.d.ts +0 -3
- package/esm/logReporterInternal.d.ts.map +0 -1
- package/esm/logReporterInternal.js +0 -19
- package/esm/logReporterInternal.js.map +0 -1
- package/esm/memory/MemoryLogReporter.d.ts.map +0 -1
- package/esm/memory/MemoryLogReporter.js +0 -51
- package/esm/memory/MemoryLogReporter.js.map +0 -1
- package/esm/memory/MemoryLogReporter.spec.d.ts +0 -2
- package/esm/memory/MemoryLogReporter.spec.d.ts.map +0 -1
- package/esm/memory/MemoryLogReporter.spec.js +0 -111
- package/esm/memory/MemoryLogReporter.spec.js.map +0 -1
- package/esm/memory/index.d.ts +0 -3
- package/esm/memory/index.d.ts.map +0 -1
- package/esm/memory/index.js +0 -3
- package/esm/memory/index.js.map +0 -1
- package/esm/memory/logEntriesToString.d.ts +0 -3
- package/esm/memory/logEntriesToString.d.ts.map +0 -1
- package/esm/memory/logEntriesToString.js +0 -6
- package/esm/memory/logEntriesToString.js.map +0 -1
- package/esm/memory/logEntriesToString.spec.d.ts +0 -2
- package/esm/memory/logEntriesToString.spec.d.ts.map +0 -1
- package/esm/memory/logEntriesToString.spec.js +0 -42
- package/esm/memory/logEntriesToString.spec.js.map +0 -1
- package/esm/memory/toInspectStringForObject.d.ts +0 -3
- package/esm/memory/toInspectStringForObject.d.ts.map +0 -1
- package/esm/memory/toInspectStringForObject.js +0 -11
- package/esm/memory/toInspectStringForObject.js.map +0 -1
- package/esm/shouldLog.d.ts +0 -8
- package/esm/shouldLog.d.ts.map +0 -1
- package/esm/shouldLog.js +0 -10
- package/esm/shouldLog.js.map +0 -1
- package/esm/store.d.ts +0 -3
- package/esm/store.d.ts.map +0 -1
- package/esm/store.js +0 -24
- package/esm/store.js.map +0 -1
- package/esm/suppressLogs.d.ts +0 -6
- package/esm/suppressLogs.d.ts.map +0 -1
- package/esm/suppressLogs.js +0 -9
- package/esm/suppressLogs.js.map +0 -1
- package/esm/suppressLogs.spec.d.ts +0 -2
- package/esm/suppressLogs.spec.d.ts.map +0 -1
- package/esm/suppressLogs.spec.js +0 -29
- package/esm/suppressLogs.spec.js.map +0 -1
- package/esm/typesInternal.d.ts +0 -20
- package/esm/typesInternal.d.ts.map +0 -1
- package/esm/typesInternal.js +0 -2
- package/esm/typesInternal.js.map +0 -1
- package/esm/utils.d.ts +0 -6
- package/esm/utils.d.ts.map +0 -1
- package/esm/utils.js +0 -11
- package/esm/utils.js.map +0 -1
- package/esm/writeToReporters.d.ts +0 -6
- package/esm/writeToReporters.d.ts.map +0 -1
- package/esm/writeToReporters.js +0 -18
- package/esm/writeToReporters.js.map +0 -1
- package/esm/writeToReporters.spec.d.ts +0 -2
- package/esm/writeToReporters.spec.d.ts.map +0 -1
- package/esm/writeToReporters.spec.js +0 -9
- package/esm/writeToReporters.spec.js.map +0 -1
- package/ts/LogEntry.ts +0 -7
- package/ts/captureLogs.ts +0 -35
- package/ts/config.ts +0 -57
- package/ts/configForTest.ts +0 -16
- package/ts/console/createConsoleLogReporter.ts +0 -48
- package/ts/console/index.ts +0 -3
- package/ts/console/isConsoleDebugAvailable.ts +0 -11
- package/ts/console/polyfilledConsole.ts +0 -34
- package/ts/console/semverGt.ts +0 -9
- package/ts/console/toConsoleMethod.ts +0 -18
- package/ts/console/types.ts +0 -3
- package/ts/customLogLevel.ts +0 -35
- package/ts/formatter/formatLogLevel.ts +0 -6
- package/ts/formatter/index.ts +0 -3
- package/ts/formatter/plainLogFormatter.ts +0 -6
- package/ts/getDefaultReporter.browser.ts +0 -13
- package/ts/getDefaultReporter.ts +0 -15
- package/ts/getLogModeFromEnvironment.browser.ts +0 -6
- package/ts/getLogModeFromEnvironment.ts +0 -16
- package/ts/getLogger.ts +0 -92
- package/ts/getLoggers.ts +0 -12
- package/ts/logLevelFn.ts +0 -72
- package/ts/logReporter.ts +0 -26
- package/ts/logReporterInternal.ts +0 -18
- package/ts/memory/MemoryLogReporter.ts +0 -72
- package/ts/memory/index.ts +0 -2
- package/ts/memory/logEntriesToString.ts +0 -7
- package/ts/memory/toInspectStringForObject.ts +0 -13
- package/ts/shouldLog.ts +0 -11
- package/ts/store.ts +0 -25
- package/ts/suppressLogs.ts +0 -14
- package/ts/typesInternal.ts +0 -21
- package/ts/utils.ts +0 -11
- package/ts/writeToReporters.ts +0 -20
package/cjs/logger.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createLogger = void 0;
|
|
13
|
+
var errors_js_1 = require("./errors.js");
|
|
14
|
+
var logLevels_js_1 = require("./logLevels.js");
|
|
15
|
+
function createLogger(_a, meta) {
|
|
16
|
+
var store = _a[0], id = _a[1], _b = _a[2], level = _b.level, _c = _b.writeTo, writeTo = _c === void 0 ? function () { return true; } : _c;
|
|
17
|
+
validateId(id, meta);
|
|
18
|
+
var _d = typeof writeTo === 'string'
|
|
19
|
+
? [function (id) { return id === writeTo; }, store.reporters]
|
|
20
|
+
: writeTo instanceof RegExp
|
|
21
|
+
? [function (id) { return writeTo.test(id); }, store.reporters]
|
|
22
|
+
: typeof writeTo === 'function'
|
|
23
|
+
? [writeTo, store.reporters]
|
|
24
|
+
: [function () { return true; }, [writeTo]], filter = _d[0], reporters = _d[1];
|
|
25
|
+
function write(entry) {
|
|
26
|
+
writeToReporters(reporters, entry, filter);
|
|
27
|
+
}
|
|
28
|
+
var logger = {
|
|
29
|
+
level: level,
|
|
30
|
+
write: write
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperties(logger, {
|
|
33
|
+
id: { value: id, writable: false },
|
|
34
|
+
count: {
|
|
35
|
+
writable: false,
|
|
36
|
+
value: (function (counter) { return function () {
|
|
37
|
+
var args = [];
|
|
38
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
39
|
+
args[_i] = arguments[_i];
|
|
40
|
+
}
|
|
41
|
+
var level = logLevels_js_1.logLevels.debug;
|
|
42
|
+
if (shouldLog(store, level, logger.level))
|
|
43
|
+
write({
|
|
44
|
+
id: id,
|
|
45
|
+
level: level,
|
|
46
|
+
args: __spreadArray([++counter], args, true),
|
|
47
|
+
timestamp: new Date()
|
|
48
|
+
});
|
|
49
|
+
}; })(0)
|
|
50
|
+
},
|
|
51
|
+
on: {
|
|
52
|
+
writable: false,
|
|
53
|
+
value: function (level, logFn) {
|
|
54
|
+
var logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level) : level;
|
|
55
|
+
if (shouldLog(store, logLevel, logger.level)) {
|
|
56
|
+
var methodName = store.logLevelStore.getName(logLevel);
|
|
57
|
+
var bindedMethod = logger[methodName].bind(logger);
|
|
58
|
+
var result = logFn(bindedMethod);
|
|
59
|
+
if (result)
|
|
60
|
+
bindedMethod(result);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
store.logLevelStore.getAllLevels().forEach(function addMethod(_a) {
|
|
66
|
+
var name = _a.name, level = _a.level;
|
|
67
|
+
Object.defineProperty(logger, name, {
|
|
68
|
+
writable: false,
|
|
69
|
+
value: function () {
|
|
70
|
+
var args = [];
|
|
71
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
72
|
+
args[_i] = arguments[_i];
|
|
73
|
+
}
|
|
74
|
+
if (shouldLog(store, level, logger.level))
|
|
75
|
+
write({ id: id, level: level, args: args, timestamp: new Date() });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
return logger;
|
|
80
|
+
}
|
|
81
|
+
exports.createLogger = createLogger;
|
|
82
|
+
function validateId(id, meta) {
|
|
83
|
+
if (/[`~!#$%^&*()=+[\]{},|<>?]/.test(id))
|
|
84
|
+
throw new errors_js_1.InvalidId(id, meta);
|
|
85
|
+
}
|
|
86
|
+
function writeToReporters(reporters, logEntry, filter) {
|
|
87
|
+
reporters.filter(function (r) { return filter(r.id); }).forEach(function (r) { return r.write(logEntry); });
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Determines should you log.
|
|
91
|
+
* @param loggerLevel Log level of the logger.
|
|
92
|
+
* It can be undefined which the global log level will be used.
|
|
93
|
+
*/
|
|
94
|
+
function shouldLog(store, targetLevel, loggerLevel) {
|
|
95
|
+
return targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.logLevel);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAuC;AACvC,+CAA0C;AAK1C,SAAgB,YAAY,CAC1B,EAAsG,EACtG,IAAqB;QADpB,KAAK,QAAA,EAAE,EAAE,QAAA,EAAE,UAA+B,EAA7B,KAAK,WAAA,EAAE,eAAoB,EAApB,OAAO,mBAAG,cAAM,OAAA,IAAI,EAAJ,CAAI,KAAA;IAGzC,UAAU,CAAC,EA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EAAE,EAAE,CAAC,CAAA;YAC9F,CAAC;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC;AA3DD,oCA2DC;AAED,SAAS,UAAU,CAAC,EAAU,EAAE,IAAqB;IACnD,IAAI,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,MAAM,IAAI,qBAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;AACzE,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAwB,EAAE,QAAkB,EAAE,MAAuC;IAC7G,SAAS,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAZ,CAAY,CAAC,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,CAAC,QAAS,CAAC,EAAlB,CAAkB,CAAC,CAAA;AACtE,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAe,EAAE,WAAqB,EAAE,WAAiC;IAC1F,OAAO,WAAW,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;AAClF,CAAC","sourcesContent":["import type { StackTraceMeta } from '@just-func/types'\nimport { RequiredPick } from 'type-plus'\nimport { InvalidId } from './errors.js'\nimport { logLevels } from './logLevels.js'\nimport { LogStore } from './logStore.js'\nimport type { LogEntry, LogFunction, Logger, LoggerOptions, LogMethodNames, LogReporter } from './types.js'\nimport { LogLevel } from './types.js'\n\nexport function createLogger<T extends string = LogMethodNames>(\n [store, id, { level, writeTo = () => true }]: [LogStore, string, RequiredPick<LoggerOptions, 'level'>],\n meta?: StackTraceMeta\n): Logger {\n validateId(id, meta)\n const [filter, reporters]: [(reporterId: string) => boolean, LogReporter[]] = typeof writeTo === 'string'\n ? [id => id === writeTo, store.reporters]\n : writeTo instanceof RegExp\n ? [id => writeTo.test(id), store.reporters]\n : typeof writeTo === 'function'\n ? [writeTo, store.reporters]\n : [() => true, [writeTo]]\n\n function write(entry: LogEntry) {\n writeToReporters(reporters, entry, filter)\n }\n\n const logger = {\n level,\n write\n } as any\n\n Object.defineProperties(logger, {\n id: { value: id, writable: false },\n count: {\n writable: false,\n value: ((counter) => (...args: any[]) => {\n const level = logLevels.debug\n if (shouldLog(store, level, logger.level))\n write({\n id,\n level,\n args: [++counter, ...args],\n timestamp: new Date()\n })\n })(0)\n },\n on: {\n writable: false,\n value: (level: number | T, logFn: LogFunction) => {\n const logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level)! : level\n if (shouldLog(store, logLevel, logger.level)) {\n const methodName = store.logLevelStore.getName(logLevel)\n const bindedMethod = logger[methodName].bind(logger)\n const result = logFn(bindedMethod)\n if (result) bindedMethod(result)\n }\n }\n }\n })\n store.logLevelStore.getAllLevels().forEach(function addMethod({ name, level }) {\n Object.defineProperty(logger, name, {\n writable: false,\n value: (...args: any[]) => {\n if (shouldLog(store, level, logger.level)) write({ id, level, args, timestamp: new Date() })\n }\n })\n })\n return logger\n}\n\nfunction validateId(id: string, meta?: StackTraceMeta) {\n if (/[`~!#$%^&*()=+[\\]{},|<>?]/.test(id)) throw new InvalidId(id, meta)\n}\n\nfunction writeToReporters(reporters: LogReporter[], logEntry: LogEntry, filter: (reporterId: string) => boolean) {\n reporters.filter(r => filter(r.id)).forEach(r => r.write(logEntry!))\n}\n\n/**\n * Determines should you log.\n * @param loggerLevel Log level of the logger.\n * It can be undefined which the global log level will be used.\n */\nfunction shouldLog(store: LogStore, targetLevel: LogLevel, loggerLevel: LogLevel | undefined) {\n return targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.logLevel)\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from '
|
|
1
|
+
import type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js';
|
|
2
2
|
export declare type MemoryLogReporter = LogReporter<LogEntry> & {
|
|
3
3
|
logs: LogEntry[];
|
|
4
4
|
/**
|
|
@@ -11,4 +11,4 @@ export declare type MemoryLogReporter = LogReporter<LogEntry> & {
|
|
|
11
11
|
export declare type MemoryLogFormatter = LogFormatter<LogEntry>;
|
|
12
12
|
export declare function toMessageWithLevel(logs: LogEntry[]): string;
|
|
13
13
|
export declare function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../ts/memory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEzF,oBAAY,iBAAiB,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG;IACtD,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB;;;OAGG;IACH,aAAa,IAAI,MAAM,CAAC;IACxB,sBAAsB,IAAI,MAAM,CAAA;CACjC,CAAA;AAED,oBAAY,kBAAkB,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;AAEvD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAQlD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAmBjG"}
|
package/cjs/memory.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMemoryLogReporter = exports.toMessageWithLevel = void 0;
|
|
4
|
+
var type_plus_1 = require("type-plus");
|
|
5
|
+
var platform_js_1 = require("./platform.js");
|
|
6
|
+
var formatter_js_1 = require("./formatter.js");
|
|
7
|
+
function toMessageWithLevel(logs) {
|
|
8
|
+
return logs.map(platform_js_1.toInspectLogEntry)
|
|
9
|
+
.map(function (log) { return "".concat((0, formatter_js_1.formatLogLevel)(log.level), " ").concat(log.args.join(' ')); })
|
|
10
|
+
.join('\n')
|
|
11
|
+
// if it has more than this log,
|
|
12
|
+
// we assume it is running under tests,
|
|
13
|
+
// and remove this log to simplify testing.
|
|
14
|
+
.replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, '');
|
|
15
|
+
}
|
|
16
|
+
exports.toMessageWithLevel = toMessageWithLevel;
|
|
17
|
+
function createMemoryLogReporter(options) {
|
|
18
|
+
var _a = (0, type_plus_1.required)({ id: 'memory', formatter: function (e) { return e; } }, options), id = _a.id, formatter = _a.formatter, filter = _a.filter;
|
|
19
|
+
var logs = [];
|
|
20
|
+
return Object.freeze({
|
|
21
|
+
id: id,
|
|
22
|
+
get formatter() { return formatter; },
|
|
23
|
+
get filter() { return filter; },
|
|
24
|
+
logs: logs,
|
|
25
|
+
write: function (entry) {
|
|
26
|
+
if (filter && !filter(entry))
|
|
27
|
+
return;
|
|
28
|
+
logs.push(formatter(entry));
|
|
29
|
+
},
|
|
30
|
+
getLogMessage: function () {
|
|
31
|
+
return logs.map(platform_js_1.toInspectLogEntry)
|
|
32
|
+
.map(function (log) { return log.args.join(' '); })
|
|
33
|
+
.join('\n');
|
|
34
|
+
},
|
|
35
|
+
getLogMessageWithLevel: function () { return toMessageWithLevel(logs); }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.createMemoryLogReporter = createMemoryLogReporter;
|
|
39
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../ts/memory.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AACpC,6CAAiD;AACjD,+CAA+C;AAe/C,SAAgB,kBAAkB,CAAC,IAAgB;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,+BAAiB,CA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,CAAC,CAAA,CAAC,CAAC;KAC7D,CAAC,CAAA;AACJ,CAAC;AAnBD,0DAmBC","sourcesContent":["import { required } from 'type-plus'\nimport { toInspectLogEntry } from './platform.js'\nimport { formatLogLevel } from './formatter.js'\nimport type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\n\nexport type MemoryLogReporter = LogReporter<LogEntry> & {\n logs: LogEntry[],\n /**\n * Gets a simple log message for testing.\n * The message only contains arguments for each log entry.\n */\n getLogMessage(): string,\n getLogMessageWithLevel(): string\n}\n\nexport type MemoryLogFormatter = LogFormatter<LogEntry>\n\nexport function toMessageWithLevel(logs: LogEntry[]) {\n return logs.map(toInspectLogEntry)\n .map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n .join('\\n')\n // if it has more than this log,\n // we assume it is running under tests,\n // and remove this log to simplify testing.\n .replace(/^\\(WARN\\) already configured for test, ignoring config\\(\\) call\\n/, '')\n}\n\nexport function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n const { id, formatter, filter } = required({ id: 'memory', formatter: (e: LogEntry) => e }, options)\n const logs: LogEntry[] = []\n return Object.freeze({\n id,\n get formatter() { return formatter },\n get filter() { return filter },\n logs,\n write(entry: LogEntry) {\n if (filter && !filter(entry)) return\n logs.push(formatter(entry))\n },\n getLogMessage() {\n return logs.map(toInspectLogEntry)\n .map(log => log.args.join(' '))\n .join('\\n')\n },\n getLogMessageWithLevel() { return toMessageWithLevel(logs) }\n })\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.spec.d.ts","sourceRoot":"","sources":["../ts/memory.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var assertron_1 = __importDefault(require("assertron"));
|
|
18
|
+
var index_js_1 = require("./index.js");
|
|
19
|
+
var testUtil_js_1 = require("./testUtil.js");
|
|
20
|
+
describe('MemoryLogReporter', function () {
|
|
21
|
+
it('filter is readonly', function () {
|
|
22
|
+
var reporter = (0, index_js_1.createMemoryLogReporter)();
|
|
23
|
+
var err = assertron_1.default.throws(function () { reporter.filter = function () { return true; }; }, function (err) { return /only a getter/.test(err); });
|
|
24
|
+
(0, testUtil_js_1.assertSSF)(err, __filename);
|
|
25
|
+
});
|
|
26
|
+
describe('unit tests', function () {
|
|
27
|
+
test('log entries are saved in the `logs` property', function () {
|
|
28
|
+
var reporter = (0, index_js_1.createMemoryLogReporter)();
|
|
29
|
+
var entry = { id: 'log', level: 1, args: ['some messages'], timestamp: new Date() };
|
|
30
|
+
reporter.write(entry);
|
|
31
|
+
expect(reporter.logs).toEqual([entry]);
|
|
32
|
+
});
|
|
33
|
+
test('can override id', function () {
|
|
34
|
+
var reporter = (0, index_js_1.createMemoryLogReporter)({ id: 'custom-id-mem' });
|
|
35
|
+
expect(reporter.id).toBe('custom-id-mem');
|
|
36
|
+
});
|
|
37
|
+
test('can filter', function () {
|
|
38
|
+
var filter = function (entry) { return entry.id !== 'secret'; };
|
|
39
|
+
var reporter = (0, index_js_1.createMemoryLogReporter)({ filter: filter });
|
|
40
|
+
expect(reporter.filter).toBe(filter);
|
|
41
|
+
reporter.write({ id: 'ok', level: 1, args: ['some messages'], timestamp: new Date() });
|
|
42
|
+
reporter.write({ id: 'secret', level: 1, args: ['some messages'], timestamp: new Date() });
|
|
43
|
+
expect(reporter.logs.length).toBe(1);
|
|
44
|
+
});
|
|
45
|
+
test('formatter can be used to pre-process the log', function () {
|
|
46
|
+
var formatter = function (entry) { return (__assign(__assign({}, entry), { args: entry.args.map(function (arg) { return arg === 'secret' ? '<censored>' : arg; }) })); };
|
|
47
|
+
var reporter = (0, index_js_1.createMemoryLogReporter)({ formatter: formatter });
|
|
48
|
+
expect(reporter.formatter).toBe(formatter);
|
|
49
|
+
var entry = { id: 'log', level: 1, args: ['a', 'secret', 'b'], timestamp: new Date() };
|
|
50
|
+
reporter.write(entry);
|
|
51
|
+
expect(reporter.logs[0].args[1]).toBe('<censored>');
|
|
52
|
+
});
|
|
53
|
+
describe('getLogMessages()', function () {
|
|
54
|
+
test('empty logs returns empty string', function () {
|
|
55
|
+
var reporter = (0, index_js_1.createMemoryLogReporter)();
|
|
56
|
+
expect(reporter.getLogMessage()).toEqual('');
|
|
57
|
+
});
|
|
58
|
+
test('print args', function () {
|
|
59
|
+
var reporter = (0, index_js_1.createMemoryLogReporter)();
|
|
60
|
+
var entry = { id: 'log', level: 1, args: ['miku', 'is', 'singing'], timestamp: new Date() };
|
|
61
|
+
reporter.write(entry);
|
|
62
|
+
expect(reporter.getLogMessage()).toEqual('miku is singing');
|
|
63
|
+
});
|
|
64
|
+
test('print object arg', function () {
|
|
65
|
+
var reporter = (0, index_js_1.createMemoryLogReporter)();
|
|
66
|
+
var entry = { id: 'log', level: 1, args: [{ 'miku': 'sing' }], timestamp: new Date() };
|
|
67
|
+
reporter.write(entry);
|
|
68
|
+
expect(reporter.getLogMessage()).toEqual("{ miku: 'sing' }");
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('getLogMessageWithLevel', function () {
|
|
72
|
+
test('print with level', function () {
|
|
73
|
+
var reporter = (0, index_js_1.createMemoryLogReporter)();
|
|
74
|
+
reporter.write({ id: 'log', level: index_js_1.logLevels.info, args: ['msg 1'], timestamp: new Date() });
|
|
75
|
+
reporter.write({ id: 'log', level: index_js_1.logLevels.warn, args: ['msg 2'], timestamp: new Date() });
|
|
76
|
+
expect(reporter.getLogMessageWithLevel()).toEqual("(INFO) msg 1\n(WARN) msg 2");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe('logEntriesToString()', function () {
|
|
82
|
+
test('convert log entries to string', function () {
|
|
83
|
+
var timestamp = new Date(2019, 6);
|
|
84
|
+
var actual = (0, testUtil_js_1.logEntriesToString)([
|
|
85
|
+
{ id: 'log', level: index_js_1.logLevels.emergency, args: ['emergency'], timestamp: timestamp },
|
|
86
|
+
{ id: 'log', level: index_js_1.logLevels.critical, args: ['critical'], timestamp: timestamp },
|
|
87
|
+
{ id: 'log', level: index_js_1.logLevels.alert, args: ['alert'], timestamp: timestamp },
|
|
88
|
+
{ id: 'log', level: index_js_1.logLevels.error, args: ['error'], timestamp: timestamp },
|
|
89
|
+
{ id: 'log', level: index_js_1.logLevels.warn, args: ['warn'], timestamp: timestamp },
|
|
90
|
+
{ id: 'log', level: index_js_1.logLevels.notice, args: ['notice'], timestamp: timestamp },
|
|
91
|
+
{ id: 'log', level: index_js_1.logLevels.info, args: ['info'], timestamp: timestamp },
|
|
92
|
+
{ id: 'log', level: index_js_1.logLevels.debug, args: ['debug'], timestamp: timestamp },
|
|
93
|
+
{ id: 'log', level: index_js_1.logLevels.trace, args: ['trace'], timestamp: timestamp }
|
|
94
|
+
]);
|
|
95
|
+
var iso = timestamp.toISOString();
|
|
96
|
+
expect(actual).toEqual("".concat(iso, ",log,(EMERGENCY),emergency\n").concat(iso, ",log,(CRITICAL),critical\n").concat(iso, ",log,(ALERT),alert\n").concat(iso, ",log,(ERROR),error\n").concat(iso, ",log,(WARN),warn\n").concat(iso, ",log,(NOTICE),notice\n").concat(iso, ",log,(INFO),info\n").concat(iso, ",log,(DEBUG),debug\n").concat(iso, ",log,(TRACE),trace"));
|
|
97
|
+
});
|
|
98
|
+
test('print out object', function () {
|
|
99
|
+
var timestamp = new Date(2021, 4);
|
|
100
|
+
var actual = (0, testUtil_js_1.logEntriesToString)([
|
|
101
|
+
{ id: 'log', level: index_js_1.logLevels.info, args: ['a', { a: 1 }], timestamp: timestamp }
|
|
102
|
+
]);
|
|
103
|
+
var iso = timestamp.toISOString();
|
|
104
|
+
expect(actual).toEqual("".concat(iso, ",log,(INFO),a,{ a: 1 }"));
|
|
105
|
+
});
|
|
106
|
+
test('print out array', function () {
|
|
107
|
+
var timestamp = new Date(2021, 4);
|
|
108
|
+
var actual = (0, testUtil_js_1.logEntriesToString)([
|
|
109
|
+
{ id: 'log', level: index_js_1.logLevels.info, args: ['a', [1, 2, 3]], timestamp: timestamp }
|
|
110
|
+
]);
|
|
111
|
+
var iso = timestamp.toISOString();
|
|
112
|
+
expect(actual).toEqual("".concat(iso, ",log,(INFO),a,[ 1, 2, 3 ]"));
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=memory.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.spec.js","sourceRoot":"","sources":["../ts/memory.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAyB;AACzB,uCAAkG;AAClG,6CAA6D;AAE7D,QAAQ,CAAC,mBAAmB,EAAE;IAC5B,EAAE,CAAC,oBAAoB,EAAE;QACvB,IAAM,QAAQ,GAAG,IAAA,kCAAuB,GAAE,CAAA;QAC1C,IAAM,GAAG,GAAG,mBAAC,CAAC,MAAM,CAAC,cAAS,QAAgB,CAAC,MAAM,GAAG,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAA,CAAC,CAAC,EAAE,UAAA,GAAG,IAAI,OAAA,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAzB,CAAyB,CAAC,CAAA;QAEvG,IAAA,uBAAS,EAAC,GAAG,EAAE,UAAU,CAAC,CAAA;I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,CAAA;IAEF,IAAI,CAAC,iBAAiB,EAAE;QACtB,IAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QACnC,IAAM,MAAM,GAAG,IAAA,gCAAkB,EAAC;YAChC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,WAAA,EAAE;SACxE,CAAC,CAAA;QAEF,IAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAG,GAAG,8BAA2B,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import a from 'assertron'\nimport { createMemoryLogReporter, LogEntry, LogFilter, LogFormatter, logLevels } from './index.js'\nimport { assertSSF, logEntriesToString } from './testUtil.js'\n\ndescribe('MemoryLogReporter', () => {\n it('filter is readonly', () => {\n const reporter = createMemoryLogReporter()\n const err = a.throws(() => { (reporter as any).filter = () => true }, err => /only a getter/.test(err))\n\n assertSSF(err, __filename)\n })\n\n describe('unit tests', () => {\n test('log entries are saved in the `logs` property', () => {\n const reporter = createMemoryLogReporter()\n const entry = { id: 'log', level: 1, args: ['some messages'], timestamp: new Date() }\n reporter.write(entry)\n expect(reporter.logs).toEqual([entry])\n })\n\n test('can override id', () => {\n const reporter = createMemoryLogReporter({ id: 'custom-id-mem' })\n expect(reporter.id).toBe('custom-id-mem')\n })\n\n test('can filter', () => {\n const filter: LogFilter = (entry) => entry.id !== 'secret'\n const reporter = createMemoryLogReporter({ filter })\n expect(reporter.filter).toBe(filter)\n reporter.write({ id: 'ok', level: 1, args: ['some messages'], timestamp: new Date() })\n reporter.write({ id: 'secret', level: 1, args: ['some messages'], timestamp: new Date() })\n expect(reporter.logs.length).toBe(1)\n })\n\n test('formatter can be used to pre-process the log', () => {\n const formatter: LogFormatter<LogEntry> = (entry) => ({\n ...entry,\n args: entry.args.map(arg => arg === 'secret' ? '<censored>' : arg)\n })\n const reporter = createMemoryLogReporter({ formatter })\n expect(reporter.formatter).toBe(formatter)\n\n const entry = { id: 'log', level: 1, args: ['a', 'secret', 'b'], timestamp: new Date() }\n reporter.write(entry)\n\n expect(reporter.logs[0].args[1]).toBe('<censored>')\n })\n\n describe('getLogMessages()', () => {\n test('empty logs returns empty string', () => {\n const reporter = createMemoryLogReporter()\n\n expect(reporter.getLogMessage()).toEqual('')\n })\n\n test('print args', () => {\n const reporter = createMemoryLogReporter()\n const entry = { id: 'log', level: 1, args: ['miku', 'is', 'singing'], timestamp: new Date() }\n reporter.write(entry)\n expect(reporter.getLogMessage()).toEqual('miku is singing')\n })\n\n test('print object arg', () => {\n const reporter = createMemoryLogReporter()\n const entry = { id: 'log', level: 1, args: [{ 'miku': 'sing' }], timestamp: new Date() }\n reporter.write(entry)\n expect(reporter.getLogMessage()).toEqual(\"{ miku: 'sing' }\")\n })\n })\n\n describe('getLogMessageWithLevel', () => {\n test('print with level', () => {\n const reporter = createMemoryLogReporter()\n reporter.write({ id: 'log', level: logLevels.info, args: ['msg 1'], timestamp: new Date() })\n reporter.write({ id: 'log', level: logLevels.warn, args: ['msg 2'], timestamp: new Date() })\n expect(reporter.getLogMessageWithLevel()).toEqual(`(INFO) msg 1\\n(WARN) msg 2`)\n })\n })\n })\n})\n\ndescribe('logEntriesToString()', () => {\n test('convert log entries to string', () => {\n const timestamp = new Date(2019, 6)\n const actual = logEntriesToString([\n { id: 'log', level: logLevels.emergency, args: ['emergency'], timestamp },\n { id: 'log', level: logLevels.critical, args: ['critical'], timestamp },\n { id: 'log', level: logLevels.alert, args: ['alert'], timestamp },\n { id: 'log', level: logLevels.error, args: ['error'], timestamp },\n { id: 'log', level: logLevels.warn, args: ['warn'], timestamp },\n { id: 'log', level: logLevels.notice, args: ['notice'], timestamp },\n { id: 'log', level: logLevels.info, args: ['info'], timestamp },\n { id: 'log', level: logLevels.debug, args: ['debug'], timestamp },\n { id: 'log', level: logLevels.trace, args: ['trace'], timestamp }\n ])\n\n const iso = timestamp.toISOString()\n expect(actual).toEqual(`${iso},log,(EMERGENCY),emergency\n${iso},log,(CRITICAL),critical\n${iso},log,(ALERT),alert\n${iso},log,(ERROR),error\n${iso},log,(WARN),warn\n${iso},log,(NOTICE),notice\n${iso},log,(INFO),info\n${iso},log,(DEBUG),debug\n${iso},log,(TRACE),trace`)\n })\n\n test('print out object', () => {\n const timestamp = new Date(2021, 4)\n const actual = logEntriesToString([\n { id: 'log', level: logLevels.info, args: ['a', { a: 1 }], timestamp }\n ])\n\n const iso = timestamp.toISOString()\n expect(actual).toEqual(`${iso},log,(INFO),a,{ a: 1 }`)\n })\n\n test('print out array', () => {\n const timestamp = new Date(2021, 4)\n const actual = logEntriesToString([\n { id: 'log', level: logLevels.info, args: ['a', [1, 2, 3]], timestamp }\n ])\n\n const iso = timestamp.toISOString()\n expect(actual).toEqual(`${iso},log,(INFO),a,[ 1, 2, 3 ]`)\n })\n})\n"]}
|
package/cjs/package.json
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ConsoleLike, LogEntry } from './types.js';
|
|
2
|
+
export declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
|
|
3
|
+
export declare function isConsoleDebugAvailable(): boolean;
|
|
4
|
+
export declare const polyfill: {
|
|
5
|
+
console?: ConsoleLike;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=platform.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.browser.d.ts","sourceRoot":"","sources":["../ts/platform.browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,MAAO,QAAQ,aAAM,CAAA;AACnD,wBAAgB,uBAAuB,YAEtC;AAED,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAO,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.polyfill = exports.isConsoleDebugAvailable = exports.toInspectLogEntry = void 0;
|
|
4
|
+
var toInspectLogEntry = function (e) { return e; };
|
|
5
|
+
exports.toInspectLogEntry = toInspectLogEntry;
|
|
6
|
+
function isConsoleDebugAvailable() {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
exports.isConsoleDebugAvailable = isConsoleDebugAvailable;
|
|
10
|
+
exports.polyfill = {};
|
|
11
|
+
//# sourceMappingURL=platform.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.browser.js","sourceRoot":"","sources":["../ts/platform.browser.ts"],"names":[],"mappings":";;;AAEO,IAAM,iBAAiB,GAAG,UAAC,CAAW,IAAK,OAAA,CAAC,EAAD,CAAC,CAAA;AAAtC,QAAA,iBAAiB,qBAAqB;AACnD,SAAgB,uBAAuB;IACrC,OAAO,IAAI,CAAA;AACb,CAAC;AAFD,0DAEC;AAEY,QAAA,QAAQ,GAA8B,EAAE,CAAA","sourcesContent":["import type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => e\nexport function isConsoleDebugAvailable() {\n return true\n}\n\nexport const polyfill: { console?: ConsoleLike } = {}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ConsoleLike, LogEntry } from './types.js';
|
|
2
|
+
export declare function semverGt(versionString: string, version: [number, number, number]): boolean;
|
|
3
|
+
export declare function isConsoleDebugAvailable(): boolean;
|
|
4
|
+
export declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
|
|
5
|
+
export declare const polyfill: {
|
|
6
|
+
console?: ConsoleLike;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,wBAAgB,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,WAOhF;AAGD,wBAAgB,uBAAuB,YAKtC;AAED,eAAO,MAAM,iBAAiB,MAAO,QAAQ,aAEzC,CAAA;AAEJ,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAO,CAAA"}
|
package/cjs/platform.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.polyfill = exports.toInspectLogEntry = exports.isConsoleDebugAvailable = exports.semverGt = void 0;
|
|
4
|
+
var util_1 = require("util");
|
|
5
|
+
function semverGt(versionString, version) {
|
|
6
|
+
var actual = versionString.split('.').reverse().reduce(function (p, v, i) {
|
|
7
|
+
p += Number.parseInt(v, 10) * Math.pow(100, i);
|
|
8
|
+
return p;
|
|
9
|
+
}, 0);
|
|
10
|
+
return actual > (version[0] * 10000 + version[1] * 100 + version[2]);
|
|
11
|
+
}
|
|
12
|
+
exports.semverGt = semverGt;
|
|
13
|
+
// istanbul ignore next
|
|
14
|
+
function isConsoleDebugAvailable() {
|
|
15
|
+
// without this, systemJs will complain `process is not defined`
|
|
16
|
+
if (!global.process)
|
|
17
|
+
return true;
|
|
18
|
+
var versionString = process.version.startsWith('v') ? process.version.slice(1) : process.version;
|
|
19
|
+
return semverGt(versionString, [9, 3, 0]);
|
|
20
|
+
}
|
|
21
|
+
exports.isConsoleDebugAvailable = isConsoleDebugAvailable;
|
|
22
|
+
var toInspectLogEntry = function (e) { return (e.args = e.args.map(function (value) { return typeof value === 'object' && value !== null ? (0, util_1.inspect)(value) : value; }),
|
|
23
|
+
e); };
|
|
24
|
+
exports.toInspectLogEntry = toInspectLogEntry;
|
|
25
|
+
exports.polyfill = {};
|
|
26
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":";;;AAAA,6BAA8B;AAG9B,SAAgB,QAAQ,CAAC,aAAqB,EAAE,OAAiC;IAC/E,IAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QAC/D,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QAC9C,OAAO,CAAC,CAAA;IACV,CAAC,EAAE,CAAC,CAAC,CAAA;IAEL,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;AACtE,CAAC;AAPD,4BAOC;AAED,uBAAuB;AACvB,SAAgB,uBAAuB;IACrC,gEAAgE;IAChE,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IAChC,IAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IAClG,OAAO,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAC3C,CAAC;AALD,0DAKC;AAEM,IAAM,iBAAiB,GAAG,UAAC,CAAW,IAAK,OAAA,CAChD,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAApE,CAAoE,CAAC;IAClG,CAAC,CAAC,EAF8C,CAE9C,CAAA;AAFS,QAAA,iBAAiB,qBAE1B;AAES,QAAA,QAAQ,GAA8B,EAAE,CAAA","sourcesContent":["import { inspect } from 'util'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport function semverGt(versionString: string, version: [number, number, number]) {\n const actual = versionString.split('.').reverse().reduce((p, v, i) => {\n p += Number.parseInt(v, 10) * Math.pow(100, i)\n return p\n }, 0)\n\n return actual > (version[0] * 10000 + version[1] * 100 + version[2])\n}\n\n// istanbul ignore next\nexport function isConsoleDebugAvailable() {\n // without this, systemJs will complain `process is not defined`\n if (!global.process) return true\n const versionString = process.version.startsWith('v') ? process.version.slice(1) : process.version\n return semverGt(versionString, [9, 3, 0])\n}\n\nexport const toInspectLogEntry = (e: LogEntry) => (\n e.args = e.args.map(value => typeof value === 'object' && value !== null ? inspect(value) : value),\n e)\n\nexport const polyfill: { console?: ConsoleLike } = {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.spec.d.ts","sourceRoot":"","sources":["../ts/platform.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var platform_js_1 = require("./platform.js");
|
|
4
|
+
test('9.3.0 returns false', function () {
|
|
5
|
+
expect((0, platform_js_1.semverGt)('9.3.0', [9, 3, 0])).toBe(false);
|
|
6
|
+
});
|
|
7
|
+
test('9.3.1 returns true', function () {
|
|
8
|
+
expect((0, platform_js_1.semverGt)('9.3.1', [9, 3, 0])).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
test('9.3.1 returns true', function () {
|
|
11
|
+
expect((0, platform_js_1.semverGt)('9.3.1', [9, 3, 0])).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
test('9.4.0 returns true', function () {
|
|
14
|
+
expect((0, platform_js_1.semverGt)('9.4.0', [9, 3, 0])).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
test('9.10.0 returns true', function () {
|
|
17
|
+
expect((0, platform_js_1.semverGt)('9.10.0', [9, 3, 0])).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
test('10.0.0 returns true', function () {
|
|
20
|
+
expect((0, platform_js_1.semverGt)('10.0.0', [9, 3, 0])).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=platform.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.spec.js","sourceRoot":"","sources":["../ts/platform.spec.ts"],"names":[],"mappings":";;AAAA,6CAAwC;AAExC,IAAI,CAAC,qBAAqB,EAAE;IAC1B,MAAM,CAAC,IAAA,sBAAQ,EAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,oBAAoB,EAAE;IACzB,MAAM,CAAC,IAAA,sBAAQ,EAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,oBAAoB,EAAE;IACzB,MAAM,CAAC,IAAA,sBAAQ,EAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,oBAAoB,EAAE;IACzB,MAAM,CAAC,IAAA,sBAAQ,EAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,qBAAqB,EAAE;IAC1B,MAAM,CAAC,IAAA,sBAAQ,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,qBAAqB,EAAE;IAC1B,MAAM,CAAC,IAAA,sBAAQ,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA","sourcesContent":["import { semverGt } from './platform.js'\n\ntest('9.3.0 returns false', () => {\n expect(semverGt('9.3.0', [9, 3, 0])).toBe(false)\n})\n\ntest('9.3.1 returns true', () => {\n expect(semverGt('9.3.1', [9, 3, 0])).toBe(true)\n})\n\ntest('9.3.1 returns true', () => {\n expect(semverGt('9.3.1', [9, 3, 0])).toBe(true)\n})\n\ntest('9.4.0 returns true', () => {\n expect(semverGt('9.4.0', [9, 3, 0])).toBe(true)\n})\n\ntest('9.10.0 returns true', () => {\n expect(semverGt('9.10.0', [9, 3, 0])).toBe(true)\n})\n\ntest('10.0.0 returns true', () => {\n expect(semverGt('10.0.0', [9, 3, 0])).toBe(true)\n})\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StackTraceMeta } from '@just-func/types';
|
|
2
|
+
import type { Logger, LoggerOptions, LogLevel, LogMethodNames, StandardLogOptions } from './types.js';
|
|
3
|
+
export interface StandardLog<N extends string = LogMethodNames> {
|
|
4
|
+
readonly logLevel: number;
|
|
5
|
+
toLogLevelName(level: number): string;
|
|
6
|
+
toLogLevel(name: N): number;
|
|
7
|
+
getLogger(params: [id: string, options?: LoggerOptions], meta?: StackTraceMeta): Logger<N>;
|
|
8
|
+
}
|
|
9
|
+
export declare function createStandardLog<N extends string = LogMethodNames>(options?: Partial<StandardLogOptions<N>>, _meta?: StackTraceMeta): Readonly<StandardLog<N>>;
|
|
10
|
+
export declare function createStandardLogForTest(logLevel?: LogLevel): {
|
|
11
|
+
reporter: import("./memory.js").MemoryLogReporter;
|
|
12
|
+
logLevel: number;
|
|
13
|
+
toLogLevelName: (level: number) => string;
|
|
14
|
+
toLogLevel: (name: LogMethodNames) => number;
|
|
15
|
+
getLogger: (params: [id: string, options?: LoggerOptions | undefined], meta?: StackTraceMeta | undefined) => Logger<LogMethodNames>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Suppress logging within the code block.
|
|
19
|
+
*/
|
|
20
|
+
export declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R;
|
|
21
|
+
//# sourceMappingURL=standardLog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standardLog.d.ts","sourceRoot":"","sources":["../ts/standardLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAMjD,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAErG,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;CAC3F;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EACjE,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,cAAc,GAC/D,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAkB1B;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,GAAE,QAA0B;;;;;;EAI5E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.suppressLogs = exports.createStandardLogForTest = exports.createStandardLog = void 0;
|
|
15
|
+
var type_plus_1 = require("type-plus");
|
|
16
|
+
var logger_js_1 = require("./logger.js");
|
|
17
|
+
var logLevels_js_1 = require("./logLevels.js");
|
|
18
|
+
var logStore_js_1 = require("./logStore.js");
|
|
19
|
+
var memory_js_1 = require("./memory.js");
|
|
20
|
+
function createStandardLog(options, _meta) {
|
|
21
|
+
var store = (0, logStore_js_1.createLogStore)((0, type_plus_1.required)({ logLevel: logLevels_js_1.logLevels.info }, options));
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
get logLevel() { return store.logLevel; },
|
|
24
|
+
toLogLevelName: function (level) {
|
|
25
|
+
return store.logLevelStore.getName(level);
|
|
26
|
+
},
|
|
27
|
+
toLogLevel: function (name) {
|
|
28
|
+
return store.logLevelStore.getLevel(name);
|
|
29
|
+
},
|
|
30
|
+
getLogger: function (_a, meta) {
|
|
31
|
+
var id = _a[0], options = _a[1];
|
|
32
|
+
if (store.loggers[id])
|
|
33
|
+
return store.loggers[id];
|
|
34
|
+
var opt = (0, type_plus_1.required)({ level: store.logLevel }, options);
|
|
35
|
+
return store.loggers[id] = (0, logger_js_1.createLogger)([store, id, opt], __assign({ ssf: this.getLogger }, meta));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.createStandardLog = createStandardLog;
|
|
40
|
+
function createStandardLogForTest(logLevel) {
|
|
41
|
+
if (logLevel === void 0) { logLevel = logLevels_js_1.logLevels.debug; }
|
|
42
|
+
var reporter = (0, memory_js_1.createMemoryLogReporter)();
|
|
43
|
+
var standardLog = createStandardLog({ reporters: [reporter], logLevel: logLevel });
|
|
44
|
+
return __assign(__assign({}, standardLog), { reporter: reporter });
|
|
45
|
+
}
|
|
46
|
+
exports.createStandardLogForTest = createStandardLogForTest;
|
|
47
|
+
function suppressLogs(block) {
|
|
48
|
+
var logs = [];
|
|
49
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
50
|
+
logs[_i - 1] = arguments[_i];
|
|
51
|
+
}
|
|
52
|
+
var origLevels = logs.map(function (l) { return l.level; });
|
|
53
|
+
logs.forEach(function (l) { return l.level = logLevels_js_1.logLevels.none; });
|
|
54
|
+
var result = block();
|
|
55
|
+
logs.forEach(function (l, i) { return l.level = origLevels[i]; });
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
exports.suppressLogs = suppressLogs;
|
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CAAC,CAAA;AACJ,CAAC;AApBD,8CAoBC;AAED,SAAgB,wBAAwB,CAAC,QAAoC;IAApC,yBAAA,EAAA,WAAqB,wBAAS,CAAC,KAAK;IAC3E,IAAM,QAAQ,GAAG,IAAA,mCAAuB,GAAE,CAAA;IAC1C,IAAM,WAAW,GAAG,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,UAAA,EAAE,CAAC,CAAA;IAC1E,6BAAY,WAAW,KAAE,QAAQ,UAAA,IAAE;AACrC,CAAC;AAJD,4DAIC;AAMD,SAAgB,YAAY,CAAI,KAAc;IAAE,cAAiB;SAAjB,UAAiB,EAAjB,qBAAiB,EAAjB,IAAiB;QAAjB,6BAAiB;;IAC/D,IAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,EAAP,CAAO,CAAC,CAAA;IACzC,IAAI,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,GAAG,wBAAS,CAAC,IAAI,EAAxB,CAAwB,CAAC,CAAA;IAC3C,IAAM,MAAM,GAAG,KAAK,EAAE,CAAA;IACtB,IAAI,CAAC,OAAO,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,EAAvB,CAAuB,CAAC,CAAA;IAC/C,OAAO,MAAM,CAAA;AACf,CAAC;AAND,oCAMC","sourcesContent":["import { StackTraceMeta } from '@just-func/types'\nimport { required } from 'type-plus'\nimport { createLogger } from './logger.js'\nimport { logLevels } from './logLevels.js'\nimport { createLogStore } from './logStore.js'\nimport { createMemoryLogReporter } from './memory.js'\nimport type { Logger, LoggerOptions, LogLevel, LogMethodNames, StandardLogOptions } from './types.js'\n\nexport interface StandardLog<N extends string = LogMethodNames> {\n readonly logLevel: number,\n toLogLevelName(level: number): string,\n toLogLevel(name: N): number,\n getLogger(params: [id: string, options?: LoggerOptions], meta?: StackTraceMeta): Logger<N>\n}\n\nexport function createStandardLog<N extends string = LogMethodNames>(\n options?: Partial<StandardLogOptions<N>>, _meta?: StackTraceMeta\n): Readonly<StandardLog<N>> {\n const store = createLogStore(required({ logLevel: logLevels.info }, options))\n\n return Object.freeze({\n get logLevel() { return store.logLevel },\n\n toLogLevelName(level: number) {\n return store.logLevelStore.getName(level)\n },\n toLogLevel(name: string) {\n return store.logLevelStore.getLevel(name)\n },\n getLogger([id, options]: [id: string, options?: LoggerOptions], meta?: StackTraceMeta): Logger<N> {\n if (store.loggers[id]) return store.loggers[id] as any\n const opt = required({ level: store.logLevel }, options)\n return store.loggers[id] = createLogger([store, id, opt], { ssf: this.getLogger, ...meta }) as any\n }\n })\n}\n\nexport function createStandardLogForTest(logLevel: LogLevel = logLevels.debug) {\n const reporter = createMemoryLogReporter()\n const standardLog = createStandardLog({ reporters: [reporter], logLevel })\n return { ...standardLog, reporter }\n}\n\n/**\n * Suppress logging within the code block.\n */\nexport function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R\nexport function suppressLogs<R>(block: () => R, ...logs: Logger[]): R {\n const origLevels = logs.map(l => l.level)\n logs.forEach(l => l.level = logLevels.none)\n const result = block()\n logs.forEach((l, i) => l.level = origLevels[i])\n return result\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standardLog.spec.d.ts","sourceRoot":"","sources":["../ts/standardLog.spec.ts"],"names":[],"mappings":""}
|