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/errors.d.ts
CHANGED
|
@@ -6,14 +6,4 @@ export declare class InvalidId extends StandardLogError {
|
|
|
6
6
|
id: string;
|
|
7
7
|
constructor(id: string, options?: IsoError.Options);
|
|
8
8
|
}
|
|
9
|
-
export declare class ProhibitedDuringProduction extends StandardLogError {
|
|
10
|
-
action: string;
|
|
11
|
-
constructor(action: string, options?: IsoError.Options);
|
|
12
|
-
}
|
|
13
|
-
export declare class InvalidEnvVar extends StandardLogError {
|
|
14
|
-
name: string;
|
|
15
|
-
value: string;
|
|
16
|
-
possibleValues: string[];
|
|
17
|
-
constructor(name: string, value: string, possibleValues: string[], options?: IsoError.Options);
|
|
18
|
-
}
|
|
19
9
|
//# sourceMappingURL=errors.d.ts.map
|
package/cjs/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG5D;AACD,qBAAa,SAAU,SAAQ,gBAAgB;IAC1B,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG1D
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG5D;AACD,qBAAa,SAAU,SAAQ,gBAAgB;IAC1B,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG1D"}
|
package/cjs/errors.js
CHANGED
|
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.InvalidId = exports.StandardLogError = void 0;
|
|
19
19
|
var iso_error_1 = require("iso-error");
|
|
20
20
|
var StandardLogError = /** @class */ (function (_super) {
|
|
21
21
|
__extends(StandardLogError, _super);
|
|
@@ -40,46 +40,4 @@ var InvalidId = /** @class */ (function (_super) {
|
|
|
40
40
|
return InvalidId;
|
|
41
41
|
}(StandardLogError));
|
|
42
42
|
exports.InvalidId = InvalidId;
|
|
43
|
-
var ProhibitedDuringProduction = /** @class */ (function (_super) {
|
|
44
|
-
__extends(ProhibitedDuringProduction, _super);
|
|
45
|
-
function ProhibitedDuringProduction(action, options) {
|
|
46
|
-
var _this = _super.call(this, "Cannot perform ".concat(action, " during production"), options) || this;
|
|
47
|
-
Object.defineProperty(_this, "action", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: action
|
|
52
|
-
});
|
|
53
|
-
return _this;
|
|
54
|
-
}
|
|
55
|
-
return ProhibitedDuringProduction;
|
|
56
|
-
}(StandardLogError));
|
|
57
|
-
exports.ProhibitedDuringProduction = ProhibitedDuringProduction;
|
|
58
|
-
var InvalidEnvVar = /** @class */ (function (_super) {
|
|
59
|
-
__extends(InvalidEnvVar, _super);
|
|
60
|
-
function InvalidEnvVar(name, value, possibleValues, options) {
|
|
61
|
-
var _this = _super.call(this, "".concat(name, " contains invalid value '").concat(value, "'").concat(" valid values: [".concat(possibleValues.join(), "]")), options) || this;
|
|
62
|
-
Object.defineProperty(_this, "name", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
configurable: true,
|
|
65
|
-
writable: true,
|
|
66
|
-
value: name
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(_this, "value", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
configurable: true,
|
|
71
|
-
writable: true,
|
|
72
|
-
value: value
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(_this, "possibleValues", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
configurable: true,
|
|
77
|
-
writable: true,
|
|
78
|
-
value: possibleValues
|
|
79
|
-
});
|
|
80
|
-
return _this;
|
|
81
|
-
}
|
|
82
|
-
return InvalidEnvVar;
|
|
83
|
-
}(StandardLogError));
|
|
84
|
-
exports.InvalidEnvVar = InvalidEnvVar;
|
|
85
43
|
//# sourceMappingURL=errors.js.map
|
package/cjs/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAiD;AAEjD;IAAsC,oCAAW;IAC/C,0BAAY,WAAmB,EAAE,OAA0B;eACzD,kBAAM,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC;IAC7C,CAAC;IACH,uBAAC;AAAD,CAAC,AAJD,CAAsC,uBAAW,GAIhD;AAJY,4CAAgB;AAK7B;IAA+B,6BAAgB;IAC7C,mBAAmB,EAAU,EAAE,OAA0B;QAAzD,YACE,kBAAM,yFAAkF,EAAE,CAAE,EAAE,OAAO,CAAC,SACvG;;;;;mBAFkB;;;IAEnB,CAAC;IACH,gBAAC;AAAD,CAAC,AAJD,CAA+B,gBAAgB,GAI9C;AAJY,8BAAS
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAiD;AAEjD;IAAsC,oCAAW;IAC/C,0BAAY,WAAmB,EAAE,OAA0B;eACzD,kBAAM,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC;IAC7C,CAAC;IACH,uBAAC;AAAD,CAAC,AAJD,CAAsC,uBAAW,GAIhD;AAJY,4CAAgB;AAK7B;IAA+B,6BAAgB;IAC7C,mBAAmB,EAAU,EAAE,OAA0B;QAAzD,YACE,kBAAM,yFAAkF,EAAE,CAAE,EAAE,OAAO,CAAC,SACvG;;;;;mBAFkB;;;IAEnB,CAAC;IACH,gBAAC;AAAD,CAAC,AAJD,CAA+B,gBAAgB,GAI9C;AAJY,8BAAS","sourcesContent":["import { IsoError, ModuleError } from 'iso-error'\n\nexport class StandardLogError extends ModuleError {\n constructor(description: string, options?: IsoError.Options) {\n super('standard-log', description, options)\n }\n}\nexport class InvalidId extends StandardLogError {\n constructor(public id: string, options?: IsoError.Options) {\n super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options)\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LogEntry } from './types.js';
|
|
2
|
+
export declare type TimestampFormat = 'none' | 'iso' | 'elapsed';
|
|
3
|
+
export declare function createTimestampFormatter(format: TimestampFormat): ((_timestamp: Date) => undefined) | ((timestamp: Date) => string);
|
|
4
|
+
export declare function formatLogLevel(level: number): string;
|
|
5
|
+
export declare function plainLogFormatter({ id, level, args, timestamp }: LogEntry): any[];
|
|
6
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,oBAAY,eAAe,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAA;AAExD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,iBAGtC,IAAI,+BAEL,IAAI,aAW5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAE3C;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,SAEzE"}
|
package/cjs/formatter.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.plainLogFormatter = exports.formatLogLevel = exports.createTimestampFormatter = void 0;
|
|
16
|
+
var ms_1 = __importDefault(require("ms"));
|
|
17
|
+
var upper_case_1 = require("upper-case");
|
|
18
|
+
var logLevels_js_1 = require("./logLevels.js");
|
|
19
|
+
function createTimestampFormatter(format) {
|
|
20
|
+
switch (format) {
|
|
21
|
+
case 'none':
|
|
22
|
+
return function (_timestamp) { return undefined; };
|
|
23
|
+
case 'iso':
|
|
24
|
+
return function (timestamp) { return timestamp.toISOString(); };
|
|
25
|
+
case 'elapsed': {
|
|
26
|
+
var lastTick_1;
|
|
27
|
+
return function (timestamp) {
|
|
28
|
+
var newTick = timestamp.getTime();
|
|
29
|
+
var result = (0, ms_1.default)(lastTick_1 === undefined ? 0 : newTick - lastTick_1);
|
|
30
|
+
lastTick_1 = newTick;
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.createTimestampFormatter = createTimestampFormatter;
|
|
37
|
+
function formatLogLevel(level) {
|
|
38
|
+
return "(".concat((0, upper_case_1.upperCase)((0, logLevels_js_1.toLogLevelName)(level)), ")");
|
|
39
|
+
}
|
|
40
|
+
exports.formatLogLevel = formatLogLevel;
|
|
41
|
+
function plainLogFormatter(_a) {
|
|
42
|
+
var id = _a.id, level = _a.level, args = _a.args, timestamp = _a.timestamp;
|
|
43
|
+
return __spreadArray([timestamp.toISOString(), id, formatLogLevel(level)], args, true);
|
|
44
|
+
}
|
|
45
|
+
exports.plainLogFormatter = plainLogFormatter;
|
|
46
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0CAAmB;AACnB,yCAAsC;AACtC,+CAA+C;AAK/C,SAAgB,wBAAwB,CAAC,MAAuB;IAC9D,QAAQ,MAAM,EAAE;QACd,KAAK,MAAM;YACT,OAAO,UAAC,UAAgB,IAAK,OAAA,SAAS,EAAT,CAAS,CAAA;QACxC,KAAK,KAAK;YACR,OAAO,UAAC,SAAe,IAAK,OAAA,SAAS,CAAC,WAAW,EAAE,EAAvB,CAAuB,CAAA;QACrD,KAAK,SAAS,CAAC,CAAC;YACd,IAAI,UAAgB,CAAA;YACpB,OAAO,UAAC,SAAe;gBACrB,IAAM,OAAO,GAAG,SAAS,CAAC,OAAO,EAAE,CAAA;gBACnC,IAAM,MAAM,GAAG,IAAA,YAAE,EAAC,UAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,UAAQ,CAAC,CAAA;gBAClE,UAAQ,GAAG,OAAO,CAAA;gBAClB,OAAO,MAAM,CAAA;YACf,CAAC,CAAA;SACF;KACF;AACH,CAAC;AAhBD,4DAgBC;AAED,SAAgB,cAAc,CAAC,KAAa;IAC1C,OAAO,WAAI,IAAA,sBAAS,EAAC,IAAA,6BAAc,EAAC,KAAK,CAAC,CAAC,MAAG,CAAA;AAChD,CAAC;AAFD,wCAEC;AAED,SAAgB,iBAAiB,CAAC,EAAwC;QAAtC,EAAE,QAAA,EAAE,KAAK,WAAA,EAAE,IAAI,UAAA,EAAE,SAAS,eAAA;IAC5D,sBAAQ,SAAS,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,GAAK,IAAI,QAAC;AACtE,CAAC;AAFD,8CAEC","sourcesContent":["import ms from 'ms'\nimport { upperCase } from 'upper-case'\nimport { toLogLevelName } from './logLevels.js'\nimport type { LogEntry } from './types.js'\n\nexport type TimestampFormat = 'none' | 'iso' | 'elapsed'\n\nexport function createTimestampFormatter(format: TimestampFormat) {\n switch (format) {\n case 'none':\n return (_timestamp: Date) => undefined\n case 'iso':\n return (timestamp: Date) => timestamp.toISOString()\n case 'elapsed': {\n let lastTick: number\n return (timestamp: Date) => {\n const newTick = timestamp.getTime()\n const result = ms(lastTick === undefined ? 0 : newTick - lastTick)\n lastTick = newTick\n return result\n }\n }\n }\n}\n\nexport function formatLogLevel(level: number) {\n return `(${upperCase(toLogLevelName(level))})`\n}\n\nexport function plainLogFormatter({ id, level, args, timestamp }: LogEntry) {\n return [timestamp.toISOString(), id, formatLogLevel(level), ...args]\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.spec.d.ts","sourceRoot":"","sources":["../ts/formatter.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var index_js_1 = require("./index.js");
|
|
4
|
+
describe('plainLogFormatter()', function () {
|
|
5
|
+
it('convert log entries to string', function () {
|
|
6
|
+
var timestamp = new Date(2019, 6);
|
|
7
|
+
var actual = (0, index_js_1.plainLogFormatter)({ id: 'plain', level: index_js_1.logLevels.emergency, args: ['emergency'], timestamp: timestamp });
|
|
8
|
+
expect(actual).toEqual([timestamp.toISOString(), 'plain', "(EMERGENCY)", "emergency"]);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
describe('createTimestampFormatter()', function () {
|
|
12
|
+
test('none', function () {
|
|
13
|
+
var formatter = (0, index_js_1.createTimestampFormatter)('none');
|
|
14
|
+
var now = new Date();
|
|
15
|
+
var actual = [formatter(now)];
|
|
16
|
+
expect(actual).toEqual([undefined]);
|
|
17
|
+
});
|
|
18
|
+
test('iso', function () {
|
|
19
|
+
var formatter = (0, index_js_1.createTimestampFormatter)('iso');
|
|
20
|
+
var now = new Date();
|
|
21
|
+
var actual = [formatter(now)];
|
|
22
|
+
expect(actual).toEqual([now.toISOString()]);
|
|
23
|
+
});
|
|
24
|
+
test('elapsed', function () {
|
|
25
|
+
var formatter = (0, index_js_1.createTimestampFormatter)('elapsed');
|
|
26
|
+
var now = new Date();
|
|
27
|
+
var next = new Date(now.getTime() + 10);
|
|
28
|
+
var actual = [formatter(now), formatter(next)];
|
|
29
|
+
expect(actual).toEqual(['0ms', '10ms']);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=formatter.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.spec.js","sourceRoot":"","sources":["../ts/formatter.spec.ts"],"names":[],"mappings":";;AAAA,uCAAmF;AAEnF,QAAQ,CAAC,qBAAqB,EAAE;IAC9B,EAAE,CAAC,+BAA+B,EAAE;QAClC,IAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QACnC,IAAM,MAAM,GAAG,IAAA,4BAAiB,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,SAAS,WAAA,EAAE,CAAC,CAAA;QAE7G,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;IACxF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,4BAA4B,EAAE;IACrC,IAAI,CAAC,MAAM,EAAE;QACX,IAAM,SAAS,GAAG,IAAA,mCAAwB,EAAC,MAAM,CAAC,CAAA;QAClD,IAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,IAAM,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,KAAK,EAAE;QACV,IAAM,SAAS,GAAG,IAAA,mCAAwB,EAAC,KAAK,CAAC,CAAA;QACjD,IAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,IAAM,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,SAAS,EAAE;QACd,IAAM,SAAS,GAAG,IAAA,mCAAwB,EAAC,SAAS,CAAC,CAAA;QACrD,IAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAA;QACzC,IAAM,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;QAEhD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { createTimestampFormatter, logLevels, plainLogFormatter } from './index.js'\n\ndescribe('plainLogFormatter()', () => {\n it('convert log entries to string', () => {\n const timestamp = new Date(2019, 6)\n const actual = plainLogFormatter({ id: 'plain', level: logLevels.emergency, args: ['emergency'], timestamp })\n\n expect(actual).toEqual([timestamp.toISOString(), 'plain', `(EMERGENCY)`, `emergency`])\n })\n})\n\ndescribe('createTimestampFormatter()', () => {\n test('none', () => {\n const formatter = createTimestampFormatter('none')\n const now = new Date()\n const actual = [formatter(now)]\n expect(actual).toEqual([undefined])\n })\n\n test('iso', () => {\n const formatter = createTimestampFormatter('iso')\n const now = new Date()\n const actual = [formatter(now)]\n expect(actual).toEqual([now.toISOString()])\n })\n\n test('elapsed', () => {\n const formatter = createTimestampFormatter('elapsed')\n const now = new Date()\n const next = new Date(now.getTime() + 10)\n const actual = [formatter(now), formatter(next)]\n\n expect(actual).toEqual(['0ms', '10ms'])\n })\n})\n"]}
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './config.js';
|
|
3
|
-
export * from './configForTest.js';
|
|
4
|
-
export * from './console/index.js';
|
|
5
|
-
export * from './customLogLevel.js';
|
|
1
|
+
export * from './console.js';
|
|
6
2
|
export * from './errors.js';
|
|
7
|
-
export * from './formatter
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './logReporter.js';
|
|
12
|
-
export * from './memory/index.js';
|
|
13
|
-
export * from './shouldLog.js';
|
|
14
|
-
export * from './suppressLogs.js';
|
|
3
|
+
export * from './formatter.js';
|
|
4
|
+
export * from './logLevels.js';
|
|
5
|
+
export * from './memory.js';
|
|
6
|
+
export * from './standardLog.js';
|
|
15
7
|
export * from './types.js';
|
|
16
|
-
export * from './utils.js';
|
|
17
8
|
//# sourceMappingURL=index.d.ts.map
|
package/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}
|
package/cjs/index.js
CHANGED
|
@@ -14,20 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./config.js"), exports);
|
|
19
|
-
__exportStar(require("./configForTest.js"), exports);
|
|
20
|
-
__exportStar(require("./console/index.js"), exports);
|
|
21
|
-
__exportStar(require("./customLogLevel.js"), exports);
|
|
17
|
+
__exportStar(require("./console.js"), exports);
|
|
22
18
|
__exportStar(require("./errors.js"), exports);
|
|
23
|
-
__exportStar(require("./formatter
|
|
24
|
-
__exportStar(require("./
|
|
25
|
-
__exportStar(require("./
|
|
26
|
-
__exportStar(require("./
|
|
27
|
-
__exportStar(require("./logReporter.js"), exports);
|
|
28
|
-
__exportStar(require("./memory/index.js"), exports);
|
|
29
|
-
__exportStar(require("./shouldLog.js"), exports);
|
|
30
|
-
__exportStar(require("./suppressLogs.js"), exports);
|
|
19
|
+
__exportStar(require("./formatter.js"), exports);
|
|
20
|
+
__exportStar(require("./logLevels.js"), exports);
|
|
21
|
+
__exportStar(require("./memory.js"), exports);
|
|
22
|
+
__exportStar(require("./standardLog.js"), exports);
|
|
31
23
|
__exportStar(require("./types.js"), exports);
|
|
32
|
-
__exportStar(require("./utils.js"), exports);
|
|
33
24
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,8CAA2B;AAC3B,iDAA8B;AAC9B,iDAA8B;AAC9B,8CAA2B;AAC3B,mDAAgC;AAChC,6CAA0B","sourcesContent":["export * from './console.js'\nexport * from './errors.js'\nexport * from './formatter.js'\nexport * from './logLevels.js'\nexport * from './memory.js'\nexport * from './standardLog.js'\nexport * from './types.js'\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare const logLevels: {
|
|
2
|
+
/**
|
|
3
|
+
* none: 0
|
|
4
|
+
*/
|
|
5
|
+
none: number;
|
|
6
|
+
/**
|
|
7
|
+
* emergency: 100
|
|
8
|
+
*/
|
|
9
|
+
emergency: number;
|
|
10
|
+
/**
|
|
11
|
+
* alert: 200
|
|
12
|
+
*/
|
|
13
|
+
alert: number;
|
|
14
|
+
/**
|
|
15
|
+
* critical: 300
|
|
16
|
+
*/
|
|
17
|
+
critical: number;
|
|
18
|
+
/**
|
|
19
|
+
* error: 400
|
|
20
|
+
*/
|
|
21
|
+
error: number;
|
|
22
|
+
/**
|
|
23
|
+
* warn: 500
|
|
24
|
+
*/
|
|
25
|
+
warn: number;
|
|
26
|
+
/**
|
|
27
|
+
* notice: 600
|
|
28
|
+
*/
|
|
29
|
+
notice: number;
|
|
30
|
+
/**
|
|
31
|
+
* info: 700
|
|
32
|
+
*/
|
|
33
|
+
info: number;
|
|
34
|
+
/**
|
|
35
|
+
* debug: 800
|
|
36
|
+
*/
|
|
37
|
+
debug: number;
|
|
38
|
+
/**
|
|
39
|
+
* trace: 900
|
|
40
|
+
*/
|
|
41
|
+
trace: number;
|
|
42
|
+
/**
|
|
43
|
+
* planck: Infinity
|
|
44
|
+
* `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.
|
|
45
|
+
*/
|
|
46
|
+
planck: number;
|
|
47
|
+
/**
|
|
48
|
+
* all: Infinity
|
|
49
|
+
*/
|
|
50
|
+
all: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Convert default log level value to log level name.
|
|
54
|
+
*/
|
|
55
|
+
export declare function toLogLevelName(level: number): "emergency" | "alert" | "critical" | "error" | "warn" | "notice" | "info" | "debug" | "trace" | "planck";
|
|
56
|
+
/**
|
|
57
|
+
* Convert default log level name to log level value.
|
|
58
|
+
*/
|
|
59
|
+
export declare function toLogLevel(name: string): any;
|
|
60
|
+
//# sourceMappingURL=logLevels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logLevels.d.ts","sourceRoot":"","sources":["../ts/logLevels.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;IACpB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;CAEJ,CAAA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,4GAW3C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,OAEtC"}
|
package/cjs/logLevels.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toLogLevel = exports.toLogLevelName = exports.logLevels = void 0;
|
|
4
|
+
exports.logLevels = {
|
|
5
|
+
/**
|
|
6
|
+
* none: 0
|
|
7
|
+
*/
|
|
8
|
+
none: 0,
|
|
9
|
+
/**
|
|
10
|
+
* emergency: 100
|
|
11
|
+
*/
|
|
12
|
+
emergency: 100,
|
|
13
|
+
/**
|
|
14
|
+
* alert: 200
|
|
15
|
+
*/
|
|
16
|
+
alert: 200,
|
|
17
|
+
/**
|
|
18
|
+
* critical: 300
|
|
19
|
+
*/
|
|
20
|
+
critical: 300,
|
|
21
|
+
/**
|
|
22
|
+
* error: 400
|
|
23
|
+
*/
|
|
24
|
+
error: 400,
|
|
25
|
+
/**
|
|
26
|
+
* warn: 500
|
|
27
|
+
*/
|
|
28
|
+
warn: 500,
|
|
29
|
+
/**
|
|
30
|
+
* notice: 600
|
|
31
|
+
*/
|
|
32
|
+
notice: 600,
|
|
33
|
+
/**
|
|
34
|
+
* info: 700
|
|
35
|
+
*/
|
|
36
|
+
info: 700,
|
|
37
|
+
/**
|
|
38
|
+
* debug: 800
|
|
39
|
+
*/
|
|
40
|
+
debug: 800,
|
|
41
|
+
/**
|
|
42
|
+
* trace: 900
|
|
43
|
+
*/
|
|
44
|
+
trace: 900,
|
|
45
|
+
/**
|
|
46
|
+
* planck: Infinity
|
|
47
|
+
* `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.
|
|
48
|
+
*/
|
|
49
|
+
planck: Infinity,
|
|
50
|
+
/**
|
|
51
|
+
* all: Infinity
|
|
52
|
+
*/
|
|
53
|
+
all: Infinity
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Convert default log level value to log level name.
|
|
57
|
+
*/
|
|
58
|
+
function toLogLevelName(level) {
|
|
59
|
+
if (level <= 100)
|
|
60
|
+
return 'emergency';
|
|
61
|
+
if (level <= 200)
|
|
62
|
+
return 'alert';
|
|
63
|
+
if (level <= 300)
|
|
64
|
+
return 'critical';
|
|
65
|
+
if (level <= 400)
|
|
66
|
+
return 'error';
|
|
67
|
+
if (level <= 500)
|
|
68
|
+
return 'warn';
|
|
69
|
+
if (level <= 600)
|
|
70
|
+
return 'notice';
|
|
71
|
+
if (level <= 700)
|
|
72
|
+
return 'info';
|
|
73
|
+
if (level <= 800)
|
|
74
|
+
return 'debug';
|
|
75
|
+
if (level <= 900)
|
|
76
|
+
return 'trace';
|
|
77
|
+
return 'planck';
|
|
78
|
+
}
|
|
79
|
+
exports.toLogLevelName = toLogLevelName;
|
|
80
|
+
/**
|
|
81
|
+
* Convert default log level name to log level value.
|
|
82
|
+
*/
|
|
83
|
+
function toLogLevel(name) {
|
|
84
|
+
return exports.logLevels[name.toLocaleLowerCase()];
|
|
85
|
+
}
|
|
86
|
+
exports.toLogLevel = toLogLevel;
|
|
87
|
+
//# sourceMappingURL=logLevels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logLevels.js","sourceRoot":"","sources":["../ts/logLevels.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,CAAC;IACP;;OAEG;IACH,SAAS,EAAE,GAAG;IACd;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;OAEG;IACH,QAAQ,EAAE,GAAG;IACb;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;OAEG;IACH,IAAI,EAAE,GAAG;IACT;;OAEG;IACH,MAAM,EAAE,GAAG;IACX;;OAEG;IACH,IAAI,EAAE,GAAG;IACT;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;OAEG;IACH,KAAK,EAAE,GAAG;IACV;;;OAGG;IACH,MAAM,EAAE,QAAQ;IAChB;;OAEG;IACH,GAAG,EAAE,QAAQ;CACd,CAAA;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAa;IAC1C,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,WAAW,CAAA;IACpC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,UAAU,CAAA;IACnC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,QAAQ,CAAA;IACjC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,OAAO,QAAQ,CAAA;AACjB,CAAC;AAXD,wCAWC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAQ,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;AACrD,CAAC;AAFD,gCAEC","sourcesContent":["export const logLevels = {\n /**\n * none: 0\n */\n none: 0,\n /**\n * emergency: 100\n */\n emergency: 100,\n /**\n * alert: 200\n */\n alert: 200,\n /**\n * critical: 300\n */\n critical: 300,\n /**\n * error: 400\n */\n error: 400,\n /**\n * warn: 500\n */\n warn: 500,\n /**\n * notice: 600\n */\n notice: 600,\n /**\n * info: 700\n */\n info: 700,\n /**\n * debug: 800\n */\n debug: 800,\n /**\n * trace: 900\n */\n trace: 900,\n /**\n * planck: Infinity\n * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.\n */\n planck: Infinity,\n /**\n * all: Infinity\n */\n all: Infinity\n}\n\n/**\n * Convert default log level value to log level name.\n */\nexport function toLogLevelName(level: number) {\n if (level <= 100) return 'emergency'\n if (level <= 200) return 'alert'\n if (level <= 300) return 'critical'\n if (level <= 400) return 'error'\n if (level <= 500) return 'warn'\n if (level <= 600) return 'notice'\n if (level <= 700) return 'info'\n if (level <= 800) return 'debug'\n if (level <= 900) return 'trace'\n return 'planck'\n}\n\n/**\n * Convert default log level name to log level value.\n */\nexport function toLogLevel(name: string) {\n return (logLevels as any)[name.toLocaleLowerCase()]\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Logger, LogLevel, LogReporter, StandardLogOptions } from './types.js';
|
|
2
|
+
export declare function createLogStore(options: StandardLogOptions): LogStore;
|
|
3
|
+
export interface LogStore {
|
|
4
|
+
loggers: Record<string, Logger>;
|
|
5
|
+
reporters: LogReporter[];
|
|
6
|
+
logLevel: LogLevel;
|
|
7
|
+
logLevelStore: ReturnType<typeof logLevelStore>;
|
|
8
|
+
}
|
|
9
|
+
export interface LogLevelStoreOptions {
|
|
10
|
+
customLevels?: Record<string, number>;
|
|
11
|
+
}
|
|
12
|
+
export declare function logLevelStore(options: LogLevelStoreOptions): {
|
|
13
|
+
getName(level: number): string;
|
|
14
|
+
getLevel(name: string): number;
|
|
15
|
+
getAllLevels(): {
|
|
16
|
+
name: string;
|
|
17
|
+
level: number;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=logStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../ts/logStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEnF,wBAAgB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,QAAQ,CAOpE;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;CAChD;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACtC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB;mBAWxC,MAAM;mBAGN,MAAM;;;;;EAWxB"}
|
package/cjs/logStore.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logLevelStore = exports.createLogStore = void 0;
|
|
4
|
+
var type_plus_1 = require("type-plus");
|
|
5
|
+
var console_js_1 = require("./console.js");
|
|
6
|
+
var logLevels_js_1 = require("./logLevels.js");
|
|
7
|
+
function createLogStore(options) {
|
|
8
|
+
return {
|
|
9
|
+
loggers: {},
|
|
10
|
+
reporters: options.reporters || [(0, console_js_1.createConsoleLogReporter)()],
|
|
11
|
+
logLevel: options.logLevel,
|
|
12
|
+
logLevelStore: logLevelStore(options)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.createLogStore = createLogStore;
|
|
16
|
+
function logLevelStore(options) {
|
|
17
|
+
var customLevels = options.customLevels || {};
|
|
18
|
+
var store = {
|
|
19
|
+
customLevels: customLevels,
|
|
20
|
+
customLevelsReverse: (0, type_plus_1.reduceByKey)(customLevels, function (p, k) {
|
|
21
|
+
p[customLevels[k]] = k;
|
|
22
|
+
return p;
|
|
23
|
+
}, {})
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
getName: function (level) {
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = store.customLevelsReverse[level]) !== null && _a !== void 0 ? _a : (0, logLevels_js_1.toLogLevelName)(level);
|
|
29
|
+
},
|
|
30
|
+
getLevel: function (name) {
|
|
31
|
+
var _a;
|
|
32
|
+
return (_a = store.customLevels[name]) !== null && _a !== void 0 ? _a : (0, logLevels_js_1.toLogLevel)(name);
|
|
33
|
+
},
|
|
34
|
+
getAllLevels: function () {
|
|
35
|
+
return (0, type_plus_1.reduceKey)(logLevels_js_1.logLevels, function (result, name) {
|
|
36
|
+
if (name !== 'none' && name !== 'all')
|
|
37
|
+
result.push({ name: name, level: logLevels_js_1.logLevels[name] });
|
|
38
|
+
return result;
|
|
39
|
+
}, (0, type_plus_1.mapKey)(store.customLevels, function (name) { return ({ name: name, level: store.customLevels[name] }); }));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.logLevelStore = logLevelStore;
|
|
44
|
+
//# sourceMappingURL=logStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logStore.js","sourceRoot":"","sources":["../ts/logStore.ts"],"names":[],"mappings":";;;AACA,uCAA0D;AAC1D,2CAAuD;AACvD,+CAAsE;AAGtE,SAAgB,cAAc,CAAC,OAA2B;IACxD,OAAO;QACL,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,IAAA,qCAAwB,GAAE,CAAC;QAC5D,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC;KACtC,CAAA;AACH,CAAC;AAPD,wCAOC;AAaD,SAAgB,aAAa,CAAC,OAA6B;IACzD,IAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAA;IAE/C,IAAM,KAAK,GAAG;QACZ,YAAY,cAAA;QACZ,mBAAmB,EAAE,IAAA,uBAAW,EAAC,YAAY,EAAE,UAAC,CAAC,EAAE,CAAC;YAClD,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;YACtB,OAAO,CAAC,CAAA;QACV,CAAC,EAAE,EAA4B,CAAC;KACjC,CAAA;IACD,OAAO;QACL,OAAO,EAAP,UAAQ,KAAa;;YACnB,OAAO,MAAA,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,mCAAI,IAAA,6BAAc,EAAC,KAAK,CAAC,CAAA;QAClE,CAAC;QACD,QAAQ,EAAR,UAAS,IAAY;;YACnB,OAAO,MAAA,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,mCAAI,IAAA,yBAAU,EAAC,IAAI,CAAC,CAAA;QACrD,CAAC;QACD,YAAY;YACV,OAAO,IAAA,qBAAS,EAAC,wBAAS,EAAE,UAAC,MAAM,EAAE,IAAI;gBACvC,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK;oBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,MAAA,EAAE,KAAK,EAAE,wBAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAEpF,OAAO,MAAM,CAAA;YACf,CAAC,EAAE,IAAA,kBAAM,EAAC,KAAK,CAAC,YAAY,EAAE,UAAA,IAAI,IAAI,OAAA,CAAC,EAAE,IAAI,MAAA,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAA3C,CAA2C,CAAC,CAAC,CAAA;QACrF,CAAC;KACF,CAAA;AACH,CAAC;AAzBD,sCAyBC","sourcesContent":["\nimport { mapKey, reduceByKey, reduceKey } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './logLevels.js'\nimport type { Logger, LogLevel, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore(options: StandardLogOptions): LogStore {\n return {\n loggers: {},\n reporters: options.reporters || [createConsoleLogReporter()],\n logLevel: options.logLevel,\n logLevelStore: logLevelStore(options)\n }\n}\n\nexport interface LogStore {\n loggers: Record<string, Logger>,\n reporters: LogReporter[],\n logLevel: LogLevel,\n logLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n customLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n const customLevels = options.customLevels || {}\n\n const store = {\n customLevels,\n customLevelsReverse: reduceByKey(customLevels, (p, k) => {\n p[customLevels[k]] = k\n return p\n }, {} as Record<number, string>)\n }\n return {\n getName(level: number) {\n return store.customLevelsReverse[level] ?? toLogLevelName(level)\n },\n getLevel(name: string) {\n return store.customLevels[name] ?? toLogLevel(name)\n },\n getAllLevels() {\n return reduceKey(logLevels, (result, name) => {\n if (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })\n\n return result\n }, mapKey(store.customLevels, name => ({ name, level: store.customLevels[name] })))\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logStore.spec.d.ts","sourceRoot":"","sources":["../ts/logStore.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
var type_plus_1 = require("type-plus");
|
|
13
|
+
var logLevels_js_1 = require("./logLevels.js");
|
|
14
|
+
var logStore_js_1 = require("./logStore.js");
|
|
15
|
+
var testUtil_js_1 = require("./testUtil.js");
|
|
16
|
+
describe('getName()', function () {
|
|
17
|
+
it.each(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], (0, testUtil_js_1.rangeEntries)(99, 100, 'emergency'), true), (0, testUtil_js_1.rangeEntries)(199, 200, 'alert'), true), (0, testUtil_js_1.rangeEntries)(299, 300, 'critical'), true), (0, testUtil_js_1.rangeEntries)(399, 400, 'error'), true), (0, testUtil_js_1.rangeEntries)(499, 500, 'warn'), true), (0, testUtil_js_1.rangeEntries)(599, 600, 'notice'), true), (0, testUtil_js_1.rangeEntries)(699, 700, 'info'), true), (0, testUtil_js_1.rangeEntries)(799, 800, 'debug'), true), (0, testUtil_js_1.rangeEntries)(899, 900, 'trace'), true), (0, testUtil_js_1.rangeEntries)(9999999, 10000000, 'planck'), true))('convert %i to %s', function (level, logLevel) {
|
|
18
|
+
var store = (0, logStore_js_1.logLevelStore)({ customLevels: {} });
|
|
19
|
+
expect(store.getName(level)).toBe(logLevel);
|
|
20
|
+
});
|
|
21
|
+
it('gets custom log level name', function () {
|
|
22
|
+
var store = (0, logStore_js_1.logLevelStore)({ customLevels: { 'cust-name': 144 } });
|
|
23
|
+
expect(store.getName(144)).toBe('cust-name');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe('getLevel()', function () {
|
|
27
|
+
it('get default log levels', function () {
|
|
28
|
+
var store = (0, logStore_js_1.logLevelStore)({ customLevels: {} });
|
|
29
|
+
var names = [
|
|
30
|
+
'emergency',
|
|
31
|
+
'alert',
|
|
32
|
+
'critical',
|
|
33
|
+
'error',
|
|
34
|
+
'warn',
|
|
35
|
+
'notice',
|
|
36
|
+
'info',
|
|
37
|
+
'debug',
|
|
38
|
+
'trace',
|
|
39
|
+
'planck'
|
|
40
|
+
];
|
|
41
|
+
expect(names.map(function (n) { return store.getLevel(n); })).toEqual([
|
|
42
|
+
100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity
|
|
43
|
+
]);
|
|
44
|
+
});
|
|
45
|
+
it('is case insensitive for default levels', function () {
|
|
46
|
+
var store = (0, logStore_js_1.logLevelStore)({ customLevels: {} });
|
|
47
|
+
var names = [
|
|
48
|
+
'emerGency',
|
|
49
|
+
'aleRt',
|
|
50
|
+
'critIcal',
|
|
51
|
+
'errOr',
|
|
52
|
+
'warN',
|
|
53
|
+
'nOtice',
|
|
54
|
+
'iNfo',
|
|
55
|
+
'deBug',
|
|
56
|
+
'traCe',
|
|
57
|
+
'planCk',
|
|
58
|
+
];
|
|
59
|
+
expect(names.map(function (n) { return store.getLevel(n); })).toEqual([
|
|
60
|
+
100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
it('gets custom log level', function () {
|
|
64
|
+
var store = (0, logStore_js_1.logLevelStore)({ customLevels: { 'cust-get': 123 } });
|
|
65
|
+
expect(store.getLevel('cust-get')).toBe(123);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe('getAllLevels()', function () {
|
|
69
|
+
it('gets all default log levels except none and all', function () {
|
|
70
|
+
var store = (0, logStore_js_1.logLevelStore)({ customLevels: {} });
|
|
71
|
+
var actual = store.getAllLevels();
|
|
72
|
+
(0, type_plus_1.forEachKey)(logLevels_js_1.logLevels, function (name) {
|
|
73
|
+
if (name === 'none' || name === 'all') {
|
|
74
|
+
expect(actual.find(function (x) { return x.name === name; })).toBeUndefined();
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
expect(actual.find(function (x) { return x.name === name; })).toEqual({ name: name, level: logLevels_js_1.logLevels[name] });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
it('include custom level (even if they have the same level value as one of the default level)', function () {
|
|
82
|
+
var store = (0, logStore_js_1.logLevelStore)({
|
|
83
|
+
customLevels: {
|
|
84
|
+
'info_a': 301,
|
|
85
|
+
'info_b': logLevels_js_1.logLevels.info
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
var actual = store.getAllLevels();
|
|
89
|
+
expect(actual.find(function (x) { return x.name === 'info_a'; })).toEqual({ name: 'info_a', level: 301 });
|
|
90
|
+
expect(actual.find(function (x) { return x.name === 'info_b'; })).toEqual({ name: 'info_b', level: logLevels_js_1.logLevels.info });
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=logStore.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logStore.spec.js","sourceRoot":"","sources":["../ts/logStore.spec.ts"],"names":[],"mappings":"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","sourcesContent":["import { forEachKey } from 'type-plus'\nimport { logLevels } from './logLevels.js'\nimport { logLevelStore } from './logStore.js'\nimport { rangeEntries } from './testUtil.js'\n\ndescribe('getName()', () => {\n it.each([\n ...rangeEntries(99, 100, 'emergency'),\n ...rangeEntries(199, 200, 'alert'),\n ...rangeEntries(299, 300, 'critical'),\n ...rangeEntries(399, 400, 'error'),\n ...rangeEntries(499, 500, 'warn'),\n ...rangeEntries(599, 600, 'notice'),\n ...rangeEntries(699, 700, 'info'),\n ...rangeEntries(799, 800, 'debug'),\n ...rangeEntries(899, 900, 'trace'),\n ...rangeEntries(9999999, 10000000, 'planck')\n ])('convert %i to %s', (level: number, logLevel: string) => {\n const store = logLevelStore({ customLevels: {} })\n expect(store.getName(level)).toBe(logLevel)\n })\n it('gets custom log level name', () => {\n const store = logLevelStore({ customLevels: { 'cust-name': 144 } })\n expect(store.getName(144)).toBe('cust-name')\n })\n})\n\ndescribe('getLevel()', () => {\n it('get default log levels', () => {\n const store = logLevelStore({ customLevels: {} })\n const names = [\n 'emergency',\n 'alert',\n 'critical',\n 'error',\n 'warn',\n 'notice',\n 'info',\n 'debug',\n 'trace',\n 'planck'\n ]\n expect(names.map(n => store.getLevel(n))).toEqual([\n 100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity\n ])\n })\n it('is case insensitive for default levels', () => {\n const store = logLevelStore({ customLevels: {} })\n const names = [\n 'emerGency',\n 'aleRt',\n 'critIcal',\n 'errOr',\n 'warN',\n 'nOtice',\n 'iNfo',\n 'deBug',\n 'traCe',\n 'planCk',\n ]\n expect(names.map(n => store.getLevel(n))).toEqual([\n 100, 200, 300, 400, 500, 600, 700, 800, 900, Infinity\n ])\n })\n it('gets custom log level', () => {\n const store = logLevelStore({ customLevels: { 'cust-get': 123 } })\n expect(store.getLevel('cust-get')).toBe(123)\n })\n})\n\ndescribe('getAllLevels()', () => {\n it('gets all default log levels except none and all', () => {\n const store = logLevelStore({ customLevels: {} })\n const actual = store.getAllLevels()\n forEachKey(logLevels, name => {\n if (name === 'none' || name === 'all') {\n expect(actual.find(x => x.name === name)).toBeUndefined()\n }\n else {\n expect(actual.find(x => x.name === name)).toEqual({ name, level: logLevels[name] })\n }\n })\n })\n it('include custom level (even if they have the same level value as one of the default level)', () => {\n const store = logLevelStore({\n customLevels: {\n 'info_a': 301,\n 'info_b': logLevels.info\n }\n })\n const actual = store.getAllLevels()\n expect(actual.find(x => x.name === 'info_a')).toEqual({ name: 'info_a', level: 301 })\n expect(actual.find(x => x.name === 'info_b')).toEqual({ name: 'info_b', level: logLevels.info })\n })\n})\n"]}
|
package/cjs/logger.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { StackTraceMeta } from '@just-func/types';
|
|
2
|
+
import { RequiredPick } from 'type-plus';
|
|
3
|
+
import { LogStore } from './logStore.js';
|
|
4
|
+
import type { Logger, LoggerOptions, LogMethodNames } from './types.js';
|
|
5
|
+
export declare function createLogger<T extends string = LogMethodNames>([store, id, { level, writeTo }]: [LogStore, string, RequiredPick<LoggerOptions, 'level'>], meta?: StackTraceMeta): Logger;
|
|
6
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAGxC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAyB,MAAM,EAAE,aAAa,EAAE,cAAc,EAAe,MAAM,YAAY,CAAA;AAG3G,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EAC5D,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,OAAoB,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,EACtG,IAAI,CAAC,EAAE,cAAc,GACpB,MAAM,CAwDR"}
|