Phase 1-14 complete: - Unified Express.js API (TypeScript, Prisma ORM, PostgreSQL 16) - React Admin GUI (Vite + Ant Design + Zustand) - JWT auth with refresh tokens - Influence: Campaigns, Representatives, Responses, Email Queue - Map: Locations, Cuts, Shifts, Canvassing System - NAR data import infrastructure (2025 format) - Listmonk newsletter integration - Landing page builder (GrapesJS) - MkDocs + Code Server integration - Volunteer portal with GPS tracking - Monitoring stack (Prometheus, Grafana, Alertmanager) - Pangolin tunnel integration Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
const winston = require('winston');
|
|
const config = require('../config');
|
|
|
|
// Create the logger only once
|
|
const logger = winston.createLogger({
|
|
level: config.isProduction ? 'info' : 'debug',
|
|
defaultMeta: { service: 'bnkops-map' },
|
|
transports: [
|
|
new winston.transports.Console({
|
|
format: winston.format.combine(
|
|
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
|
winston.format.errors({ stack: true }),
|
|
winston.format.colorize(),
|
|
winston.format.printf(({ timestamp, level, message, service }) => {
|
|
return `${timestamp} [${service}] ${level}: ${message}`;
|
|
})
|
|
)
|
|
})
|
|
]
|
|
});
|
|
|
|
// Add file transport in production
|
|
if (config.isProduction) {
|
|
logger.add(new winston.transports.File({
|
|
filename: 'error.log',
|
|
level: 'error',
|
|
format: winston.format.combine(
|
|
winston.format.timestamp(),
|
|
winston.format.errors({ stack: true }),
|
|
winston.format.json()
|
|
)
|
|
}));
|
|
logger.add(new winston.transports.File({
|
|
filename: 'combined.log',
|
|
format: winston.format.combine(
|
|
winston.format.timestamp(),
|
|
winston.format.errors({ stack: true }),
|
|
winston.format.json()
|
|
)
|
|
}));
|
|
}
|
|
|
|
module.exports = logger; |