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

Optionally format log file path with time in time point file rotator #78

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

Conversation

fpervaiz
Copy link
Contributor

@fpervaiz fpervaiz commented Dec 5, 2024

Aim is to allow custom file names and paths on time point rotation, rather than the default behaviour of appending the date/time to the file name given in the base path.

Copy link
Owner

@SpriteOvO SpriteOvO left a comment

Choose a reason for hiding this comment

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

Sorry for the very late review.

Customizing rotated file names is a meaningful feature, and it would certainly be nice if we have it, but I think this implementation is a bit misleading.

The chrono crate is under the hood and not visible to users. Besides that, RotatingFileSink also has time-irrelevant rotation policies. So exposing the chrono's time format directly to the path string parameter is not a good idea I think.

A possible better implementation is from C++ spdlog https://github.com/gabime/spdlog/blob/7cbf2a696764f3c2c84ff4b8eb592fce5924919e/include/spdlog/sinks/daily_file_sink.h#L68 - we have a somehow callback parameter, passing policy-related information into it, and the user returns the custom file path they expected. The right path might be this, but I haven't have time to figure out the details of the API designs recently (a bit busy sorry). I'll probably reply later with more details or you can feel free to explore it yourself then we discuss :)

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.

2 participants