473,486 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

logging module's documentation lies?

Quote from the docs:

FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
logging.basicConfig(format=FORMAT)
d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
logging.warning("Protocol problem: %s", "connection reset",
extra=d)

would print something like

2006-02-08 22:20:02,165 192.168.0.1 fbloggs Protocol problem:
connection reset

If we try to run that exact example, which doesn't seem logically
flawed in any way:
>>import logging
FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
logging.basicConfig(format=FORMAT)
d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
logging.warning("Protocol problem: %s", "connection reset",
extra=d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/logging/__init__.py",
line 1266, in warning
apply(root.warning, (msg,)+args, kwargs)
File "/usr/lib/python2.5/site-packages/logging/__init__.py",
line 969, in warning
apply(self._log, (WARNING, msg, args), kwargs)
TypeError: _log() got an unexpected keyword argument 'extra'

I tried using **d instead, no show. I tried extra=d in Python 2.4, no
show. I tried **d in Python 2.4, no show.

So, my question unto the lot of you is: Do the docs for the logging
module lie to me?

URL: http://docs.python.org/lib/module-logging.html
Jun 27 '08 #1
1 1906
On Jun 24, 2:35*pm, "ludvig.eric...@gmail.com"
<ludvig.eric...@gmail.comwrote:
Quote from the docs:

* * FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
* * logging.basicConfig(format=FORMAT)
* * d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
* * logging.warning("Protocol problem: %s", "connection reset",
extra=d)

would print something like

* * 2006-02-08 22:20:02,165 192.168.0.1 fbloggs *Protocol problem:
connection reset

If we try to run that exact example, which doesn't seem logically
flawed in any way:

* * >>import logging
* * >>FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
* * >>logging.basicConfig(format=FORMAT)
* * >>d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
* * >>logging.warning("Protocol problem: %s", "connection reset",
extra=d)
* * Traceback (most recent call last):
* * * File "<stdin>", line 1, in <module>
* * * File "/usr/lib/python2.5/site-packages/logging/__init__.py",
line 1266, in warning
* * * * apply(root.warning, (msg,)+args, kwargs)
* * * File "/usr/lib/python2.5/site-packages/logging/__init__.py",
line 969, in warning
* * * * apply(self._log, (WARNING, msg, args), kwargs)
* * TypeError: _log() got an unexpected keyword argument 'extra'

I tried using **d instead, no show. I tried extra=d in Python 2.4, no
show. I tried **d in Python 2.4, no show.

So, my question unto the lot of you is: Do the docs for the logging
module lie to me?

URL:http://docs.python.org/lib/module-logging.html
From the documentation: `Changed in version 2.5: extra was added.`

Documentation never lies, authors do. Or, in this case, don't.

Matt
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1640
by: Robert.Schmitt | last post by:
I found that the configuration system of the new logging package of Python 2.3 has some unintuitive idiosyncracies that are worth mentioning because they can cost you quite some development time...
6
10860
by: Ville Vainio | last post by:
Just posting this for the sake of google: Like everyone else, I figured it's time to start using the 'logging' module. I typically want to dump "info" level (and up) log information to...
3
1803
by: Daniel Lichtenberger | last post by:
Hi, I'm looking for a logging module to be used in a mod_python-powered website. Python 2.3's logging package seems like a good fit, however I'm not sure if it's completely safe to use it under...
3
2452
by: Chris Smith | last post by:
Hola, pythonisas: The documentation for the logging module is good, but a bit obscure. In particular, there seems to be a lot of action at a distance. The fact that getLogger() can actually be a...
7
1528
by: Leo Breebaart | last post by:
I have another question where I am not so much looking for a solution but rather hoping to get some feedback on *which* solutions people here consider good Pythonic ways to approach a issue. ...
10
2638
by: Baurzhan Ismagulov | last post by:
Hello all, I want that each module has its own logger. I've defined the following config file: keys=f01 keys=console
0
1245
by: Christoph Haas | last post by:
Evening, I have an application that is running in an endless loop processing an incoming queue. Every run is supposed to write a log file about the run and then close it again. While the...
12
1945
by: Tekkaman | last post by:
I'm getting a strange behaviour from the "pathname" and "lineno" formatter mapping keys. Instead of my file and my line number I get: /usr/lib/python2.4/logging/__init__.py as the file, and...
3
6379
by: Lowell Alleman | last post by:
Here is the situation: I wrote my own log handler class (derived from logging.Handler) and I want to be able to use it from a logging config file, that is, a config file loaded with the...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.