3.1.0 • Published 4 years ago

@offirmo/practical-logger-core v3.1.0

Weekly downloads
15
License
Unlicense
Repository
github
Last release
4 years ago

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:

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 })