Skip to content

#147 - Purge the log records and the log files older than a configured retention - #148

Merged
njoubert-cleverage merged 2 commits into
mainfrom
147
Oct 13, 2026
Merged

njoubert-cleverage merged 2 commits into
mainfrom
147

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #147: log retention, as proposed in #147 (comment) (no CSV export: the log file of the execution is the archive).

Configuration

  • New bundle configuration logs.database_max_days and logs.file_max_days (int ≥ 1, default null: kept, no behaviour change).
  • Both overridable by process, under the new logs key of its options (next to ui and notification); a missing or null key is inherited from the bundle configuration. ProcessConfigurationsManager::getLogsOptions().

cleverage:ui-process:purge-logs [--dry-run]

  • Database: deletes the log_record rows created more than database_max_days days ago (DBAL, by batches of 1000: select ids, DELETE ... WHERE id IN (...)).
  • Files: scans %kernel.logs_dir%/<code>/ and deletes the files last modified more than file_max_days days ago. Only the files written by the bundle (<uuid>.log) are deleted; a code that cannot be a directory name of the log directory (.., /) is skipped.
  • Processed codes: those of process_execution and those of the defined processes; the executions of a process no longer defined use the bundle retention.
  • process_execution is never modified nor deleted: the UI already hides "Download log file" (file missing) and "Show logs stored in database" (no log left).
  • --dry-run counts without deleting. Output: one row per process with a retention (retentions, records / files deleted) and totals.
  • Reclaiming the database space (VACUUM FULL, OPTIMIZE TABLE, VACUUM) is not run by the command: it locks the table and would block the running processes. Documented, to run once after the first purge during a maintenance window.

Documentation

Executions & logs reference (new "Log retention" section, with "Database space"), bundle configuration, process UI options (logs key), console commands, index, troubleshooting ("The log_record table keeps growing"); CHANGELOG (Latest).

Tests

  • Configuration (defaults, custom, invalid values), extension wiring, getLogsOptions() (defaults, configured, invalid values, unknown process).
  • Functional PurgeLogsCommandTest on the SQLite test database: service, nothing to purge, bundle and process retentions, process no longer defined, file not written by the bundle kept, --dry-run, database retention only, process retention only, 2001 records deleted by batches, executions kept.
  • 397 tests OK. PHPStan, PHP-CS-Fixer, Rector, Twig-CS-Fixer OK.
  • Not run on MySQL / PostgreSQL (standard DBAL queries).

Requirements

  • Documentation updates
    • Reference
    • Changelog
  • Unit tests

Breaking changes

None: new configuration with null defaults (nothing purged), new process option, new command. Minor.

🤖 Generated with Claude Code

njoubert-cleverage and others added 2 commits October 13, 2026 16:23
…d retention

New cleverage:ui-process:purge-logs command, logs.database_max_days and logs.file_max_days bundle configuration, overridable by the logs option of each process. The process executions are kept.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage
njoubert-cleverage merged commit cb88e9e into main Oct 13, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add log rotation in database process logs

1 participant