turnstiles

Crates.ioturnstiles
lib.rsturnstiles
version0.4.2
sourcesrc
created_at2021-12-22 05:44:59.849635
updated_at2024-08-20 05:49:13.358121
descriptionSeamless file rotation
homepagehttps://github.com/Zylatis/turnstiles
repositoryhttps://github.com/Zylatis/turnstiles
max_upload_size
id501498
size39,200
(Zylatis)

documentation

README

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.

Commit count: 116

cargo fmt