473,738 Members | 5,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[logging] problems in Python 2.3

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.266 4\usr\lib\pytho n2.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.

--
Frantisek Fuka
(yes, that IS my real name)
(and it's pronounced "Fran-tjee-shek Foo-kah")
----------------------------------------------------
My E-mail: fu**@fuxoft.cz
My Homepage: http://www.fuxoft.cz
My ICQ: 2745855
Jul 18 '05 #1
3 1574
Frantisek Fuka <fu**@fuxoft.cz > wrote in message news:<c1******* ****@ns.felk.cv ut.cz>...
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.266 4\usr\lib\pytho n2.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?
Jul 18 '05 #2
Vinay Sajip wrote:
Frantisek Fuka <fu**@fuxoft.cz > wrote in message news:<c1******* ****@ns.felk.cv ut.cz>...
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.2 664\usr\lib\pyt hon2.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?


Yes, I am using "import logging". And there is nothing like
"python.266 4" 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.

--
Frantisek Fuka
(yes, that IS my real name)
(and it's pronounced "Fran-tjee-shek Foo-kah")
----------------------------------------------------
My E-mail: fu**@fuxoft.cz
My Homepage: http://www.fuxoft.cz
My ICQ: 2745855
Jul 18 '05 #3
Frantisek Fuka <fu**@fuxoft.cz > wrote in message news:<c1******* ****@ns.felk.cv ut.cz>...
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.266 4\usr\lib\pytho n2.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\__in it__.py([co])?

-jJ
Jul 18 '05 #4

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

Similar topics

0
1659
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 and are not documented elsewhere. I used the logging configuration file shown below. My aim was to log only the INFO messages, but log DEBUG messages for one particular module (called webTestLogin.py).
3
5276
by: Jeff Shannon | last post by:
I'm having some difficulty getting my logging configuration set correctly. I'm using a config file (copied at end of post), with the intent of setting several loggers which write to a combination of a file, stderr (for debugging), and the NT Eventlog, but I don't seem to be getting the right combination of handlers called. The desired combinations are as follows: root - Eventlog, stderr log02 - file, stderr
23
2220
by: Rotem | last post by:
Hi, while working on something in my current project I have made several improvements to the logging package in Python, two of them are worth mentioning: 1. addition of a logging record field %(function)s, which results in the name of the entity which logged the record. My version even deduces the class name in the case which the logger is a bound method, and assuming the name of the "self" variable is indeed "self".
2
1272
by: Chris Curvey | last post by:
The following code exists in logging/config.py handlers = h except: #if an error occurs when instantiating a handler, too bad pass #this could happen e.g. because of lack of privileges The problem here is that if something did go wrong instantiating the handler, you have no idea what the problem was (permissions, syntax error, wrong parameters), and later on you get a message like:
0
1863
by: robert | last post by:
As more and more python packages are starting to use the bloomy (Java-ish) 'logging' module in a mood of responsibility and as I am not overly happy with the current "thickener" style of usage, I want to put this comment and a alternative most simple default framework for discussion. Maybe there are more Python users which like to see that imported (managed) logging issue more down-to-earth and flexible ? ... Vinay Sajip wrote: >...
3
5400
by: nicholas.petrella | last post by:
I am currently trying to use the python logging system as a core enterprise level logging solution for our development and production environments. The rotating file handler seems to be what I am looking for as I want the ability to have control over the number and size of log files that are written out for each of our tools. I have noticed a few problems with this handler and wanted to post here to get your impressions and possibly...
4
1877
by: Alia Khouri | last post by:
I've been struggling with the logging module in the stdlib which seems to me rather counter-intuitive: For some reason it refuses to recognize configuration options when they are set inside a class so I have had to initialize logging and set the configuration options in the global scope of my module with logging.basicConfig. Here's what I did within the class setup method:
4
1621
by: samwyse | last post by:
In the Python 2.5 Library Reference, section 14.5.3 (Logging to multiple destinations), an example is given of logging to both a file and the console. This is done by using logging.basicConfig() to configure a log file, and then calling logging.getLogger('').addHandler(console) to add the console. However, in section 14.5.4 (Sending and receiving logging events across a network), a call is made to rootLogger.addHandler(socketHandler),...
4
2362
by: Matthew Wilson | last post by:
I'm working on a package that uses the standard library logging module along with a .cfg file. In my code, I use logging.config.fileConfig('/home/matt/mypackage/matt.cfg') to load in the logging config file. However, it seems really obvious to me that this won't work when I share this package with others.
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9476
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9263
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8210
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.