npm.io
3.1.0 • Published 5 years ago

@offirmo/practical-logger-core

Licence
Unlicense
Version
3.1.0
Deps
1
Size
73 kB
Vulns
0
Weekly
0

Offirmo’s practical logger - Core (internal, reusable)
Offirmo’s quality seal

npm badge dependencies badge bundle size badge license badge maintenance status badge

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

Keywords