refactor: Clean up logging system with LOG_LEVEL filtering

- Add LOG_LEVEL env variable support (debug, info, warn, error)
- Default to 'info' level for production-ready logs
- Integrate Morgan HTTP logging with custom logger
- Remove console.logs and replace with custom logger
- Remove sensitive password debug logs from email service
- Remove noisy warn logs from email sync and event notifier
- Add gray color for timestamps to improve readability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
richardtekula
2025-12-17 09:45:00 +01:00
parent f8d8bb2330
commit bd44458c32
10 changed files with 66 additions and 44 deletions

View File

@@ -332,7 +332,6 @@ export const sendSingleEventNotification = async (eventId, adminUserId) => {
const userEmail = await getUserEmail(userId);
if (!userEmail) {
logger.warn(`Používateľ ${username} nemá nastavený primárny email - preskakujem`);
stats.skipped++;
continue;
}
@@ -343,7 +342,7 @@ export const sendSingleEventNotification = async (eventId, adminUserId) => {
const textBody = generateEventNotificationText({ firstName, username, event });
// Send email
logger.info(`Odosielam notifikáciu pre ${username} (${userEmail})`);
logger.info(`Odosielam notifikáciu pre ${username}`);
const success = await sendNotificationEmail(jmapConfig, userEmail, subject, htmlBody, textBody);
@@ -427,7 +426,6 @@ export const sendEventNotifications = async () => {
const userEmail = await getUserEmail(userId);
if (!userEmail) {
logger.warn(`Používateľ ${username} nemá nastavený primárny email - preskakujem`);
stats.skipped++;
continue;
}
@@ -438,7 +436,7 @@ export const sendEventNotifications = async () => {
const textBody = generateEventNotificationText({ firstName, username, event });
// Send email
logger.info(`Odosielam notifikáciu pre ${username} (${userEmail}) - udalosť: ${event.title}`);
logger.info(`Odosielam notifikáciu pre ${username} - udalosť: ${event.title}`);
const success = await sendNotificationEmail(jmapConfig, userEmail, subject, htmlBody, textBody);