import log4js from "log4js";
import path from "path";
import config from "./config";

log4js.configure({
  appenders: {
    everything: {
      type: "dateFile",
      filename: path.join(__dirname, "../../logs/app.log"),
    },
    download: {
      type: "file",
      filename: path.join(__dirname, "../../logs/download.log"),
    },
  },
  categories: {
    default: {
      appenders: ["everything"],
      level: config.logger.level,
    },
    download: {
      appenders: ["download"],
      level: config.logger.level,
    },
  },
});

export default function (module) {
  return log4js.getLogger(module);
}
