GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - voxpelli/node-bunyan-adaptor: Maps the major Pino / Bunyan logging methods to custom methods

BranchesTags
Open more actions menu

Latest commit

 

History

131 Commits
131 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.husky
.husky
 
 
test
test
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.knip.jsonc
.knip.jsonc
 
 
.npmrc
.npmrc
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
declaration.tsconfig.json
declaration.tsconfig.json
 
 
eslint.config.mjs
eslint.config.mjs
 
 
index.d.ts
index.d.ts
 
 
index.js
index.js
 
 
package.json
package.json
 
 
reference-types.d.ts
reference-types.d.ts
 
 
renovate.json
renovate.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

Pino / Bunyan Adaptor

npm version npm downloads Module type: ESM Types in JS neostandard javascript 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 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 named export:

import { createLogger } from 'bunyan-adaptor';

CommonJS require() is also supported via Node.js ESM require() loading:

const createLogger = require('bunyan-adaptor');
// or
const { createLogger } = require('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

  • abstract-logging

About

Maps the major Pino / Bunyan logging methods to custom methods

Topics

bunyanbunyan-interfaceconsole-logfallbacksloggingmockingpino

Resources

Readme
0BSD license

Contributing

Contributing

Security policy

Security policy
Activity

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Sponsor this project

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.