Skip to content

Delete old log entries by age; configurable log size/retention; remove logs on uninstall - #233

Open
codeling wants to merge 1 commit into
mainfrom
fix/log-retention-185
Open

codeling wants to merge 1 commit into
mainfrom
fix/log-retention-185

Conversation

@codeling

@codeling codeling commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Fixes #185.

Problem

The "Prune old attempts" setting only deletes database rows. The log file (plg_system_bfstop.log.php) was only rotated by size (5 MB, one previous generation), so entries could stay forever on quiet sites, and the log files stayed behind after logging was disabled or the plugin uninstalled.

Changes

  • LoggerHelper::pruneByAge($days): removes entries older than the retention from the log file and its previous generation, rewriting in place under a lock. Lines that don't start with a timestamp (header, multi-line messages) are kept or dropped with the entry before them. Runs from the daily maintenance, independent of the log level.
  • New plugin parameters: logMaxSize (MB, default 5, as before) and logKeepDays (default 28, 0 = keep until rotated). The settings form fields are in the companion com_bfstop PR.
  • The log files are deleted on uninstall.
  • Tests in LoggerHelperTest; CHANGELOG entry.

Needs the companion PR in com_bfstop (settings + prune/clear buttons in the log view): https://github.com/codeling/com_bfstop/pulls

Testing

Integration tests need a Joomla site and could not be run in my environment; the pruning/rotation logic was checked with a standalone script against stubbed Joomla classes. CI runs the integration tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_017uE6PYkghPiTJRGH1QrWZx


Generated by Claude Code

…gs on uninstall

The daily maintenance now also removes the log entries older than the
configured number of days (default 28) from the log file and its previous
generation, independent of the log level. The size limit at which the log
is rotated is configurable (default 5 MB, as before). The log files are
deleted when the plugin is uninstalled.

Fixes #185

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017uE6PYkghPiTJRGH1QrWZx
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.

Purging feature should also delete old log entries

2 participants