Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file logging log rotation #98216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pafuent
Copy link
Contributor

@pafuent pafuent commented Oct 16, 2024

Fixes #97066

RBSet were used on RotatedFileLogger because it guarantees that iterating it is done via operator<. This is important because RotatedFileLogger depends on this behavior to delete the oldest log file.
On #61194 HashSet was added and all RBSet uses were replaced by HashSet.
When that happened, the iteration in order is guaranteed to be the insertion order, wich made that RotatedFileLogger delete the newest log file. As a bonus, I added unit test for RotatedFileLogger and CompositeLogger.

@pafuent pafuent requested review from a team as code owners October 16, 2024 03:29
@AThousandShips AThousandShips added bug topic:core cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release labels Oct 16, 2024
@AThousandShips AThousandShips added this to the 4.4 milestone Oct 16, 2024
@AThousandShips AThousandShips changed the title Fix file loggin log rotation Fix file logging log rotation Oct 16, 2024
@pafuent pafuent force-pushed the fixing_log_rotation branch from bd18983 to 5013221 Compare October 17, 2024 13:36
@pafuent pafuent force-pushed the fixing_log_rotation branch from 5013221 to a94209d Compare November 13, 2024 02:40
@pafuent
Copy link
Contributor Author

pafuent commented Nov 13, 2024

Friendly remainder

@pafuent pafuent force-pushed the fixing_log_rotation branch from a94209d to 25ac8bc Compare November 13, 2024 02:43

namespace TestLogger {

const int sleep_duration = 1200000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const int sleep_duration = 1200000;
constexpr int sleep_duration = 1200000;

Also, can we use a shorter sleep duration? This is 1.2 seconds, which can impact test runtimes significantly since we test 6 rotations in total (8 seconds).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know 1.2 seconds is a lot, but the timestamp format that is added to the log files when are rotated is vformat("%sT%02d:%02d:%02d", timestamp, dt.hour, dt.minute, dt.second); which is up to seconds. So in order to get a new file name more than a second must pass between file rotations.

@pafuent pafuent force-pushed the fixing_log_rotation branch from 25ac8bc to 241a920 Compare November 20, 2024 02:57
Fixes godotengine#97066

`RBSet` were used on `RotatedFileLogger` because it guarantees that
iterating it is done via `operator<`. This is important because
`RotatedFileLogger` depends on this behavior to delete the oldest log file.
On godotengine#61194 `HashSet` was added and all `RBSet` uses were replaced by
`HashSet`.
When that happened, the iteration in order is guaranteed to be the insertion
order, wich made that `RotatedFileLogger` delete the newest log file.
As a bonus, I added unit test for `RotatedFileLogger` and `CompositeLogger`.
@pafuent pafuent force-pushed the fixing_log_rotation branch from 241a920 to be2caf1 Compare November 29, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release topic:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File logging log rotation is broken.
3 participants