Re: Create Logging module

2019-08-01 Thread Sinardy Xing
Sorry for spamming this is suppose send to tutor-ow...@python.org On Thu, Aug 1, 2019 at 5:08 PM Sinardy Xing wrote: > Hi, > > I am learning to create python logging. > > My goal is to create a logging module where I can use as decorator in my > main app > > follo

Create Logging module

2019-08-01 Thread Sinardy Xing
Hi, I am learning to create python logging. My goal is to create a logging module where I can use as decorator in my main app following is the logging code start here--- import logging #DEBUG: Detailed information, typically of interest only when diagnosing problems. #INFO

Re: Logging module and datetime - oil & water for some reason?

2019-04-02 Thread DL Neil
Skip, On 2/04/19 9:54 AM, Skip Montanaro wrote: I assiduously avoided using Python's logging package for about the first dozen years of its existence. I eventually gave in and started I'm glad you're stepping-up! I'm never sure whether to be amazed or dismayed by the huge number of folk exp

Logging module and datetime - oil & water for some reason?

2019-04-01 Thread Skip Montanaro
I assiduously avoided using Python's logging package for about the first dozen years of its existence. I eventually gave in and started using it relatively recently in the guise of a thin wrapper provided by a colleague at work. Today I had occasion to tweak the timestamp format only to discover th

Re: Multiple log files using logging module

2019-03-24 Thread Luuk
On 24-3-2019 19:33, Peter Otten wrote: Luuk wrote: On 24-3-2019 18:13, Sharan Basappa wrote: I have a test program that imports a design program. Both the programs need to log messages. I have tried the following: 1) Both the programs have the following lines: for handler in logging.root.han

Re: Multiple log files using logging module

2019-03-24 Thread Peter Otten
Luuk wrote: > On 24-3-2019 18:13, Sharan Basappa wrote: >> I have a test program that imports a design program. >> Both the programs need to log messages. >> >> I have tried the following: >> >> 1) Both the programs have the following lines: >> for handler in logging.root.handlers[:]: >> lo

Re: Multiple log files using logging module

2019-03-24 Thread DL Neil
On 25/03/19 6:13 AM, Sharan Basappa wrote: I have a test program that imports a design program. Both the programs need to log messages. ...> I would like to get comment from members here as well as some simple programs to illustrate this ... Have you copied this code from somewhere? Which tu

Re: Multiple log files using logging module

2019-03-24 Thread Luuk
On 24-3-2019 18:13, Sharan Basappa wrote: I have a test program that imports a design program. Both the programs need to log messages. I have tried the following: 1) Both the programs have the following lines: for handler in logging.root.handlers[:]: logging.root.removeHandler(handler)

Multiple log files using logging module

2019-03-24 Thread Sharan Basappa
I have a test program that imports a design program. Both the programs need to log messages. I have tried the following: 1) Both the programs have the following lines: for handler in logging.root.handlers[:]: logging.root.removeHandler(handler) #Create and configure logger filename = os.

Re: logging module - how to include method's class name when using %(funcName)

2018-09-11 Thread Peter Otten
Malcolm Greene wrote: > I'm using the Python logging module and looking for a way to include a > method's class name when using %(funcName). Is this possible? When you > have several related classes, just getting the function (method) name is > not enough information to

Re: logging module - how to include method's class name when using %(funcName)

2018-09-10 Thread dieter
Malcolm Greene writes: > I'm using the Python logging module and looking for a way to include a > method's class name when using %(funcName). Is this possible? If it does not happen automatically, the standard logging components will not let you do it (the name "funcName&quo

logging module - how to include method's class name when using %(funcName)

2018-09-10 Thread Malcolm Greene
I'm using the Python logging module and looking for a way to include a method's class name when using %(funcName). Is this possible? When you have several related classes, just getting the function (method) name is not enough information to provide context on the code being exe

Re: Anyone using cloud based monitoring/logging services with Python logging module?

2018-07-26 Thread Ben Finney
Malcolm Greene writes: > Looking for feedback on anyone who's using a cloud based > monitoring/logging service with Python's standard lib logging module, The free-software Sentry https://sentry.io/> is full-featured, implemented in PYthon, and available to set up on your

Re: Anyone using cloud based monitoring/logging services with Python logging module?

2018-07-26 Thread Michael Vilain
cloud based > monitoring/logging service with Python's standard lib logging module, > eg. services such as Datadog, Loggly, Papertrailapp, Scalyr, LogDNA, > Logz.io, Logentries, Loggr, Logstats? > Would appreciate hearing your experience, pros, cons, > recommendations, etc. > T

Anyone using cloud based monitoring/logging services with Python logging module?

2018-07-26 Thread Malcolm Greene
Looking for feedback on anyone who's using a cloud based monitoring/logging service with Python's standard lib logging module, eg. services such as Datadog, Loggly, Papertrailapp, Scalyr, LogDNA, Logz.io, Logentries, Loggr, Logstats? Would appreciate hearing your experience,

Re: logging module

2018-07-01 Thread dieter
Sharan Basappa writes: > I am trying to use logging module and somehow I cannot make it work. > > A simple code that I am trying is below. The commented code line 5,6 are > other options I have tried but don't work > > #importing module > import logging > &

Re: logging module

2018-07-01 Thread Steven D'Aprano
On Sun, 01 Jul 2018 06:05:48 -0700, Sharan Basappa wrote: > Folks, > > I am trying to use logging module and somehow I cannot make it work. > > A simple code that I am trying is below. The commented code line 5,6 are > other options I have tried but don't work > &g

Re: logging module

2018-07-01 Thread Bev in TX
> On Jul 1, 2018, at 8:05 AM, Sharan Basappa wrote: > > Folks, > > I am trying to use logging module and somehow I cannot make it work. Saying that something does not work does not provide enough information for anyone to assist you. You need to provide both the exact co

logging module

2018-07-01 Thread Sharan Basappa
Folks, I am trying to use logging module and somehow I cannot make it work. A simple code that I am trying is below. The commented code line 5,6 are other options I have tried but don't work #importing module import logging #Create and configure logger #logging.basicConfig(filena

Re: The basics of the logging module mystify me

2018-04-20 Thread Skip Montanaro
> I've no idea what setting log.level does; I would normally use > logging.basicConfig to set that sort of thing. > > logging.basicConfig(level=logging.INFO) The log.level setting is what calling log.setLevel(...) does under the covers. What neither apparently do is have any effect on whatever han

Re: The basics of the logging module mystify me

2018-04-20 Thread Ian Pilcher
On 04/19/2018 04:52 AM, Thomas Jollans wrote: Or, more often than not, it's best to use the logging module's configuration system that creates the right web of handlers and formatters for you. Wow! This is the first I've heard of logging.config (although it's easy to find now that I know that

Re: The basics of the logging module mystify me

2018-04-20 Thread Albert-Jan Roskam
On Apr 19, 2018 03:03, Skip Montanaro wrote: > > > I really don't like the logging module, but it looks like I'm stuck > with it. Why aren't simple/obvious things either simple or obvious? Agreed. One thing that, in my opinion, ought to be added to the docs is s

Re: The basics of the logging module mystify me

2018-04-19 Thread Thomas Jollans
ndler (WARNING)> >>> logging.lastResort.setLevel(logging.INFO) # DON'T DO THIS THOUGH >>> log.info('info 2') info 2 >>> Of course you should rather be creating your own handler >>> handler = logging.StreamHandler() >>> handler.setLev

Re: The basics of the logging module mystify me

2018-04-19 Thread Paul Moore
On 19 April 2018 at 02:00, Skip Montanaro wrote: > I really don't like the logging module, but it looks like I'm stuck > with it. Why aren't simple/obvious things either simple or obvious? If you can use non-stdlib things there are alternatives. I've heard good

Re: The basics of the logging module mystify me

2018-04-18 Thread Chris Angelico
fo("Awk! Goodbye...") >>>> log.isEnabledFor(logging.INFO) > True > > Why do the two log.info(...) calls not produce output on stderr when > the level has clearly been set to logging.INFO? There is an active > stream handler as demonstrated by the successful log.warn(...) c

The basics of the logging module mystify me

2018-04-18 Thread Skip Montanaro
n stderr when the level has clearly been set to logging.INFO? There is an active stream handler as demonstrated by the successful log.warn(...) call. I really don't like the logging module, but it looks like I'm stuck with it. Why aren't simple/obvious things either simple or obvious? Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Logging module stopped working

2017-10-17 Thread llanitedave
ss MainWindow(QMainWindow): > def __init__(self): > super().__init__() > logging.info("Creating window, %s", str(datetime.datetime.today())) > self.createUI() > > logging.info("Class created %s", str(datetime.datetime.today())) >

Re: Logging module stopped working

2017-10-17 Thread llanitedave
Those are some good suggestions, I've found that I won't be able to work on it today, but I'll definitely follow up tomorrow. As for not showing all the code, the main window and its associated code are definitely there and working. I didn't post it because of all the setup code for fields and

Re: Logging module stopped working

2017-10-17 Thread Steve D'Aprano
(datetime.datetime.today())) logging.critical("Can you see this? %s", str(datetime.datetime.today())) # plus whatever else is needed to make the application run ... That will show precisely where and when logging stops: 1. Does it work at all, straight out of the logging module? If not,

Re: Logging module stopped working

2017-10-16 Thread Chris Angelico
On Tue, Oct 17, 2017 at 3:06 PM, llanitedave wrote: > I'm building an application that contains some long-running operations in a > separate thread from the user interface. I've been using the logging module > writing logging.info() statements to a .log file to kee

Logging module stopped working

2017-10-16 Thread llanitedave
I'm building an application that contains some long-running operations in a separate thread from the user interface. I've been using the logging module writing logging.info() statements to a .log file to keep track of the data interactions while it runs. In the midst of a recen

Re: Is there any way to use the logging module adding nothing to a message

2016-06-04 Thread cl
ging.Formatter('%(message)s') > > f.setFormatter(formatter) > > log.addHandler(f) > > > > Will I get just the message with no extras added by the logging module? > > Yuo have the code, and presumably the system on which to test it. What's > the answer? >

Re: Is there any way to use the logging module adding nothing to a message

2016-06-04 Thread Ben Finney
er) > log.addHandler(f) > > Will I get just the message with no extras added by the logging module? Yuo have the code, and presumably the system on which to test it. What's the answer? -- \ “I am too firm in my consciousness of the marvelous to be ever | `\ f

Is there any way to use the logging module adding nothing to a message

2016-06-04 Thread cl
n etc. If I do:- f = logging.handlers.RotatingFileHandler("/home/chris/tmp/mail.log", 'a', 100, 4) f.setLevel(logging.DEBUG) formatter = logging.Formatter('%(message)s') f.setFormatter(formatter) log.addHandler(f) Will I get just the message

Re: Enumerating loggers iin logging module

2015-01-03 Thread John Pote
Thanks for the replies, thought there'd be a simple answer. Much appreciated. John On 30/12/2014 22:40, Chris Angelico wrote: On Wed, Dec 31, 2014 at 8:24 AM, Tim Chase wrote: While it may involve reaching into the objects may or may not be blessed, the following seems to work for me in Py2.7

Re: Enumerating loggers iin logging module

2014-12-30 Thread Chris Angelico
On Wed, Dec 31, 2014 at 8:24 AM, Tim Chase wrote: > While it may involve reaching into the objects may or may not be > blessed, the following seems to work for me in Py2.7: > > >>> import logging > >>> # add a bunch of loggers and sub-loggers > >>> print logging.Logger.manager.loggerDict.key

Re: Enumerating loggers iin logging module

2014-12-30 Thread Tim Chase
On 2014-12-30 18:42, jptechnical.co.uk wrote: > I've recently started using the logging module and wondered if > there was a way to enumerate all the Logger objects available as a > result of calls to "logging.getLogger(name)". Went through the docs > and could not spot

Enumerating loggers iin logging module

2014-12-30 Thread jptechnical.co.uk
Hello all, I've recently started using the logging module and wondered if there was a way to enumerate all the Logger objects available as a result of calls to "logging.getLogger(name)". Went through the docs and could not spot any way of doing this. Have I missed something?

RE: creating log file with Python logging module

2014-08-05 Thread Arulnambi Nandagoban
-Message d'origine- De : Python-list [mailto:python-list-bounces+a.nandagoban=traxens@python.org] De la part de Peter Otten Envoyé : Monday, August 4, 2014 4:03 PM À : python-list@python.org Objet : Re: creating log file with Python logging module Peter Otten wrote: > Pet

Re: creating log file with Python logging module

2014-08-04 Thread Peter Otten
Peter Otten wrote: > Peter Otten wrote: > >> You won't see a rollover if you restart it. > > Sorry, I tried it and the above statement is wrong. [Arulnambi Nandagoban] > logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - > %(message)s', datefmt='%a, %d %b %Y %H:%M:%S', level

Re: creating log file with Python logging module

2014-08-04 Thread Peter Otten
Peter Otten wrote: > You won't see a rollover if you restart it. Sorry, I tried it and the above statement is wrong. -- https://mail.python.org/mailman/listinfo/python-list

Re: creating log file with Python logging module

2014-08-04 Thread Peter Otten
Arulnambi Nandagoban wrote: > I am using logging module for my application to log all debug information. > I configured it create a new log file every day with > > "TimedRotatingFileHandler". I display debug message in console as well. > But I didn't see creatio

creating log file with Python logging module

2014-08-04 Thread Arulnambi Nandagoban
Hello all, I am using logging module for my application to log all debug information. I configured it create a new log file every day with "TimedRotatingFileHandler". I display debug message in console as well. But I didn't see creation of new file. Can someone help me t

Re: Use of logging module to track TODOs

2013-11-27 Thread Mark Lawrence
On 27/11/2013 14:52, Jean-Michel Pichavant wrote: - Original Message - Hey list, Greetings ! How do you do with your TODOs? Regards, Jordi TODOs always share the same fate : they get forgotten and wander the code until the project dies. Unless you have the required mental resil

Re: Use of logging module to track TODOs

2013-11-27 Thread Jean-Michel Pichavant
- Original Message - > Hey list, Greetings ! > How do you do with your TODOs? > > Regards, > Jordi TODOs always share the same fate : they get forgotten and wander the code until the project dies. Unless you have the required mental resilience to stop the urgent work to fix your TO

Use of logging module to track TODOs

2013-11-27 Thread Jordi Riera
lp to trace the TODOs in files. """ import logging import os import sys import json # setting the new level in logging module. # new_level = (logging.DEBUG + 1, 'TODO') logging.addLevelName(*new_level) logging.TODO = new_level[0] class DictFormatter(logging.Formatter): &

Re: Stucked with python logging module

2011-11-15 Thread Kushal Kumaran
On Wed, Nov 16, 2011 at 8:58 AM, sword wrote: > I just scaned through the beginer's guide of logging module, but I > can't get anything from console. The demo just like this: > > import logging > logging.debug("This is a demo") > > Maybe I should do st

Stucked with python logging module

2011-11-15 Thread sword
I just scaned through the beginer's guide of logging module, but I can't get anything from console. The demo just like this: import logging logging.debug("This is a demo") Maybe I should do sth to put the log to stdout in basicConfig first? Thanks in advance -- http://mai

Re: How add class name to format of the logging module?

2011-10-12 Thread Vinay Sajip
On Oct 12, 9:42 pm, Peng Yu wrote: > Hi, > > The following attributes does not include the class name. Is there a > way to add class name to the format string? Thanks! Not in the general case without a reasonable run-time cost. Since you can find the exact line number a logging call was made from

How add class name to format of the logging module?

2011-10-12 Thread Peng Yu
Hi, The following attributes does not include the class name. Is there a way to add class name to the format string? Thanks! http://docs.python.org/library/logging.html#logrecord-attributes -- Regards, Peng -- http://mail.python.org/mailman/listinfo/python-list

Re: logging module usage

2011-04-07 Thread mennis
Thank you. This has been very helpful. Ian -- http://mail.python.org/mailman/listinfo/python-list

Re: logging module usage

2011-03-31 Thread Vinay Sajip
On Mar 30, 3:49 pm, mennis wrote: > I am working on a library for controlling various appliances in which > I use theloggingmodule.  I'd like some input on the basic structure > of what I've done.  Specifically theloggingaspect but more general > comments are welcome.  I'm convinced I mis-understa

logging module usage

2011-03-30 Thread mennis
I am working on a library for controlling various appliances in which I use the logging module. I'd like some input on the basic structure of what I've done. Specifically the logging aspect but more general comments are welcome. I'm convinced I mis-understand something but I&

Re: Special logging module needed

2011-03-24 Thread Laszlo Nagy
2011.03.23. 19:33 keltezéssel, Dan Stromberg írta: On Wed, Mar 23, 2011 at 7:37 AM, Laszlo Nagy > wrote: I was also thinking about storing data in a gdbm database. One file for each month storing at most 100 log messages for every key value. Then one fi

Re: Special logging module needed

2011-03-23 Thread Dan Stromberg
On Wed, Mar 23, 2011 at 7:37 AM, Laszlo Nagy wrote: > I was also thinking about storing data in a gdbm database. One file for > each month storing at most 100 log messages for every key value. Then one > file for each day in the current month, storing one message for each key > value. Incrementa

Special logging module needed

2011-03-23 Thread Laszlo Nagy
Hi All, We have a special problem that needs to be addressed. We need to have a database of log messages. These messages are not simple strings - they are data structures. The log messages are assigned to various objects. Objects can be identified with simple object identifiers (strings).

Re: logging module -- better timestamp accuracy on Windows

2011-02-16 Thread Brian Curtin
On Wed, Feb 16, 2011 at 12:23, benhoyt wrote: > > > AFAIK, the Windows performance counter has long-term accuracy issues, > > so neither is perfect. Preferably we should have a timer with the long- > > term accuracy of time.time and the short-term accuracy of time.clock. > > Thanks for the tip --

Re: logging module -- better timestamp accuracy on Windows

2011-02-16 Thread benhoyt
> For example, are you assuming that your clock() call in logging is > the very first call made? Yes, we were making that assumption (the time.clock() call in the import of our log module), which was true in our code, but I can see where it's not a good thing to assume generally. > Also, IIUC

Re: logging module -- better timestamp accuracy on Windows

2011-02-16 Thread benhoyt
> AFAIK, the Windows performance counter has long-term accuracy issues, > so neither is perfect. Preferably we should have a timer with the long- > term accuracy of time.time and the short-term accuracy of time.clock. Thanks for the tip -- yes, I hadn't thought about that, but you're right, Quer

Re: logging module -- better timestamp accuracy on Windows

2011-02-16 Thread Brian Curtin
On Wed, Feb 16, 2011 at 09:34, sturlamolden wrote: > On 16 Feb, 15:30, benhoyt wrote: > > > It seems to me that the logging module should use a millisecond-accurate > timestamp (time.clock) on Windows, just like the "timeit" module does. > > AFAIK, the Windows pe

Re: logging module -- better timestamp accuracy on Windows

2011-02-16 Thread sturlamolden
On 16 Feb, 15:30, benhoyt wrote: > It seems to me that the logging module should use a millisecond-accurate > timestamp (time.clock) on Windows, just like the "timeit" module does. AFAIK, the Windows performance counter has long-term accuracy issues, so neither is perfect. Pref

Re: logging module -- better timestamp accuracy on Windows

2011-02-16 Thread Vinay Sajip
On Feb 16, 2:30 pm, benhoyt wrote: > It seems to me that the logging module should use a millisecond-accurate > timestamp (time.clock) on Windows, > just like the "timeit" module does. It's not an unreasonable request, though I don't think logging should be used t

Re: logging module -- better timestamp accuracy on Windows

2011-02-16 Thread benhoyt
-02-15T10:11:12.123 Request complete, took 0.56 ms It seems to me that the logging module should use a millisecond-accurate timestamp (time.clock) on Windows, just like the "timeit" module does. -Ben -- http://mail.python.org/mailman/listinfo/python-list

Re: logging module -- better timestamp accuracy on Windows

2011-02-15 Thread Ross Ridge
benhoyt wrote: >This works, but as you can see, it's a bit hacky. Is there a better way to = >fix it? (I'd like the fix to affect all loggers, including the root logger.= >) A simpler solution would be to caclulate the time it takes to the handle the request using time.clock() and include it in

logging module -- better timestamp accuracy on Windows

2011-02-15 Thread benhoyt
The Python logging module calls time.time() in LogRecord.__init__ to fetch the timestamp of the log record. However, time.time() isn't particularly accurate on Windows. We're logging start and end of our requests in our web server, which can be milliseconds apart, and the log timest

Re: Using logging module to log either to screen or a file

2010-12-07 Thread RedBaron
On Dec 7, 7:33 pm, Jean-Michel Pichavant wrote: > RedBaron wrote: > > Hi, > > I am beginner to python and i am writing a program that does a lot of > > things. One of the requirements is that the program shud generate a > > log file. I came across python loggging module and found it very > > usefu

Re: Using logging module to log either to screen or a file

2010-12-07 Thread Jean-Michel Pichavant
RedBaron wrote: Hi, I am beginner to python and i am writing a program that does a lot of things. One of the requirements is that the program shud generate a log file. I came across python loggging module and found it very useful. But I have a few problems Suppose by giving option '-v' along with

Using logging module to log either to screen or a file

2010-12-07 Thread RedBaron
Hi, I am beginner to python and i am writing a program that does a lot of things. One of the requirements is that the program shud generate a log file. I came across python loggging module and found it very useful. But I have a few problems Suppose by giving option '-v' along with the program the u

Re: hand made class with destructor and the logging module

2010-10-27 Thread Vinay Sajip
On Oct 27, 3:21 pm, climb65 wrote: > This class has a destructor which is expected to log something into my log > file if a crash occurs. > Well, the destructor works well but during the crash, python has already > closed the log file and the reference to the Logger has been set to None. > So, I c

hand made class with destructor and the logging module

2010-10-27 Thread climb65
Hello, I have a handmade class within a python program which uses the logging module. This class has a destructor which is expected to log something into my log file if a crash occurs. Well, the destructor works well but during the crash, python has already closed the log file and the

Re: logging module -> Miss messages if don't flush constantly? How set to flush constantly?

2010-08-21 Thread Peter Otten
Chris Seberino wrote: > It looks like I can miss some logging messages if I don't flush after > every oneis that true? As far as I can tell from the 2.6 source the StreamHandler does flush after each record. Peter -- http://mail.python.org/mailman/listinfo/python-list

logging module -> Miss messages if don't flush constantly? How set to flush constantly?

2010-08-21 Thread Chris Seberino
It looks like I can miss some logging messages if I don't flush after every oneis that true? This is an issue when program crashes so that logger didn't get a chance to print everything. Is there some way to set logging to constantly flush? -- http://mail.python.org/mailman/listinfo/python-l

Fwd: question on logging module - solved

2010-05-19 Thread frank zhu
FYI. -- Forwarded message -- From: Cameron Simpson Date: Wed, May 19, 2010 at 6:18 PM Subject: Re: question on logging module To: frank zhu On 19May2010 11:55, frank zhu wrote: | Thanks Cameron. That was the problem. I copied the sample code and named it | logging.py. which

Re: question on logging module

2010-05-18 Thread Cameron Simpson
On 18May2010 23:42, frank zhu wrote: | Hi, | >From the python 2.6.4 tutorial, refer to | http://docs.python.org/release/2.6.4/tutorial/stdlib2.html#logging | | The above example doesn't work for me. | Here is script log | | # | | o...@oem-desktop ~ $

question on logging module

2010-05-18 Thread frank zhu
Hi, >From the python 2.6.4 tutorial, refer to http://docs.python.org/release/2.6.4/tutorial/stdlib2.html#logging The above example doesn't work for me. Here is script log # o...@oem-desktop ~ $ python -V Python 2.6.4 o...@oem-desktop ~ $ python Python

Re: Is it possible to print different levels to different streams using the logging module?

2010-01-17 Thread Vinay Sajip
On Jan 16, 2:32 pm, Dotan Barak wrote: > Hi. > > I would like to use theloggingmodule and print the following levels to > the mentioned streams: > > CRITICAL    -> stderr > ERROR         -> stderr > WARNING   -> stderr > INFO             -> stdout > DEBUG         -> stdout > > I would like that ev

Re: Is it possible to print different levels to different streams using the logging module?

2010-01-16 Thread Peter Otten
Dotan Barak wrote: > Hi. > > I would like to use the logging module and print the following levels to > the mentioned streams: > > CRITICAL-> stderr > ERROR -> stderr > WARNING -> stderr > INFO -> stdout > DEBUG ->

Is it possible to print different levels to different streams using the logging module?

2010-01-16 Thread Dotan Barak
Hi. I would like to use the logging module and print the following levels to the mentioned streams: CRITICAL-> stderr ERROR -> stderr WARNING -> stderr INFO -> stdout DEBUG -> stdout I would like that every message will be printed only on

Re: how to change when the logging module creates the log file?

2010-01-06 Thread Chris Colbert
are > handled. However, if no exceptions are encountered, I don't want to create a > log at all. > > The problem I am running into is that the stdlib logging module creates the > log file immediately upon logger instantiation. > > Thus: > >>> logger = logging.basic

how to change when the logging module creates the log file?

2010-01-06 Thread Chris Colbert
I have an application the writes to a log file when specific exceptions are handled. However, if no exceptions are encountered, I don't want to create a log at all. The problem I am running into is that the stdlib logging module creates the log file immediately upon logger instantiation.

Re: AttributeError: logging module bug ?

2009-12-21 Thread Peter
On 12/21/2009 08:35 AM, Gabriel Genellina wrote: En Sat, 19 Dec 2009 00:18:26 -0300, Peter escribió: This was somehow unexpected for me, since in a module using logger.py, I could use either import: from mylogger import logger # without package name or from of.mylogger import logger # wi

Re: AttributeError: logging module bug ?

2009-12-20 Thread Gabriel Genellina
En Sat, 19 Dec 2009 00:18:26 -0300, Peter escribió: This was somehow unexpected for me, since in a module using logger.py, I could use either import: from mylogger import logger # without package name or from of.mylogger import logger # with package name but this does not seem to work f

Re: AttributeError: logging module bug ?

2009-12-18 Thread Peter
./of/logger.py from logging import Formatter class RootFormatter(Formatter): pass class ModuleFormatter(Formatter): pass class ClassFormatter(Formatter): pass class DataFormatter(Formatter): pass (and an empty ./of/__init__.py) your initial script runs without error. If yo

Re: AttributeError: logging module bug ?

2009-12-16 Thread Peter Otten
Peter wrote: >>> What's the problem ? >>> >> Please provide the config file "logging.cfg" to ease debugging. >> >> Peter >> > Here it is, thanks for having a look > Peter Unfortunately I still can't reproduce your problem. With a minimal file ./of/logger.py from logging import Formatt

Re: AttributeError: logging module bug ?

2009-12-15 Thread Peter
What's the problem ? Please provide the config file "logging.cfg" to ease debugging. Peter Here it is, thanks for having a look Peter # supports no whitespace !!! [DEFAULT] logdir=/tmp logfile=python logging_server=localhost [loggers] keys=root,module,class,data,class_1,data_1,of_

Re: AttributeError: logging module bug ?

2009-12-15 Thread Neil Cerutti
On 2009-12-15, Neil Cerutti wrote: > On 2009-12-15, Peter wrote: >> on python 2.6 the following code raises an AttributeError: >> >> #!/usr/bin/env python >> import os.path as p >> import logging, logging.config >> >> >> class Logger(object): >>def load_config(self): >> logging.config.fi

Re: AttributeError: logging module bug ?

2009-12-15 Thread Peter Otten
Peter wrote: > on python 2.6 the following code raises an AttributeError: > > #!/usr/bin/env python > import os.path as p > import logging, logging.config > > > class Logger(object): >def load_config(self): > logging.config.fileConfig(p.join(p.dirname(__file__),'logging.cfg')) > > log

Re: AttributeError: logging module bug ?

2009-12-15 Thread Neil Cerutti
On 2009-12-15, Peter wrote: > on python 2.6 the following code raises an AttributeError: > > #!/usr/bin/env python > import os.path as p > import logging, logging.config > > > class Logger(object): >def load_config(self): > logging.config.fileConfig(p.join(p.dirname(__file__),'logging.cfg

AttributeError: logging module bug ?

2009-12-15 Thread Peter
on python 2.6 the following code raises an AttributeError: #!/usr/bin/env python import os.path as p import logging, logging.config class Logger(object): def load_config(self): logging.config.fileConfig(p.join(p.dirname(__file__),'logging.cfg')) logger = Logger() logger.load_config() ==

Re: logging module, SMTPHandler and gmail in python 2.6

2009-12-06 Thread Vinay Sajip
On Dec 4, 12:31 pm, mynthon wrote: Thank you for this suggestion. Ideally, you would have created an issue for this on bugs.python.org, because then it would be more likely to be acted upon. I've implemented this feature in r76691 (in Python trunk and py3k) in a more general way. It works by spe

logging module, SMTPHandler and gmail in python 2.6

2009-12-04 Thread mynthon
You cannot use gmail account for sending emails with logging module. It is because google requires TLS connection and logging module doesn't support it. To use gmail you have to extend logging.handlers.SMTPHandler class and override SMTPHandler.emit() method. Here is source code. (There r

Re: Using logging module for conditional nested logs

2009-11-07 Thread Vinay Sajip
On Nov 4, 11:14 pm, Reckoner wrote: > Thanks again. You're welcome. You asked (on a Logging 101 blog comment) for a tutorial on how to use Filters. I can point you this Stack Overflow question: http://stackoverflow.com/questions/1383254/logging-streamhandler-and-standard-streams The answer is

Re: Using logging module for conditional nested logs

2009-11-04 Thread Reckoner
On Nov 4, 1:30 pm, Vinay Sajip wrote: > On Nov 4, 7:40 pm, Reckoner wrote: > > > > > I hope that made some sense. > > Not especially :-( > > Sorry I don't understand exactly what you mean, because I find your > terminology confusing. For example, "logger that is attached to foo2" > - loggers are

Re: Using logging module for conditional nested logs

2009-11-04 Thread Vinay Sajip
On Nov 4, 7:40 pm, Reckoner wrote: > > I hope that made some sense. Not especially :-( Sorry I don't understand exactly what you mean, because I find your terminology confusing. For example, "logger that is attached to foo2" - loggers are not attached to functions. "It responds to the 'root' log

Using logging module for conditional nested logs

2009-11-04 Thread Reckoner
Hi, I am getting started with your logging module and I went through the tutorial and know-how to create a top-level 'root' logger with the appropriate handlers. I have a number of functions,say, def foo1() def foo2() ... foo1() # foo2 calls foo1 and I know how to connect eac

Re: logging module and binary strings

2009-07-01 Thread Robert Kern
;}) Traceback (most recent call last): File "/usr/lib/python2.6/logging/__init__.py", line 773, in emit stream.write(fs % msg.encode("UTF-8")) UnicodeDecodeError: 'utf8' codec can't decode byte 0xfe in position 10: unexpected code byte snip Is there

Re: logging module and binary strings

2009-07-01 Thread Peter Otten
logging.info(x, extra={'encoding':'utf-8'}) > Traceback (most recent call last): > File "/usr/lib/python2.6/logging/__init__.py", line 773, in emit > stream.write(fs % msg.encode("UTF-8")) > UnicodeDecodeError: 'utf8' codec

logging module and binary strings

2009-07-01 Thread Frank Aune
{'encoding':'utf-8'}) Traceback (most recent call last): File "/usr/lib/python2.6/logging/__init__.py", line 773, in emit stream.write(fs % msg.encode("UTF-8")) UnicodeDecodeError: 'utf8' codec can't decode byte 0xfe in position 10: unexpe

Re: Using logging module to log into flash drive

2009-06-10 Thread Jorgen Grahn
On Tue, 9 Jun 2009 18:10:18 +0100, A. Cavallo wrote: [top-posting fixed] > On Tuesday 09 June 2009 16:57:00 kretel wrote: >> Hi All, >> >> I am trying to implement the following functionality: >> 1. log messages to the flash drive >> 2. if the flash drive is not available, switch handler to the

Re: Using logging module to log into flash drive

2009-06-10 Thread Krzysztof Retel
On Jun 9, 7:57 pm, Carl Banks wrote: > On Jun 9, 8:57 am, kretel wrote: > > > > > Hi All, > > > I am trying to implement the following functionality: > > 1. log messages to the flash drive > > 2. if the flash drive is not available, switch handler to the > > BufferringHandler and log into buffer,

  1   2   3   >