winston-railtown is a transport to ship your logs to railtown.ai
For testing purposes only
$ npm install --save @railtownai/winston-railtownai
- token: Your railtown token [required]
const winston = require('winston')
import RailtownTransport from '@railtownai/winston-railtownai')
var logger = winston.createLogger({
// Whatever options you need
// Refer https://github.com/winstonjs/winston#creating-your-own-logger
})
logger.add(
new RailtownTransport({
token: 'your_token_here',
... //winston transport options
})
)
//or use environment variable 'RAILTOWN_TOKEN' and call it without the token key
logger.add(
new RailtownTransport({
... //winston transport options
})
)
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);
}