caproto.server.autosave.RotatingFileManager

Inheritance diagram of RotatingFileManager
class caproto.server.autosave.RotatingFileManager(filename, *, max_files_per_day=5, max_file_age=30, date_suffix='_%Y%m%d-%H%M%S', logger=<Logger caproto.server.autosave (WARNING)>)[source]

Save to a primary filename, while rotating out old copies.

Automatically prunes old copies of the file beyond a certain age or a maximum file count (overall or per day).

Files will first be pruned by the overall age cutoff, then on a per day basis.

Parameters:
filenamestr

The primary filename that should be used.

max_files_per_dayint, optional

Remove the oldest files in a given day.

max_file_ageint, optional

Prune files beyond this cutoff.

date_suffixstr, optional

Defaults to “_%Y%m%d-%H%M%S” - used by strftime/strptime.

loggerlogging.Logger, optional

The logger instance to use for messages. Defaults to the module logger.

Methods

prune_files()

Prune files that are outside of the configured maximum times.

rotate_in_file(fn)

Move a valid file from another location to self.filename and prune.

Attributes

directory

The directory holding the save file.

files_by_age

Get a dictionary of {age_timedelta: filename}.

glob_string

The glob string which can be used to find matching files.

date_suffix

filename

log

max_file_age

max_files_per_day