slf4ts-bunyan

bunyan logging-binding for slf4ts-api

Usage no npm install needed!

<script type="module">
  import slf4tsBunyan from 'https://cdn.skypack.dev/slf4ts-bunyan';
</script>

README

slf4ts-bunyan

bunyan Logging-Binding for slf4ts

NPM Version License Dependencies Status

It's meant to be used with nodejs.

Example Usage

Example package.json:

{
    ...,
    "dependencies": {
        "slf4ts-bunyan": "latest"
    },
    ...
}

Example code:

import { LoggerFactory, LoggerConfiguration } from "slf4ts-api";

const ROOT_LOGGER = LoggerFactory.getLogger();
ROOT_LOGGER.setMetadata({ application: 'my-app' });

/**
 * prints something like:
 * 
 *  {
 *      "hostname":"...",
 *      "pid":...,
 *      "application":"my-app",
 *      "level":30,
 *      "msg":"Test Message { version: '1.0.0' } Error: \n    at Object.<anonymous> ...",
 *      "time":"...",
 *      "v":0
 *  }
 * 
 * Note that the metadata are extra fields while objects
 * passed to the log-method call are part of the log-message
 */
ROOT_LOGGER.info("Test Message", { version: '1.0.0' }, new Error());

License

MIT