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 🙏

© 2024 – Pkg Stats / Ryan Hefner

bunion

v0.2.137

Published

Semver-oriented TypeScript library skeleton.

Downloads

136

Readme

Version


Bunion / BXN / B4N

This logging module is ~30% more performant than Bunyan when used as a part of a complete pipeline.

Advantages over other loggers like Bunyan

  1. Has a default logger, configured by .bunion.js
  2. Uses array format instead of object format by default - more readable and more performant
  3. Has CLI tools for navigating log files

Basic API

  1. Only writes to stdout, not stderr
  2. Uses an array format by default:
 return safe.stringify([
   '@bunion:1',  // the format of the logging line, with version number
   appName,    // your app name
   level,      // the logging level
   process.pid,  // the process pid
   host,         // the hostname where the log originated
   new Date().toUTCString(),  // a UTC date string
   fields,     // custom metadata - useful for filtering logs - fields is best used as an object {"xyz":"foo","filter":"on this"}
   message      // your message, which is an array
 ]);

Installation

 $ npm install bunion

| Usage


import log from 'bunion';
log.info('just saying hi.');
log.warn('shit hit the fan', 'part 2');
log.debug('boop', {yep:'this property is on an object'}, {'we can log': {'nested':["objects, also"]}});

the above will log this raw data to stdout:

["@bunion","foobar","INFO",10613,"host@you","Sun, 25 Aug 2019 23:05:42 GMT",null,["just saying hi."]]
["@bunion","foobar","WARN",10613,"host@you","Sun, 25 Aug 2019 23:05:42 GMT",null,["shit hit the fan","part 2"]]
["@bunion","foobar","DEBUG",10613,"host@you","Sun, 25 Aug 2019 23:05:42 GMT",null,["boop",{"yep":"this property is on an object"},{"we can log":{"nested":["objects, also"]}}]]

and then you can read/consume the logs via:


 $ node foo.js | bunion 

Use the following env value for higher performance:


 $ bunion_max_level=warn node foo.js | bunion --level warn

Using the bunion config file to setup a default logger

Use .bunion.js in the root of your project or current working directory.



const getDefaultBunionConf = (): BunionConf => {
  return {
    producer: {
      name: 'default',
      appName: 'default',
      forceRaw: false,
      level: 'TRACE',
      fields: {}
    },
    consumer: {
      localeDateString: 'en-US',
      highlightMatches: true,
      level: 'TRACE',
      match: [],
      matchAny: [],
      matchAll: [],
      inspect: {
        array: {
          length: 25
        },
        object: {
          depth: 5
        }
      },
      transform: {
        keys: {}
      }
    }
  }
};

How it works:


Something like this:

echo '{"@bunion":true,"level":"WARN","appName":"my-api","date":"08-22-1984","value":"this is the end"}' | bunion

Will display this in your terminal:

08-22-1984 app:my-api WARN  this is the end 

Something like this:

 echo '["@bunion","app","INFO",333,"host","date-str",null,"message1"]' | bunion

Will display this in your terminal:

date-str app:app INFO message1 

Something like this:

 echo '["@bunion","app","INFO",333,"host","date-str",null,["message1","message2",{"foo":"bar"}]]' | bunion

Will display this in your terminal:

date-str app:app INFO  message1 message2 {
  foo: 'bar'
}