@railtownai/winston-railtownai
TypeScript icon, indicating that this package has built-in type declarations

1.0.13 • Public • Published

winston-railtown

winston-railtown is a transport to ship your logs to railtown.ai

Install

$ npm install --save @railtownai/winston-railtownai

Options

In adition to the options accepted by winston transport, Railtown Transport accepts the following options:

  • token - string - Your railtown token [required]

You can either provide the token through the environment variable 'RAILTOWN_TOKEN' or pass it through the options.

Usage

const winston = require('winston');
 /**
   * Requiring `@railtownai/winston-railtownai` will expose
   * `winston.transports.RailtownAi`
   */
require('@railtownai/winston-railtownai');

const logger = winston.createLogger({
  // Whatever options you need
  // Refer https://github.com/winstonjs/winston#creating-your-own-logger
  transports: [
    new winston.transports.RailtownAi(options)
  ]
})

// You can also add the logger 
logger.add(new winston.transports.RailtownAi(options))

ES6

import winston from 'winston';
 /**
   * importing `@railtownai/winston-railtownai` will expose
   * `winston.transports.RailtownAi`
   */
import '@railtownai/winston-railtownai';

const logger = winston.createLogger({
  // Whatever options you need
  // Refer https://github.com/winstonjs/winston#creating-your-own-logger
  transports: [
    new winston.transports.RailtownAi(options)
  ]
})

// You can also add the logger 
logger.add(new winston.transports.RailtownAi(options))

Manually Logging Errors with additional properties

Import winstonLogger and use as follows:

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

  winstonLogger.error(logError);
}

Dependents (0)

Package Sidebar

Install

npm i @railtownai/winston-railtownai

Weekly Downloads

0

Version

1.0.13

License

MIT

Unpacked Size

12.3 kB

Total Files

6

Last publish

Collaborators

  • mbrailtown
  • jbueza-railtownai
  • marwanhaddad
  • chrisgirard