logger.js 625 B

12345678910111213141516171819202122232425262728293031
  1. const { format, createLogger, transports } = require("winston");
  2. const { combine, timestamp, label, printf, prettyPrint } = format;
  3. const CATEGORY = "winston custom format";
  4. const config = require("../configs/config.json")
  5. const logger = createLogger({
  6. level: "debug",
  7. format: combine(
  8. label({ label: CATEGORY }),
  9. timestamp({
  10. format: "MMM-DD-YYYY HH:mm:ss",
  11. }),
  12. prettyPrint()
  13. ),
  14. // transports: [
  15. // new transports.Console()
  16. // ],
  17. transports: [
  18. //new transports:
  19. new transports.File({
  20. filename: config.logfolderpath+"/logs.log",
  21. }),
  22. ],
  23. });
  24. module.exports = logger;