cpython: eead4be1bdd9 (original) (raw)

Mercurial > cpython

changeset 83271:eead4be1bdd9

Closed #9556: Allowed specifying a time-of-day for a TimedRotatingFileHandler to rotate. [#9556]

Vinay Sajip <vinay_sajip@yahoo.co.uk>
date Fri, 12 Apr 2013 17:04:23 +0100
parents 95eed7a76c72
children 5118304a4c9c
files Doc/library/logging.handlers.rst Lib/logging/handlers.py Lib/test/test_logging.py Misc/NEWS
diffstat 4 files changed, 73 insertions(+), 8 deletions(-)[+] [-] Doc/library/logging.handlers.rst 8 Lib/logging/handlers.py 28 Lib/test/test_logging.py 42 Misc/NEWS 3

line wrap: on

line diff

--- a/Doc/library/logging.handlers.rst +++ b/Doc/library/logging.handlers.rst @@ -296,7 +296,7 @@ The :class:TimedRotatingFileHandler cl timed intervals. -.. class:: TimedRotatingFileHandler(filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False) +.. class:: TimedRotatingFileHandler(filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False, atTime=None) Returns a new instance of the :class:TimedRotatingFileHandler class. The specified file is opened and used as the stream for logging. On rotating it also @@ -346,6 +346,12 @@ timed intervals. If delay is true, then file opening is deferred until the first call to :meth:emit.

.. method:: doRollover()

--- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -1,4 +1,4 @@ -# Copyright 2001-2012 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2013 by Vinay Sajip. All Rights Reserved. #

Permission to use, copy, modify, and distribute this software and its

documentation for any purpose and without fee is hereby granted,

@@ -18,7 +18,7 @@ Additional handlers for the logging package for Python. The core package is based on PEP 282 and comments thereto in comp.lang.python. -Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved. To use, simply 'import logging.handlers' and log away """ @@ -196,11 +196,12 @@ class TimedRotatingFileHandler(BaseRotat If backupCount is > 0, when rollover is done, no more than backupCount files are kept - the oldest ones are deleted. """

@@ -270,9 +271,22 @@ class TimedRotatingFileHandler(BaseRotat currentHour = t[3] currentMinute = t[4] currentSecond = t[5]

+

@@ -290,7 +304,7 @@ class TimedRotatingFileHandler(BaseRotat # This is because the above time calculation takes us to midnight on this # day, i.e. the start of the next day. if self.when.startswith('W'):

--- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -3949,6 +3949,48 @@ class TimedRotatingFileHandlerTest(BaseF assertRaises(ValueError, logging.handlers.TimedRotatingFileHandler, self.fn, 'W7', delay=True)

+

+

+

+

+

+

+

+ + def secs(**kw): return datetime.timedelta(**kw) // datetime.timedelta(seconds=1)

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -34,6 +34,9 @@ Core and Builtins Library ------- +- Issue #9556: Allowed specifying a time-of-day for a TimedRotatingFileHandler