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

tracing-appender: Custom rotation duration #778

Open
Karrq opened this issue Jul 6, 2020 · 3 comments · May be fixed by #2654 or #3135
Open

tracing-appender: Custom rotation duration #778

Karrq opened this issue Jul 6, 2020 · 3 comments · May be fixed by #2654 or #3135
Labels
crate/appender Related to the `tracing-appender` crate. kind/feature New feature or request

Comments

@Karrq
Copy link

Karrq commented Jul 6, 2020

Feature Request

Crates

tracing-appender

Motivation

Allow custom rotation timings for logs. Right now only 3 types are available: hourly, daily and never. This is far too coarse to provide efficient logging. My particular use case, is a "watcher" application that monitors something every X ms (configured at the start), it would be incredibly nice if I could specify X ms (for example) per rotation, effectively making each log be one run of the "watch"

Proposal

Add another enum constructor with a std::time::Duration and do calculations based on that instead of fixed timesteps.
(chrono's DateTime<Tz> implements Add<Duration> for DateTime<Tz>, thererfore it's pretty direct.

This right now it's only associated const items that resolve to a variant of the enum Roation.

round_date needs to be changed to account for this, one way could be assuming the custom duration to be a divisor of the unrounded_date, and thus discarding the remainder, calculations should be done using nanoseconds for as much precision as possible.

join_date is a tricky one, I don't know how to approach the implementation of this.

Alternatives

There are many ways to go to implement this, the one in the proposal is how I'd do.

@hawkw hawkw added crate/appender Related to the `tracing-appender` crate. kind/feature New feature or request labels Jul 6, 2020
@hawkw
Copy link
Member

hawkw commented Jul 6, 2020

cc @zekisherif

@zekisherif
Copy link
Contributor

@Karrq Sorry about the delay (busy week).

I agree that custom rotations is sorely needed. If you haven't already started on the implementation, I think I'll be able to starting Wednesday

@JRAndreassen
Copy link

Hi...

I would like to see this change as well...
I had the same thought about making the Duration the a parameter...
Thanks
JR

@stegaBOB stegaBOB linked a pull request Jul 16, 2023 that will close this issue
2 tasks
@gibbz00 gibbz00 linked a pull request Nov 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/appender Related to the `tracing-appender` crate. kind/feature New feature or request
Projects
None yet
4 participants