mirror of https://github.com/preservetube/auto.git
27 lines
958 B
JavaScript
27 lines
958 B
JavaScript
const winston = require('winston')
|
|
const { Logtail } = require('@logtail/node')
|
|
const { LogtailTransport } = require('@logtail/winston')
|
|
|
|
const logtail = new Logtail(process.env.LOGTAIL)
|
|
|
|
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}`),
|
|
)}),
|
|
new LogtailTransport(logtail, {
|
|
level: 'error'
|
|
})
|
|
],
|
|
});
|
|
|
|
module.exports = logger |