Handlers

Inheritance diagram of musify.log.handlers

All logging handlers specific to this package.

Classes:

CurrentTimeRotatingFileHandler([filename, ...])

Handles log file and directory rotation based on log file/folder name.

class musify.log.handlers.CurrentTimeRotatingFileHandler(filename=None, encoding=None, when=None, interval=None, count=None, delay=False, errors=None)

Bases: BaseRotatingHandler

Handles log file and directory rotation based on log file/folder name.

Parameters:
  • filename (str | None (default: None)) – The full path to the log file. Optionally, include a ‘{}’ part in the path to format in the current datetime. When None, defaults to ‘{}.log’

  • encoding (str | None (default: None)) – When not None, it is used to open the file with that encoding.

  • when (str | None (default: None)) – The timespan for ‘interval’ which is used together to calculate the timedelta. Accepts same values as TimeMapper.

  • interval (int | None (default: None)) – The multiplier for when. When combined with when, gives the negative timedelta relative to now which is the maximum datetime to keep logs for.

  • count (int | None (default: None)) – The maximum number of files to keep.

  • delay (bool (default: False)) – When True, the file opening is deferred until the first call to emit().

  • errors (str | None (default: None)) – Used to determine how encoding errors are handled.

Attributes:

dt

filename

delta

count

removed

Methods:

shouldRollover(*_, **__)

Always returns False.

rotator(unformatted, formatted)

Rotates the files in the folder on the given unformatted path.

dt
filename
delta
count
removed: list[datetime]
static shouldRollover(*_, **__)

Always returns False. Rotation happens on __init__ and only needs to happen once.

Return type:

bool

rotator(unformatted, formatted)

Rotates the files in the folder on the given unformatted path. Removes files older than self.delta and the oldest files when number of files >= count until number of files <= count. formatted path is excluded from processing.