Open Karrq opened 4 years ago
cc @zekisherif
@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
Hi...
I would like to see this change as well... I had the same thought about making the Duration the a parameter... Thanks JR
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'sDateTime<Tz>
implementsAdd<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 theunrounded_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.