@offirmo/practical-logger-core
v3.1.0
Published
Common internal code for Offirmo’s practical logger
Downloads
45
Readme
This is an internal / technical component of Offirmo’s practical logger.
- isomorphic code for node and browser
- TODO explain the interface pattern
Usage
This is most likely not what you are looking for!
See the final implementations using this module:
- minimal no-op: @offirmo/practical-logger-minimal-noop
- browser: @offirmo/practical-logger-browser
- node: @offirmo/practical-logger-node
if you know what you are doing:
While this module was made to be a component in a final logger sink, it is a perfectly working logger which will output JSON lines to stdout, corresponding to log lines, in the same way bunyan does.
import { createLogger } from '@offirmo/practical-logger-core'
const logger = createLogger({ /* ... */ })
logger.verbose('foo', { bar: 42, baz: 33 })
Advanced usage:
import { createLogger, LogPayload } from '@offirmo/practical-logger-core'
function sink(payload: LogPayload) {
const {
level,
name,
msg,
time,
err,
details
} = payload
/* ... */
}
const logger = createLogger({ /* ... */ }, sink)
logger.verbose('foo', { bar: 42, baz: 33 })