Git Product home page Git Product logo

node-bunyan-adaptor's Introduction

Pino / Bunyan Adaptor

npm version npm downloads Module type: CJS+ESM Types in JS js-semistandard-style Follow @voxpelli@mastodon.social

Types and mapper for Pino / Bunyan logging methods.

Support Pino / Bunyan compatible loggers with fallback console.log().

BunyanLite – simplified Pino / Bunyan type subsets

Apart from the actual adapter, this module also ships with some useful generic TypeScript types, where BunyanLite is the most usable of them.

The BunyanLite type can be used wherever one wants to reference a basic Pino / Bunyan subset. That type can then be fulfilled by Pino, Bunyan, a logger created by this module or by another module implementing the same subset.

All Pino / Bunyan type subsets

  • BunyanLite – specifies the lite subset of the Bunyan interface that this module supports
  • BunyanLogMethod – specifies the very simple syntax for the individual log methods
  • BunyanChildMethod – specified the syntax of the child() method

Pino / Bunyan subset that's part of BunyanLite

  • .fatal()
  • .error()
  • .warn()
  • .info()
  • .debug()
  • .trace()
  • .child(data)

createLogger() – map any logger to BunyanLite subset

Simple CommonJS example:

const logger = require('bunyan-adaptor')({
  log: console.log.bind(console),
  error: console.error.bind(console),
});

logger.error('Warning');      // Uses console.error()
logger.info('Informational'); // Uses console.log()

Simple ESM example:

import createLogger from 'bunyan-adaptor';

const logger = createLogger({
  log: console.log.bind(console),
  error: console.error.bind(console),
});

logger.error('Warning');      // Uses console.error()
logger.info('Informational'); // Uses console.log()

Also available as a non-default export:

const { createLogger } = require('bunyan-adaptor');
import { createLogger } from 'bunyan-adaptor';

createLogger(options)

Maps options methods to all seven Bunyan log levels.

  • .fatal() – maps to options.fatal and fallbacks to options.error and options.log in that order
  • .error() – maps to options.error and fallbacks to options.log in that order
  • .warn() – maps to options.warn and fallbacks to options.log
  • .info() – maps to options.info and fallbacks to options.log
  • .debug() – maps to options.debug and fallbacks to options.verbose and options.log in that order
  • .trace() – maps to options.trace and fallbacks to options.verbose and options.log in that order

options.log itself fallbacks to console.log()

In addition to the above there's also support for:

  • .child(data) – used to create a child logger. Defaults to built in method, can be overriden using options.child

See also

node-bunyan-adaptor's People

Contributors

renovate-bot avatar renovate[bot] avatar voxpelli avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-bunyan-adaptor's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codeql-analysis.yml
.github/workflows/dependency-review.yml
.github/workflows/lint.yml
.github/workflows/nodejs.yml
.github/workflows/types.yml
npm
package.json
  • @scoop/bunyan 2.0.2
  • @skypack/package-check ^0.2.2
  • @types/chai ^4.3.5
  • @types/mocha ^10.0.1
  • @types/pino ^7.0.5
  • @types/sinon ^10.0.16
  • @types/sinon-chai ^3.2.9
  • @voxpelli/eslint-config ^19.0.0
  • @voxpelli/tsconfig ^8.0.0
  • c8 ^8.0.1
  • chai ^4.3.7
  • eslint ^8.47.0
  • eslint-plugin-es-x ^7.2.0
  • eslint-plugin-import ^2.28.0
  • eslint-plugin-jsdoc ^46.4.6
  • eslint-plugin-mocha ^10.1.0
  • eslint-plugin-n ^16.0.1
  • eslint-plugin-promise ^6.1.1
  • eslint-plugin-security ^1.7.1
  • eslint-plugin-sort-destructure-keys ^1.5.0
  • eslint-plugin-unicorn ^48.0.1
  • husky ^8.0.3
  • installed-check ^8.0.0
  • knip ^2.19.3
  • linemod ^1.1.0
  • mocha ^10.2.0
  • npm-run-all2 ^6.0.6
  • pino ^8.15.0
  • sinon ^15.2.0
  • sinon-chai ^3.7.0
  • type-coverage ^2.26.0
  • typescript ~5.1.6
  • node >=16.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.