fix: Improve logging - fix LOG_LEVEL filter, reduce HTTP noise

- Fix LOG_LEVEL filtering logic (was inverted)
- HTTP logs now only show errors (4xx, 5xx) by default
- Add database connection check at startup
- Cron jobs logged on separate lines
- LOG_LEVEL=debug shows all HTTP requests

🤖 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:54:07 +01:00
parent 095a3a5b03
commit 3cd2531f6b
5 changed files with 49 additions and 27 deletions

View File

@@ -1,11 +1,25 @@
import app from './app.js';
import { startAllCronJobs } from './cron/index.js';
import { logger } from './utils/logger.js';
import { testConnection } from './config/database.js';
const port = process.env.PORT || 5000;
app.listen(port, () => {
logger.info(`Server running on http://localhost:${port}`);
// Start cron jobs after server is running
startAllCronJobs();
});
const start = async () => {
try {
// Test database connection
await testConnection();
logger.success('Database connected');
// Start server
app.listen(port, () => {
logger.info(`Server running on http://localhost:${port}`);
startAllCronJobs();
});
} catch (error) {
logger.error('Failed to start server', error);
process.exit(1);
}
};
start();