// const { createLogger, format, transports } = require("winston");
// const path = require("path");

// // Create a logger instance
// const logger = createLogger({
//   level: "error", // Log only errors
//   format: format.combine(
//     format.timestamp({ format: "DD-MM-YYYY HH:mm:ss" }), // Add timestamp
//     format.errors({ stack: true }), // Include stack trace
//     format.json() // Log in JSON format
//   ),
//   transports: [
//     new transports.File({ filename: path.join(__dirname, "error.log") }), // Log to a file
//   ],
// });

// module.exports = logger;

const { createLogger, format, transports } = require("winston");
const path = require("path");

const logger = createLogger({
  format: format.combine(
    format.timestamp({ format: "DD-MM-YYYY HH:mm:ss" }),
    format.errors({ stack: true }),
    format.json()
  ),
  transports: [
    new transports.File({
      filename: path.join(__dirname, "error.log"),
      level: "error",
      handleExceptions: true,
    }),
    // new transports.Console({
    //   format: format.combine(format.colorize(), format.simple()),
    //   handleExceptions: true,
    // }),
  ],
});

module.exports = logger;
