Initial commit: Telegram Management System
Some checks failed
Deploy / deploy (push) Has been cancelled
Some checks failed
Deploy / deploy (push) Has been cancelled
Full-stack web application for Telegram management - Frontend: Vue 3 + Vben Admin - Backend: NestJS - Features: User management, group broadcast, statistics 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
49
marketing-agent/services/ab-testing/src/utils/logger.js
Normal file
49
marketing-agent/services/ab-testing/src/utils/logger.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import winston from 'winston';
|
||||
import { config } from '../config/index.js';
|
||||
|
||||
const { combine, timestamp, json, printf, colorize } = winston.format;
|
||||
|
||||
// Custom format for console output
|
||||
const consoleFormat = printf(({ level, message, timestamp, ...meta }) => {
|
||||
const metaStr = Object.keys(meta).length ? ` ${JSON.stringify(meta)}` : '';
|
||||
return `${timestamp} [${level}]: ${message}${metaStr}`;
|
||||
});
|
||||
|
||||
// Create logger
|
||||
export const logger = winston.createLogger({
|
||||
level: config.logging.level,
|
||||
format: combine(
|
||||
timestamp(),
|
||||
json()
|
||||
),
|
||||
transports: [
|
||||
// Console transport
|
||||
new winston.transports.Console({
|
||||
format: combine(
|
||||
colorize(),
|
||||
timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
||||
consoleFormat
|
||||
)
|
||||
}),
|
||||
// File transport
|
||||
new winston.transports.File({
|
||||
filename: config.logging.file,
|
||||
format: combine(
|
||||
timestamp(),
|
||||
json()
|
||||
)
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
// Add error file transport in production
|
||||
if (config.env === 'production') {
|
||||
logger.add(new winston.transports.File({
|
||||
filename: 'logs/error.log',
|
||||
level: 'error',
|
||||
format: combine(
|
||||
timestamp(),
|
||||
json()
|
||||
)
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user