Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31975

Re: Getting a TimedRotatingFileHandler not to put two dates in the same file?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'much!': 0.05; 'arguments': 0.07; 'class,': 0.07; 'filenames': 0.07; 'subject:file': 0.07; 'subject:two': 0.07; 'used.': 0.07; 'splitting': 0.09; 'subject:Getting': 0.09; 'subject:same': 0.09; 'cc:addr:python- list': 0.10; 'subject:not': 0.11; 'received:192.168.11': 0.16; 'subclassing': 0.16; 'subject: \n ': 0.16; 'subject:dates': 0.16; 'wrote:': 0.17; 'fix': 0.17; '(or': 0.18; 'file.': 0.20; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'guess': 0.27; 'lines': 0.28; 'noticed': 0.28; 'dates': 0.33; 'changed': 0.34; 'so,': 0.35; 'subject:?': 0.35; 'there': 0.35; 'but': 0.36; 'itself': 0.37; 'two': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'end': 0.40; 'close': 0.63; 'information': 0.63; 'date,': 0.65; 'potentially': 0.66; 'header :Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84
Date Tue, 23 Oct 2012 19:46:57 -0400
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1
MIME-Version 1.0
To David M Chess <chess@us.ibm.com>
Subject Re: Getting a TimedRotatingFileHandler not to put two dates in the same file?
References <OFF42E9E1E.D755EB22-ON85257AA0.00534D0A-85257AA0.005487C9@us.ibm.com>
In-Reply-To <OFF42E9E1E.D755EB22-ON85257AA0.00534D0A-85257AA0.005487C9@us.ibm.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:4hWX1ntmxDZRbzXR0C/4HaShALT5wLfbJc/Hn2tlj3f XB7R0bG8diI9vl4RXg+e9dmkNbrRcpZOhfyCGQxBfxr7SILW1G H6Ku9MCwaCp1Dv+gBtHRTJgSORh5dgoHjNkUZcGN8c2krkBDgH xHHW+khoOG/SgwjhMSXqtwOzZUhphcA9E2hdJWIcsJX1oXz/Mm p7OIA1DiQPrJYfkF1pfYAV20XfZ6R5Ap8O/Ua1HBjsTQIJCh5F R07uo/QSOBphLxSvKbyGOdc0e8KKzfeXI9cK47Cz/f0bHk2CE9 +SgLeVloVvKmQBXM5ZRgK6mowOin76MuADO37beNA/CZuWA2PU 1RZPybZInyJSf4hn+YvU=
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To d@davea.name
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2703.1351036027.27098.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351036027 news.xs4all.nl 6847 [2001:888:2000:d::a6]:37712
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31975

Show key headers only | View raw


On 10/23/2012 11:23 AM, David M Chess wrote:
> We have a TimedRotatingFileHandler with when='midnight'

You give us no clue what's in this class, or how it comes up with the
filenames used.

> . 
>
> This works great, splitting the log information across files by date, as 
> long as the process is actually up at midnight.
>
> But now the users have noticed that if the process isn't up at midnight, 
> they can end up with lines from two (or I guess potentially more) dates in 
> the same log file.
>
> Is there some way to fix this, either with cleverer arguments into the 
> TimedRotatingFileHandler, or by some plausible subclassing of it or its 
> superclass?

Why not use the date itself to derive the filename?  And check whether
the date has changed since the last update, and if so, close and
reopen.  Midnight is irrelevant.

> Or am I misinterpreting the symptoms somehow?
>
> Tx much!
> DC
>
>

-- 

DaveA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Getting a TimedRotatingFileHandler not to put two dates in the same file? Dave Angel <d@davea.name> - 2012-10-23 19:46 -0400

csiph-web