Express/MongoDB backend with JWT auth, RBAC, S3 uploads, notifications, and scheduled jobs.
27 lines
723 B
JavaScript
27 lines
723 B
JavaScript
// /utils/logger.js
|
|
|
|
const winston = require('winston');
|
|
|
|
const logger = winston.createLogger({
|
|
level: process.env.LOG_LEVEL || 'info',
|
|
format: winston.format.combine(
|
|
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
|
winston.format.errors({ stack: true }),
|
|
winston.format.splat(),
|
|
winston.format.json()
|
|
),
|
|
defaultMeta: { service: 'institution-api' },
|
|
transports: [
|
|
new winston.transports.Console({
|
|
format: winston.format.combine(
|
|
winston.format.colorize(),
|
|
winston.format.printf(({ timestamp, level, message, service, stack }) => {
|
|
return `[${timestamp}] [${level}]: ${stack || message}`;
|
|
})
|
|
)
|
|
})
|
|
]
|
|
});
|
|
|
|
module.exports = logger;
|