Here is configuration:
export default function getLogger(filename) {
const config = {
level: process.env.LOG_LEVEL || "info",
defaultMeta: {
service: filename,
},
format: combine(
colorize({ all: true }),
timestamp({
format: "YYYY-MM-DD hh:mm:ss.SSS A",
}),
align(),
printf(
(info) =>
`[${info.timestamp}] [${info.service}] ${info.level}: ${info.message}`
)
),
transports: [new winston.transports.Console()],
};
const logger = winston.createLogger(config);
return logger;
}
Output:
[2024-03-16 05:13:34.799 PM] [app.js] info: Database connected.
[2024-03-16 05:13:34.801 PM] [app.js] info: Server running on port 3000
[2024-03-16 05:13:56.041 PM] [autenticate.js] error: Autenticaion failed
As you can see output is not aligning properly. What am I doing wrong here?