Add log rotation utility with file management and cleanup

- Implemented log rotation module with configurable size and age-based log management
- Added utility functions to parse log file sizes and retention durations
- Created methods for identifying, filtering, and cleaning up old log files
- Integrated log rotation initialization in the main application entry point
- Added periodic checks for log file size and age-based cleanup
This commit is contained in:
jango-blockchained
2025-02-03 15:43:27 +01:00
parent 1753e35cd3
commit 51c1594f2f
3 changed files with 160 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ import { requestLogger, errorLogger } from './middleware/logging.middleware.js';
import { get_hass } from './hass/index.js';
import { LiteMCP } from 'litemcp';
import { logger } from './utils/logger.js';
import { initLogRotation } from './utils/log-rotation.js';
logger.info('Starting Home Assistant MCP...');
logger.info('Initializing Home Assistant connection...');
@@ -27,6 +28,9 @@ logger.info('Initializing Home Assistant connection...');
*/
const app = express();
// Initialize log rotation
initLogRotation();
// Apply logging middleware first to catch all requests
app.use(requestLogger);