summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-12-14 01:17:56 (GMT)
committerGitHub <noreply@github.com>2021-12-14 01:17:56 (GMT)
commitf84e2f6c0aca97c59ec8ce21715ae9bd89893307 (patch)
tree80bad977c20a878c8d88b8c2d7255f2cef9fd6b1 /Doc/library
parentbcb5d66b8f9a35e7de8e285b980bb81ebbfdd400 (diff)
downloadcpython-f84e2f6c0aca97c59ec8ce21715ae9bd89893307.zip
cpython-f84e2f6c0aca97c59ec8ce21715ae9bd89893307.tar.gz
cpython-f84e2f6c0aca97c59ec8ce21715ae9bd89893307.tar.bz2
[3.10] bpo-46063: Improve algorithm for computing which rolled-over log fileā€¦ (GH-30093) (GH-30094)
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/logging.handlers.rst17
1 files changed, 17 insertions, 0 deletions
diff --git a/Doc/library/logging.handlers.rst b/Doc/library/logging.handlers.rst
index 73c542b..a664efd 100644
--- a/Doc/library/logging.handlers.rst
+++ b/Doc/library/logging.handlers.rst
@@ -231,6 +231,19 @@ need to override.
return the same output every time for a given input, otherwise the
rollover behaviour may not work as expected.
+ It's also worth noting that care should be taken when using a namer to
+ preserve certain attributes in the filename which are used during rotation.
+ For example, :class:`RotatingFileHandler` expects to have a set of log files
+ whose names contain successive integers, so that rotation works as expected,
+ and :class:`TimedRotatingFileHandler` deletes old log files (based on the
+ ``backupCount`` parameter passed to the handler's initializer) by determining
+ the oldest files to delete. For this to happen, the filenames should be
+ sortable using the date/time portion of the filename, and a namer needs to
+ respect this. (If a namer is wanted that doesn't respect this scheme, it will
+ need to be used in a subclass of :class:`TimedRotatingFileHandler` which
+ overrides the :meth:`~TimedRotatingFileHandler.getFilesToDelete` method to
+ fit in with the custom naming scheme.)
+
.. versionadded:: 3.3
@@ -440,6 +453,10 @@ timed intervals.
Outputs the record to the file, catering for rollover as described above.
+ .. method:: getFilesToDelete()
+
+ Returns a list of filenames which should be deleted as part of rollover. These
+ are the absolute paths of the oldest backup log files written by the handler.
.. _socket-handler: