@offirmo/practical-logger-core

Common internal code for Offirmo’s practical logger

Usage no npm install needed!

<script type="module">
  import offirmoPracticalLoggerCore from 'https://cdn.skypack.dev/@offirmo/practical-logger-core';
</script>

README

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