3.0.2 • Published 6 years ago

@availjs/avail-bunyan v3.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

AvailBunyan

Higher Order Bunyan Avail Service that adds a log method to your Avail Service. AvailBunyan is powered by bunyan.

Installation

  npm i @availjs/avail-bunyan

Usage

AvailBunyan exposes a Higher Order Service function called WithBunyan. WithBunyan takes a Bunyan Configuration Object and returns an Avail Constructor. By default WithBunyan will use the Avail class as it's base class, but takes a Base Class as it's second parameter.

  const {Avail} = require('@availjs/avail');
  const {WithBunyan, AddStandardLoggers} = require('@availjs/avail-bunyan');
  const Logger = require('bunyan');
  
  // bunyan configuration object
  const logOptions = {
    name: 'MyService',
    streams: [
      {
        stream: process.stdout,
        level: 'info'
      },
      {
        stream: process.stderr,
        level: 'error'
      }
    ]
  };
  
  class MyAvailService extends Avail {}
  
  const MyAvailServiceConstructor = WithBunyan(logOptions, MyAvailService);
  const myAvailService = new MyAvailServiceConstructor('MyAvailService');
  
  assert(myAvailService.log instanceof Logger);
  
  // avail-bunyan also includes a helper function to add standard loggers to your Avail instance.
  AddStandardLoggers(myAvailService); 
  // this will add logs for ON_START, ON_INIT, ON_READY, ON_STOP, and ON_ERROR 
3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago