sile / sloggers

A Rust library which provides frequently used slog loggers and convenient functions
MIT License
37 stars 18 forks source link

Add basic log file rotation functionality #14

Closed sile closed 6 years ago

sile commented 6 years ago

Add rotate_size and rotate_keep options to FileLoggerBuilder and FileLoggerConfig for supporting basic log file rotation.

Related Issue: https://github.com/sile/sloggers/issues/12

codecov-io commented 6 years ago

Codecov Report

Merging #14 into master will increase coverage by 38.57%. The diff coverage is 78.64%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #14       +/-   ##
===========================================
+ Coverage    3.99%   42.56%   +38.57%     
===========================================
  Files           9        9               
  Lines         401      585      +184     
===========================================
+ Hits           16      249      +233     
+ Misses        385      336       -49
Impacted Files Coverage Δ
src/lib.rs 100% <ø> (ø) :arrow_up:
src/error.rs 0% <0%> (ø) :arrow_up:
src/file.rs 64.53% <79.05%> (+55.15%) :arrow_up:
src/types.rs 33.33% <0%> (+33.33%) :arrow_up:
src/misc.rs 43.75% <0%> (+43.75%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update fd02146...e51fc25. Read the comment docs.

przygienda commented 6 years ago

Looked over, cool. Are you willing to add compression on rotation as option (i.e. the old file is moved to a new name and compressed into .gz?) interesting question being how the compression should be forked? thread? then we'll have lifetime issues I think. spawning a process? tad heavy ... Some kind of worker queue?

sile commented 6 years ago

Are you willing to add compression on rotation as option ...

I would like to keep this PR simple, but I will consider it a bit.

przygienda commented 6 years ago

cool, willing to help if you attack that ... think through design first & whether you want to go there ...

slog is a professional quality logger and that take it a notch higher up again IMO ... Alternately, we could implement a log-rotating-copressing drain and take the whole thing out of sloggers if you prefer and let sloggers use that just like it uses KVFilter now ...

On Wed, Aug 29, 2018 at 5:34 AM Takeru Ohta notifications@github.com wrote:

Are you willing to add compression on rotation as option ...

I would like to keep this PR simple, but I will consider it a bit.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sile/sloggers/pull/14#issuecomment-416936066, or mute the thread https://github.com/notifications/unsubscribe-auth/ABo0CxRZ8ahha09LnUpua4r7YSBz_14pks5uVopJgaJpZM4WOB7s .

sile commented 6 years ago

Thank you for your comments. > @przygienda

I prefer to use threads for compressing log files. And I added rotated log file compression option at https://github.com/sile/sloggers/pull/14/commits/049b6cf3ffcf6ac6ed53d8ab3332c9c665045cf1.

Alternately, we could implement a log-rotating-copressing drain and take the whole thing out of sloggers if you prefer and let sloggers use that just like it uses KVFilter now ...

If you want a more advanced implementation (or options) than https://github.com/sile/sloggers/pull/14/commits/049b6cf3ffcf6ac6ed53d8ab3332c9c665045cf1, it seems better to implement this feature on another crate like slog-kvfilter.

przygienda commented 6 years ago

so, that's getting pulled up? looks good and useful to me ...

sile commented 6 years ago

looks good and useful to me

I see. I will merge this PR after conflicts are resolved.