Perplexica/src/utils/logger.ts
WaelAbouceo 7844ca9343 zizo
2025-02-02 12:14:15 +02:00

28 lines
864 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import winston from 'winston';
const { combine, timestamp, printf, colorize } = winston.format;
const logFormat = printf(({ timestamp, level, message }) => {
return `${timestamp} [${level.toUpperCase()}]: ${message}`;
});
const logger = winston.createLogger({
level: process.env.LOG_LEVEL || 'info',
format: combine(
timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
colorize(), // optional color in dev
logFormat
),
transports: [
// Console transport ensures Docker sees logs on stdout
new winston.transports.Console(),
new winston.transports.File({ filename: 'app.log' }),
// Optional: file transport if you also want to persist logs on the containers filesystem
// new winston.transports.File({ filename: 'app.log' }),
],
});
logger.info("✅ Winston logger active, logging to console!");
export default logger;