0.2.137 • Published 20 days ago

bunion v0.2.137

Weekly downloads
99
License
SEE LICENSE IN li...
Repository
github
Last release
20 days ago

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'
} 
0.2.137

20 days ago

0.2.136

2 months ago

0.2.135

2 months ago

0.1.132

1 year ago

0.1.134

1 year ago

0.1.133

1 year ago

0.0.129

5 years ago

0.0.128

5 years ago

0.0.127

5 years ago

0.0.126

5 years ago

0.0.125

5 years ago

0.0.124

5 years ago

0.0.123

5 years ago

0.0.122

5 years ago

0.0.121

5 years ago

0.0.120

5 years ago

0.0.119

5 years ago

0.0.118

5 years ago

0.0.117

5 years ago

0.0.116

5 years ago

0.0.115

5 years ago

0.0.114

5 years ago

0.0.113

5 years ago

0.0.112

5 years ago

0.0.109

6 years ago

0.0.107

6 years ago

0.0.106

6 years ago

0.0.103

6 years ago

0.0.102

6 years ago

0.0.101

6 years ago