logging.handlers.BaseRotatingHandler

class logging.handlers.BaseRotatingHandler(filename, mode, encoding=None, delay=False)

The parameters are as for FileHandler. The attributes are:

namer

If this attribute is set to a callable, the rotation_filename() method delegates to this callable. The parameters passed to the callable are those passed to rotation_filename().

Note

The namer function is called quite a few times during rollover, so it should be as simple and as fast as possible. It should also return the same output every time for a given input, otherwise the rollover behaviour may not work as expected.

New in version 3.3.

rotator

If this attribute is set to a callable, the rotate() method delegates to this callable. The parameters passed to the callable are those passed to rotate().

New in version 3.3.

rotation_filename(default_name)

Modify the filename of a log file when rotating.

This is provided so that a custom filename can be provided.

The default implementation calls the ‘namer’ attribute of the handler, if it’s callable, passing the default name to it. If the attribute isn’t callable (the default is None), the name is returned unchanged.

Parameters: default_name – The default name for the log file.

New in version 3.3.

rotate(source, dest)

When rotating, rotate the current log.

The default implementation calls the ‘rotator’ attribute of the handler, if it’s callable, passing the source and dest arguments to it. If the attribute isn’t callable (the default is None), the source is simply renamed to the destination.

Parameters:
  • source – The source filename. This is normally the base filename, e.g. ‘test.log’.
  • dest – The destination filename. This is normally what the source is rotated to, e.g. ‘test.log.1’.

New in version 3.3.

doc_python
2016-10-07 17:36:07
Comments
Leave a Comment

Please login to continue.