summaryrefslogtreecommitdiffstats
path: root/Doc/library/logging.handlers.rst
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2021-12-14 00:53:37 (GMT)
committerGitHub <noreply@github.com>2021-12-14 00:53:37 (GMT)
commitcb589d1b6bad4b75852c2e2a471a3800d5efdca7 (patch)
tree8f740a9418027df57d63bdb1ee510afa8ec1d148 /Doc/library/logging.handlers.rst
parenteb483c46d62707bdf705491f76cf1fa9642fb47e (diff)
downloadcpython-cb589d1b6bad4b75852c2e2a471a3800d5efdca7.zip
cpython-cb589d1b6bad4b75852c2e2a471a3800d5efdca7.tar.gz
cpython-cb589d1b6bad4b75852c2e2a471a3800d5efdca7.tar.bz2
bpo-46063: Improve algorithm for computing which rolled-over log fileā€¦ (GH-30093)
Diffstat (limited to 'Doc/library/logging.handlers.rst')
-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 5625690..f5ef80e 100644
--- a/Doc/library/logging.handlers.rst
+++ b/Doc/library/logging.handlers.rst
@@ -234,6 +234,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
@@ -443,6 +456,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: