Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28063
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rikardhulten@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'failing': 0.05; 'method,': 0.07; 'msg': 0.07; 'subject:file': 0.07; 'lawrence': 0.09; 'that).': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python- list': 0.10; 'emit': 0.16; 'linux)': 0.16; 'needed?': 0.16; 'subclassing': 0.16; 'wording': 0.16; 'wrote:': 0.17; 'basically': 0.17; 'url:dev': 0.17; 'windows': 0.19; 'module': 0.19; '(not': 0.20; 'meant': 0.21; 'not,': 0.21; '(on': 0.22; 'wednesday,': 0.22; "i'd": 0.22; 'cc:2**0': 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'idea': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; '[1]': 0.27; 'logging': 0.27; 'correct': 0.28; 'went': 0.28; 'implies': 0.29; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; 'running': 0.32; 'event.': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'wrong': 0.34; 'ahead': 0.35; 'process,': 0.35; 'open': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'next': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'should': 0.36; 'possible': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'url:docs': 0.38; 'delete': 0.38; 'little': 0.39; 'where': 0.40; 'your': 0.60; 'from:no real name:2**0': 0.60; 'close': 0.63; 'august': 0.66; 'subject:get': 0.81; '(your': 0.84; 'running,': 0.84; 'scratch,': 0.84; 'subject:skip:l 10': 0.84; 'windows)': 0.84 |
| Newsgroups | comp.lang.python |
| Date | Wed, 29 Aug 2012 05:57:11 -0700 (PDT) |
| In-Reply-To | <mailman.3931.1346244515.4697.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=80.252.171.140; posting-account=TI1DrAoAAACvFn7UBxQHUag5wutG1VRO |
| References | <3570ffff-749a-44c4-ab9e-10c37d9526e8@googlegroups.com> <mailman.3931.1346244515.4697.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-IP | 80.252.171.140 |
| MIME-Version | 1.0 |
| Subject | Re: Can I get logging.FileHandler to close the file on each emit? |
| From | rikardhulten@gmail.com |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| 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> |
| Message-ID | <mailman.3933.1346245034.4697.python-list@python.org> (permalink) |
| Lines | 55 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1346245034 news.xs4all.nl 6903 [2001:888:2000:d::a6]:36978 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:28063 |
Show key headers only | View raw
On Wednesday, August 29, 2012 2:48:57 PM UTC+2, Mark Lawrence wrote: > On 29/08/2012 11:18, wrote: > > > I use logging.FileHandler (on windows) and I would like to be able to delete the file while the process is running and have it create the file again on next log event. > > > > > > On windows (not tried linux) this is not possible because the file is locked by the process, can I get it to close the file after each log event? > > > > > > If not, would the correct thing to do be to write my own LogHandler with this behavior? > > > > > > / Rikard > > > > > > > I know little about the logging module but given that the FileHandler[1] > > has a close method, can you simply call that, delete the file and reopen > > where needed? Failing that I'd look at subclassing existing code and > > not writing your own (Your wording implies to me that you're thinking of > > writing something from scratch, my apologies should I be wrong on that). > > > > [1] http://docs.python.org/dev/library/logging.handlers.html > > > > -- > > Cheers. > > > > Mark Lawrence. I want to delete the file from outside the process while it is running, so in the code I have no idea when that is... I meant subclassing logging.Handler, which I went ahead and tried and it seems to work as I like. Basically in emit I do 1. open log file 2. write msg to it 3. close file / Rikard
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Can I get logging.FileHandler to close the file on each emit? rikardhulten@gmail.com - 2012-08-29 03:18 -0700
Re: Can I get logging.FileHandler to close the file on each emit? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-29 13:49 +0100
Re: Can I get logging.FileHandler to close the file on each emit? rikardhulten@gmail.com - 2012-08-29 05:57 -0700
Re: Can I get logging.FileHandler to close the file on each emit? Dieter Maurer <dieter@handshake.de> - 2012-08-30 09:24 +0200
csiph-web