jellyfin-discord-bot/server/logger.ts
mightypanders 8a06a661fa
All checks were successful
Compile the repository / compile (pull_request) Successful in 1m28s
adjust some files to new formatting
2023-06-24 21:05:43 +02:00

25 lines
661 B
TypeScript

import { createLogger, format, transports } from "winston"
import { config } from "./configuration"
const printFn = format.printf(({ guildId, level, message, errorCode, requestId, timestamp: logTimestamp }: { [k: string]: string }) => {
return `[${guildId ?? ''}][${level}][${logTimestamp}][${errorCode ?? ''}][${requestId ?? ''}]:${message}`
})
const logFormat = format.combine(
format.timestamp(),
printFn
)
const consoleTransports = [
new transports.Console({
format: logFormat
})
]
export const logger = createLogger({
level: config.bot.debug ? 'debug' : 'info',
format: logFormat,
silent: config.bot.silent,
transports: consoleTransports
})