import { createLogger, format, transports } from "winston";
import "winston-daily-rotate-file";
import { join } from "path";

const defaultFormat = format.combine(
  format.timestamp({
    format: "YYYY-MM-DD HH:mm:ss",
  }),
  format.errors({ stack: true }),
  format.simple(),
  format.colorize(),
);

const logger = createLogger({
  format: defaultFormat,
  transports: [
    new transports.DailyRotateFile({
      filename: join("Taehui", "%DATE%.log"),
      zippedArchive: true,
    }),
  ],
});

logger.add(
  new transports.Console({
    format: defaultFormat,
  }),
);

export default logger;
