npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cork-labs/monkfish-adapter-logger

v0.3.0

Published

Logger adapter for Node.js framework Monkfish

Downloads

16

Readme

Monkfish Adapter Logger

Logger adapter for Node.js framework Monkfish.

Getting Started

npm install --save @cork-labs/monkfish @cork-labs/monkfish-adapter-logger

Wraps bunyan logger library to facilitate injection, testing and configuration of logs.

See Monkfish for more information.

API

Logger

Logger.createLogger(config, data)

Creates an instance of Logger from configuration.

  • config: object - of stream instances (OutBunyan, OutConsole, OutFile).
  • data: object (optional) - permanent log fields (tip: keep it flat).

Example config:

{
  name: 'my-app',
  streams: [
    // append to file (does not create directories, will fail if dirs are missings)
    {
      type: 'file',
      path: './logs/test.log',
      options: { ... } // override options for this stream only
    },
    {
      type: 'bunyan',
      bunyan: { /* Bunyan nativate options */ },
      // options: { ... } are ignored in bunyan stream
    },
    // for debug purposes only, do not use in production
    {
      type: 'console',
      // override options for this stream, e.g.: make console more human friendly
      options: {
        message: true,
        prettyJson: 2,
        dump: true
      }
    },
  ],
  // options for all streams
  options: {
    message: false, // log an extra line with a human readable message before the json payload
    prettyJson: 0, // format json payload (multi-line)
    dump: false // output error stack traces after payload (multi-line)
  }
}

new Logger(name, streams): void

Creates an instance of Logger with the pre-configured stream instances.

  • name: string - added to the log fields as log_n
  • streams: array - of stream instances (OutBunyan, OutConsole, OutFile).
  • data: object (optional) - permanent log fields (tip: keep it flat).

logger.child(data): Logger

Returns a new logger, containing all the parent configuration and context, plus the provided optional data.

  • data: object (optional) - additional permanent log fields (tip: keep it flat).

logger.set(key, value): void

Adds key/value to permanent fields data or removes key when value not provided.

Avoid adding objects, keep it flat.

  • key: string
  • value: any (optional) - If value not provided (or undefined is provided), removes key from permanent fields.

logger.debug('message', data): void

Logs a debug level message, with adittional optional fields.

logger.info(message, data): void

Logs an info level message, with adittional optional fields.

  • message: string - logged as log_m.
  • data: object (optional) - additional fields for this log message only.

logger.warn('message', data): void

Logs an warning level message, with adittional optional fields.

  • message: string - logged as log_m.
  • data: object (optional) - additional fields for this log message only.

logger.error('message', data, err): void

Logs an error level message, with adittional optional fields, plus optional error (ideally a subclass of Error).

  • message: string - logged as log_m.
  • data: object (optional) - additional fields for this log message only.

If error is a subclass of Error, only the following key/values are added to the log.

  • err_name: err.constructor.name
  • err_msg: err.message
  • err_trace: err.stack

Otherwise, it is directly logged under the err key.

logger.flat(prefix, obj): object

Flattens the object for logging, use on data objects before you log them to keep them flat.

  • prefix: string - e.g. user.
  • data: object (optional) - additional fields for this log message only.
  • ret: object (optional) - if provided, fields are flattened into this object.
// flattening one object
const flatUser = logger.flat('todo', todo);
logger.info('todo.created', data);

// { log_m: 'todo.created', ..., todo_id: ..., todo_title: ... }

// flattening two objects into one
const data = logger.flat('article', article, {});
logger.flat('tag', tag, data)
logger.info('article.tags.created', data);

// { log_m: 'article.tags.created', ..., todo_id: ..., todo_title: ..., tag_id: ..., tag_title: ... }

Develop

# lint and fix
npm run lint

# run test suite
npm test

# lint and test
npm run build

# serve test coverage
npm run coverage

# publish a minor version
node_modules/.bin/npm-bump minor

Contributing

We'd love for you to contribute to our source code and to make it even better than it is today!

Check CONTRIBUTING before submitting issues and PRs.

Links

MIT License

Copyright (c) 2018 Cork Labs