Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81447
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ganesh1pal@gmail.com> |
| 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; 'argument': 0.05; 'startup': 0.05; 'subject:Python': 0.06; '21,': 0.07; 'redirected': 0.07; 'referring': 0.07; 'strict': 0.07; 'subject:()': 0.09; 'wrapper': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'suggest': 0.14; '2.7': 0.14; 'chris,': 0.16; 'effect,': 0.16; 'handlers': 0.16; 'invokes': 0.16; 'itself).': 0.16; 'stderr': 0.16; 'stdout': 0.16; 'subject:Logging': 0.16; 'wrote:': 0.18; 'module': 0.19; 'input': 0.22; 'example': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'certainly': 0.24; 'stick': 0.24; 'file.': 0.24; '(or': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'logging': 0.26; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; '(which': 0.31; 'comments': 0.31; 'routine': 0.31; 'url:python': 0.33; 'fri,': 0.33; 'level.': 0.33; "can't": 0.35; 'except': 0.35; 'possible.': 0.35; 'something': 0.35; '(2)': 0.35; 'no,': 0.35; 'requirement': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; 'similar': 0.36; 'url:org': 0.36; 'changing': 0.37; 'nov': 0.38; 'planning': 0.38; 'pm,': 0.38; 'that,': 0.38; 'does': 0.39; 'url:mail': 0.40; 'how': 0.40; 'ensure': 0.60; 'catch': 0.60; 'logged': 0.60; "you're": 0.61; 'guarantee': 0.63; 'provide': 0.64; 'great': 0.65; 'to:addr:gmail.com': 0.65; '"one': 0.84; 'shadow': 0.84; 'messages:': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=hOqWFX0CPbuGsZUhn+iT/v99cptC7DdXg7P+eKfyXb4=; b=QSLgdCBVvr5pN7hNRAf7OmJqL6bmyN6qjLO+VEQ4zlC2hDhw5VC5rDiqB1i0iUh8QG sl3WZaxViHODeVnMO8gb3fdBadlrcaigTOn1z4Vey9pGUELc6mbjAJusE6YLyZokudxN 2duQdoTo4zP02aoqFGodTgd0vaLOUbjZkmDw7M3PlFIS3O2QJAJx8d5olzEvypUMfaYn kSmvx8ioZZvFspAJSx/NNBaTOCqJ2zPUhN4waHqMqFlAeI6BeiZySllsn9Q934BdE2/j I9UeJ5n2Qq/r08EB1o6bz16TznasfC5mdniq9imoTSP2R6ptD2Uzk1HgGMzMzA8b3akX HPVA== |
| MIME-Version | 1.0 |
| X-Received | by 10.112.172.97 with SMTP id bb1mr19087237lbc.38.1416819919853; Mon, 24 Nov 2014 01:05:19 -0800 (PST) |
| In-Reply-To | <CAPTjJmrZcFxoQuHGCEbeR=b9iPbAuP8TLBg-sO4Sdb6uKXQdEA@mail.gmail.com> |
| References | <CACT3xuV7c0jQ_yj_+BU28t3B_tcr9mTAtNefiiBcAe1dPQmnbQ@mail.gmail.com> <CAPTjJmrZcFxoQuHGCEbeR=b9iPbAuP8TLBg-sO4Sdb6uKXQdEA@mail.gmail.com> |
| Date | Mon, 24 Nov 2014 14:35:19 +0530 |
| Subject | Re: Python Logging and printf() |
| From | Ganesh Pal <ganesh1pal@gmail.com> |
| To | Chris Angelico <rosuav@gmail.com> |
| Content-Type | multipart/alternative; boundary=001a11c33e90089d7305089718f4 |
| Cc | "python-list@python.org" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16241.1416819927.18130.python-list@python.org> (permalink) |
| Lines | 97 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1416819927 news.xs4all.nl 2909 [2001:888:2000:d::a6]:53319 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:81447 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Hi Chris, Thanks for the comments , Iam planning to use logging handlers ( StreamHandler and FileHandler) to achieve my requirement . Any quick reference example to this will be great , Iam on Python 2.7 , Iam referring the python docs for mow. Regards, Ganesh On Fri, Nov 21, 2014 at 5:25 PM, Chris Angelico <rosuav@gmail.com> wrote: > On Fri, Nov 21, 2014 at 9:48 PM, Ganesh Pal <ganesh1pal@gmail.com> wrote: > > Please provide your input on the below questions. > > > > (1). How do i guarantee that all console messages will be logged into > the > > logfile ? > > (2) I feel the need to retain few print(), how do I ensure the print() > > messages are also logged into the log file. > > If you're using Python 3, you can shadow print() with your own > function. The logging functions don't have the same signature, so > you'd need to write a wrapper (or else stick to a strict policy of > "one argument to print() and it must be a string"), but it's certainly > possible. > > But part of the point of the logging module is that it's not the same > as console messages: you can reduce log spam by changing the logging > level. So no, you don't have a guarantee that all console messages > will be logged to the log file. If you want that, I would suggest a > process-level wrapper - something which invokes a subprocess with > redirected stdout and/or stderr - or, at very least, a startup routine > that does the redirection (which will have similar effect, except that > it can't catch startup failure messages from Python itself). > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list >
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Python Logging and printf() Ganesh Pal <ganesh1pal@gmail.com> - 2014-11-24 14:35 +0530
csiph-web