import { Injectable, type LoggerService, Scope } from "@nestjs/common"; import * as Winston from "winston"; @Injectable({ scope: Scope.TRANSIENT }) export class LogService implements LoggerService { private readonly winstonLogger: Winston.Logger; constructor() { this.winstonLogger = Winston.createLogger({ format: Winston.format.combine( Winston.format.timestamp(), Winston.format.simple(), ), transports: [ new Winston.transports.Console(), new Winston.transports.File({ filename: "application.log" }), ], }); } log(message: string) { this.winstonLogger.info(message); } error(message: string, trace: string) { this.winstonLogger.error(`Message: ${message} - Trace: ${trace}`); } warn(message: string) { this.winstonLogger.warn(message); } debug(message: string) { this.winstonLogger.debug(message); } verbose(message: string) { this.winstonLogger.verbose(message); } }