[logging] problems in Python 2.3

F

Frantisek Fuka

I am using the standard "logging" module included with Python and it
seems it doesn't correctly identify the filename (and thus module name)
from where the logging method was called. In fact, no matter from which
module I call the logging method, the resulting log says that the
filename of the caller is:

\tmp\python.2664\usr\lib\python2.3\logging\__init__.py

(this seems to me like a reference to the logging module itself combined
with some sort of weird temporary storage)

This happens on my Windows98 machine both under Cygwin and under Windows
Python (both of them 2.3). When I try the exact same script on the Linux
server with Python 2.2 installed, it displays the filenames correctly.
 
V

Vinay Sajip

Frantisek Fuka said:
I am using the standard "logging" module included with Python and it
seems it doesn't correctly identify the filename (and thus module name)
from where the logging method was called. In fact, no matter from which
module I call the logging method, the resulting log says that the
filename of the caller is:

\tmp\python.2664\usr\lib\python2.3\logging\__init__.py

(this seems to me like a reference to the logging module itself combined
with some sort of weird temporary storage)

This happens on my Windows98 machine both under Cygwin and under Windows
Python (both of them 2.3). When I try the exact same script on the Linux
server with Python 2.2 installed, it displays the filenames correctly.

Strange that it happens the same under Windows. Why would it be
looking for a Unix-like path such as the one you describe under
Windows, when not using cygwin?

Are you using "import logging" rather than "from logging import *" in
your script?
 
F

Frantisek Fuka

Vinay said:
Strange that it happens the same under Windows. Why would it be
looking for a Unix-like path such as the one you describe under
Windows, when not using cygwin?

Are you using "import logging" rather than "from logging import *" in
your script?

Yes, I am using "import logging". And there is nothing like
"python.2664" in my cygwin "/tmp/" directory (and never was). My
application is in completely different directory. Also note that the
displayed filename has BACKSLASHES, not forward slashes.
 
J

Jim Jewett

Frantisek Fuka said:
In fact, no matter from which module I call the logging method,
the resulting log says that the filename of the caller is:
\tmp\python.2664\usr\lib\python2.3\logging\__init__.py
(this seems to me like a reference to the logging module itself combined
with some sort of weird temporary storage)

Are you by any chance running from inside an editor, such as
emacs or even idle? If the module somehow gets hold of a
second sourcefile (and this looks like a copy tied to your
current process -- like the names for toplevel under emacs),
then this won't match the original __srcfile__.

You may wish to override the portion that finds a caller, so
that it will throw out, say, anything matching .*\logging\__init__.py([co])?

-jJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top