Auto-deletion of log files based on config#80
Merged
arhimede merged 3 commits intodotkernel:5.0from Oct 14, 2025
Merged
Conversation
Signed-off-by: Jurj-Bogdan <bogdanjurj11@gmail.com>
arhimede
reviewed
Oct 13, 2025
| $path = $streamData['uri']; | ||
| $uriParts = pathinfo($path); | ||
|
|
||
| $files = scandir($uriParts['dirname']); |
Member
There was a problem hiding this comment.
you need to be sure that you are in the log folder all the time
hmm
| $fileTimestamp !== false | ||
| && $fileTimestamp < $this->logLifetime | ||
| ) { | ||
| unlink($match); |
Member
There was a problem hiding this comment.
what is for various reason the file have wrong permissions ?
or it is a symlink ?
should we use @ unlink ?
Member
I think is too much to allow such a comple format |
Signed-off-by: Jurj-Bogdan <bogdanjurj11@gmail.com>
arhimede
reviewed
Oct 14, 2025
| 'name' => 'MyFilter', | ||
| ], | ||
| ], | ||
| 'log_lifetime' => null, // optional |
Member
There was a problem hiding this comment.
add here a short comment with possible values , which mean an integger
Signed-off-by: Jurj-Bogdan <bogdanjurj11@gmail.com>
arhimede
approved these changes
Oct 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An initial version of the feature requested in #79 .
This PR only adds an extra method to the existing
StreamWriterclass and the extra config and processing it requires.A few things to mention:
StreamclassAbstractWriteritself as I didn't want to force any custom writers to have this feature as wellDateTimeImmutableformats, but theintvalues mentioned in the issue work, defaulting to N days - again, let me know if this is unnecessary.Here's a small example for the following logger config:
And the following existing log files:
For logs written during 2025.10.10 the flow is as follows:
Using
error_writerto write will not trigger any deletion aslog_lifetimeis null (can be omitted completely).Using
custom_writerwill only delete2025-06-10.logbecause the set value will be converted to "30 days ago", so2025-10-09is too new. All other log format untouched.Using
second_custom_writerwill delete2025-10-09_custom_log.logonly (presuming 12 hours have indeed passed).