1.3.9 • Published 5 years ago
standard-log-memory v1.3.9
standard-log-memory
Provides a memory log reporter for standard-log
Usage
import { createMemoryLogReporter, logEntriesToString } from 'standard-log-memory'
import { config, getLogger } from 'standard-log'
const reporter = createMemoryLogReporter()
config({ reporters: [reporter]})
const log = getLogger('some logger')
log.info('some log')
console.info(reporter.logs) // contains all log entries
console.info(logEntriesToString(reporter.logs)) // render log entries as string using `plainFormatter`
You can supply a formatter
to pre-process the log entries before they are saved.
For example, you can use it to censor sensitive information.
import { createMemoryLogReporter } from 'standard-log-memory'
const reporter = createMemoryLogReporter({
formatter: (entry) => ({
...entry,
args: entry.args(removeSensitiveInformation)
})
})
function removeSensitiveInformation(values: any[]) {
return /* your implementation */
}