2023-03-28 14:52:17 +00:00
|
|
|
const winston = require('winston')
|
2023-09-02 18:28:53 +00:00
|
|
|
const { Logtail } = require('@logtail/node')
|
|
|
|
const { LogtailTransport } = require('@logtail/winston')
|
|
|
|
|
|
|
|
const logtail = new Logtail(process.env.LOGTAIL)
|
|
|
|
|
2023-03-28 14:52:17 +00:00
|
|
|
const logger = winston.createLogger({
|
|
|
|
format: winston.format.json(),
|
|
|
|
transports: [
|
|
|
|
new winston.transports.Console({
|
|
|
|
format:winston.format.combine(
|
|
|
|
winston.format.timestamp({format: 'MMM-DD-YYYY HH:mm:ss'}),
|
|
|
|
winston.format.printf(info => `${[info.timestamp]}: ${info.message}`),
|
|
|
|
)}),
|
|
|
|
new winston.transports.File({
|
|
|
|
filename: 'logs/client.log',
|
|
|
|
format:winston.format.combine(
|
|
|
|
winston.format.timestamp({format: 'MMM-DD-YYYY HH:mm:ss'}),
|
|
|
|
winston.format.printf(info => `${[info.timestamp]}: ${info.message}`),
|
|
|
|
)}),
|
2023-09-02 18:28:53 +00:00
|
|
|
new LogtailTransport(logtail, {
|
|
|
|
level: 'error'
|
|
|
|
})
|
2023-03-28 14:52:17 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = logger
|