8 releases
0.4.2 | Aug 20, 2024 |
---|---|
0.4.1 | Aug 17, 2022 |
0.2.1 | Dec 23, 2021 |
0.1.3 | Dec 22, 2021 |
#175 in Debugging
327 downloads per month
23KB
261 lines
Turnstiles
A WIP library which wraps the io::Write
trait to enable file rotation i.e. for logs. The goal is to enable file rotation at the file handle level and do so with as few dependencies as possible.
Implemented/planned rotation conditions:
- None (never rotate)
- SizeMB (file size)
- Duration (time since last modified)
- SizeLines (number of lines in file)
There are also three options to prune old logs:
- None
- MaxFiles
- MaxAge
Warning:
This is currently in active development and may change/break often. Every effort will be taken to ensure that breaking changes that occur are reflected in a change of at least the minor version of the package, both in terms of the API and the generation of log files. Versions prior to 0.2.0 were so riddled with bugs I'm amazed I managed to put my pants on on those days I was writing it.
Documentation
See docs here for notes on how it works, example usage, and error handling.
Future work
- Refresh internal index when rotation requested, not just at logger creation
- Be more careful around edgecases for example rotating on 1mb files and writing exactly 1mb to disk
- More direct integration with dedicated logging libraries, i.e.
impl log::Log
. - Investigate integration with things like
atomicwrites
- More flexible rotation options
Why turnstiles
?
It's a metal thing that rotates, and also the name of the Billy Joel album which has Summer, Highland Falls
on it, one of my favourite songs.
Dependencies
~2.2–3.5MB
~56K SLoC