@railtownai/winston-railtownai
v1.0.13
Published
winston-railtownai is a transport to ship your logs to railtown.ai
Downloads
7
Readme
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);
}