Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > logging module: log method with keyword arguments

Reply
Thread Tools

logging module: log method with keyword arguments

 
 
David Konerding
Guest
Posts: n/a
 
      09-09-2003
Hi,
I am trying to write my own Logging Handler object, to work within an existing logging system that I use.

However, when I try to dispatch log calls to the logger, I get an error in an internal logging call.

Here's an example code:
logger = logging.getLogger('test')
logger_handler = logging.StreamHandler(sys.stdout)
logger_formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
logger_handler.setFormatter(logger_formatter)
logger.addHandler(logger_handler)
logger.setLevel(logging.DEBUG)
logger.debug("Message: %(msg2)", msg2="foo")

The message I get is:

File "/home/portnoy/d5/dek/sw/rh9/Python-2.3/lib/python2.3/logging/__init__.py", line 879, in debug
apply(self._log, (DEBUG, msg, args), kwargs)
TypeError: _log() got an unexpected keyword argument 'msg2'

Now, I can kind of understand this because the documentation for the debug() method says:

The only keyword argument in kwargs which is inspected is exc_info which,
if it does not evaluate as false, causes exception information (via a
call to sys.exc_info()) to be added to the logging message.

My only problem is that the documentation doesn't say anything about
not accepting kwargs which aren't "exc_info" (I recognize the syntax I used above doesn't
actually do what I wanted anyway).

Dave
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging exception with java.util.logging.Logger#log() to file only Royan Java 1 04-01-2008 09:42 PM
RE: keyword checker - keyword.kwlist Hamilton, William Python 4 05-13-2007 06:31 AM
keyword checker - keyword.kwlist tom@finland.com Python 6 05-10-2007 04:53 PM
Keyword arguments in a block, possible with zero arguments? Peter Motzfeldt Ruby 1 03-13-2007 01:33 PM
Difference between default arguments and keyword arguments Edward Diener Python 14 04-05-2004 11:26 PM



Advertisments