Initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
const winston = require("winston");
|
||||
|
||||
const prettyFormat = winston.format.printf(({ timestamp, level, message, error, ...meta }) => {
|
||||
const logObject = {
|
||||
timestamp,
|
||||
level,
|
||||
message,
|
||||
...(Object.keys(meta).length ? { meta } : {}),
|
||||
};
|
||||
|
||||
return JSON.stringify(logObject, null, 2);
|
||||
});
|
||||
|
||||
const logger = winston.createLogger({
|
||||
level: "info",
|
||||
format: winston.format.combine(
|
||||
winston.format.errors({ stack: true }),
|
||||
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
|
||||
prettyFormat),
|
||||
transports: [
|
||||
new winston.transports.Console(),
|
||||
new winston.transports.File({ filename: "./Logs/error.log", level: "error" }),
|
||||
],
|
||||
});
|
||||
|
||||
module.exports = logger;
|
||||
Reference in New Issue
Block a user