0.0.2 • Published 2 years ago

bunyan-test-francisco v0.0.2

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

bunyan-railtownai

bunyan-railtownai is a bunyan stream to ship your logs to railtown.ai

For testing purposes only

Install

$ npm install @railtownai/bunyan-railtownai

Options

Usage

const bunyan = require('bunyan');
const BunyanRailtownAi = require('@railtownai/bunyan-railtownai');


const log = bunyan.createLogger({
  name: 'myapp',
  stream: new BunyanRailtownAi({
    token: 'your_token_here',
  }),
});

//or use environment variable 'RAILTOWN_TOKEN' and call it without the token key

const log = bunyan.createLogger({
  name: 'myapp',
  stream: new BunyanRailtownAi(),
});

Manually Logging Errors with additional properties

Import bunyanLogger and use as follows:

try {
  // code to try 
} catch (error) {
    const logError = {
      err: { message: error.message, stack: error.stack },
      userId: '123456789',
      projectId: 'abcdefg'
    };

    bunyanLogger.error(logError, error.message);
}