[ python-Bugs-968245 ] Python Logging filename & file number

SourceForge.net noreply at sourceforge.net
Fri Jul 16 07:45:42 CEST 2004


Bugs item #968245, was opened at 2004-06-07 15:49
Message generated for change (Settings changed) made by vsajip
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=968245&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
Resolution: Works For Me
Priority: 5
Submitted By: Ryan (superleo303)
Assigned to: Vinay Sajip (vsajip)
Summary: Python Logging filename & file number 

Initial Comment:
I use Freebsd and redhat 9.0 linus at work.

Using Python Logging filename & file number on freebsd
works fine.
When i print a log statement, and have my config
formatter section set like:
[formatter_default]
format=%(asctime)s <%(levelname)s>
<%(module)s:%(lineno)s> %(message)s
datefmt=

On bsd my logs look like:
<INFO> <propmancmd:95> stateOnly is: DE
<INFO> <propmancmd:105>  MEssages .........
<INFO> <propmancmd:107> collecting datasource: 1011
<INFO> <propman:98>   Collectors overwrite existing
pickle files: 0
<INFO> <propman:99>           Collectors run in
multiple threads: 4
<DEBUG> <propman:528> sql is:
...

See, the filename and file number get displayed with
each logging call,

Now, The same exact code run on the same exact version
of python on a linux machine yiedls the lines:

<INFO> <__init__:988> stateOnly is: DE
<INFO> <__init__:988>  MEssages
<INFO> <__init__:988> collecting datasource: 1011
<INFO> <__init__:988>   Collectors overwrite existing
pickle files: 0
<INFO> <__init__:988>           Collectors run in
multiple threads: 4
<DEBUG> <__init__:988> sql is: 
...

So i opened up ./python2.3/logging/__init__.py  line
988 and it seems to be where the problem is.

Can someone take a look at this asap?   I have to run
all my code on linux machines, so now i cant see which
file and which line is making the logging.

To reproduce, get a freebsd and linux machine,
then run a simple script that uses logging config files
and use the above example as your formatter in the
logging confrig file,

BSD should show the filenames and numbers, linux should
show __init__ 988 instead.


----------------------------------------------------------------------

Comment By: Ryan (superleo303)
Date: 2004-07-15 18:05

Message:
Logged In: YES 
user_id=1058618

Bug is solved. Probably due to the fact that the our sys
admin builds packages and doesnt install python from source,
the package had pyc and pyo files in it for logging/__inti__.py*
once those were deleted, and as root, ran python -O, the
problem was fixed.  Sorry to waste time with a non-bug   :)
This issue is solved.

----------------------------------------------------------------------

Comment By: Ryan (superleo303)
Date: 2004-07-15 12:55

Message:
Logged In: YES 
user_id=1058618

I have tried this on 3 red hat boxes, all the same version
of red hat, and im pretty sure its all the same version of
python, my sys admin builds a python package and installs
that way, ill ask him to install python from source on one
of the machines and see if that helps, if it doesnt, would
you be willing to log into our machine here and test it,
maybe there is something (obvious) you can see that is wrong?

----------------------------------------------------------------------

Comment By: Vinay Sajip (vsajip)
Date: 2004-07-15 07:00

Message:
Logged In: YES 
user_id=308438

I tried this on Mandrake Linux 10 (it's a Red Hat variant) 
which has Python 2.3.3, with the expected result:

2004-07-15 07:45:58,258 <INFO> <test:9> This is a inof call.
2004-07-15 07:45:58,282 <WARNING> <test:10> This is a 
warn call.
2004-07-15 07:45:58,282 <ERROR> <test:11> This is a error 
call.

Might there be a problem with your Red Hat or Python 
installation? Have you tried it on several Red Hat boxes?

----------------------------------------------------------------------

Comment By: Ryan (superleo303)
Date: 2004-07-14 15:40

Message:
Logged In: YES 
user_id=1058618

Also,
Here are the versions of python i am using

$ python
Python 2.3.3 (#2, Jan 21 2004, 07:27:38)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>>

$ python
Python 2.3.4 (#2, Jul 12 2004, 09:19:42)
[GCC 3.3.3 [FreeBSD] 20031106] on freebsd5
Type "help", "copyright", "credits" or "license" for more
information.
>>>

----------------------------------------------------------------------

Comment By: Ryan (superleo303)
Date: 2004-07-14 15:31

Message:
Logged In: YES 
user_id=1058618

Hi ,
I have attached a script to reproduce the error, jsut run
./test.py in the folder.

This is what freebsd produces:
$ python ./test.py
2004-07-14 11:29:47,067 <INFO> <test:9> This is a inof call.
2004-07-14 11:29:47,069 <WARNING> <test:10> This is a warn call.
2004-07-14 11:29:47,069 <ERROR> <test:11> This is a error call.

This is what redhat produces:
$ python ./test.py
2004-07-14 11:28:24,812 <INFO> <__init__:988> This is a info
call.
2004-07-14 11:28:24,812 <WARNING> <__init__:988> This is a
warn call.
2004-07-14 11:28:24,812 <ERROR> <__init__:988> This is a
error call.

As you can see, the filename:fileno attributes are different.



----------------------------------------------------------------------

Comment By: Ryan (superleo303)
Date: 2004-07-12 13:35

Message:
Logged In: YES 
user_id=1058618

Sorry, no , i just have been very busy and havent had time
to reproduce the error, 
i promise by tomorrow ill have a small set of scripts  to
reproduce the error.
All the linux boxes, which is 4 of them, are red hat 9.0, so
maybe its only a problem with red hat?
Ill be posting the scripts tomorrow.
Thanks for checking into this 

-Ryan

ps - i wasnt able to send you an email, it said:

<vsajip at users.sourceforge.net>: host
mail.sourceforge.net[66.35.250.206] said:
    550 Administrative prohibition

<vsajip at sourceforge.net>: host
mail.sourceforge.net[66.35.250.206] said: 550
    Administrative prohibition


----------------------------------------------------------------------

Comment By: Vinay Sajip (vsajip)
Date: 2004-07-05 12:06

Message:
Logged In: YES 
user_id=308438

I'm not able to reproduce these problems under Linux - I only 
have access to Mandrake 10.0 (a Red Hat variant).

Can you upload a script or set of scripts which demonstrates 
the problem?

----------------------------------------------------------------------

Comment By: Ryan (superleo303)
Date: 2004-06-10 17:18

Message:
Logged In: YES 
user_id=1058618

vsajip, i tested on both machines, both machines returned
the same results:

STACKWALKER RESULTS RUN ON LINUX RED HAT 9.0

[rsmith at marge]:~/ned$ cd bin/testing/stackwalk/
[rsmith at marge]:~/ned/bin/testing/stackwalk$ python sw1.py
[rsmith at marge]:~/ned/bin/testing/stackwalk$ python sw2.py
[rsmith at marge]:~/ned/bin/testing/stackwalk$ python sw3.py
[rsmith at marge]:~/ned/bin/testing/stackwalk$ python sw4.py
[rsmith at marge]:~/ned/bin/testing/stackwalk$ python stackwalk.py
[rsmith at marge]:~/ned/bin/testing/stackwalk$ python getcaller.py
/home/rsmith/ned/bin/testing/stackwalk/sw1.py(4)
/home/rsmith/ned/bin/testing/stackwalk/sw2.py(5)
/home/rsmith/ned/bin/testing/stackwalk/sw3.py(6)
/home/rsmith/ned/bin/testing/stackwalk/sw4.py(7)
getcaller.py(3)
[rsmith at marge]:~/ned/bin/testing/stackwalk$


-------------------------------------------------------------------------

STACKWALKER RESULTS RUN ON FREEBSD 5.2.1-RELEASE-p8

[ryan at dev2]:~/ned$ cd bin/testing/stackwalk/
[ryan at dev2]:~/ned/bin/testing/stackwalk$ python sw1.py
[ryan at dev2]:~/ned/bin/testing/stackwalk$ python sw2.py
[ryan at dev2]:~/ned/bin/testing/stackwalk$ python sw3.py
[ryan at dev2]:~/ned/bin/testing/stackwalk$ python sw4.py
[ryan at dev2]:~/ned/bin/testing/stackwalk$ python stackwalk.py
[ryan at dev2]:~/ned/bin/testing/stackwalk$ python getcaller.py
/usr/home/ryan/ned/bin/testing/stackwalk/sw1.py(4)
/usr/home/ryan/ned/bin/testing/stackwalk/sw2.py(5)
/usr/home/ryan/ned/bin/testing/stackwalk/sw3.py(6)
/usr/home/ryan/ned/bin/testing/stackwalk/sw4.py(7)
getcaller.py(3)
[ryan at dev2]:~/ned/bin/testing/stackwalk$

----------------------------------------------------------------------

Comment By: Vinay Sajip (vsajip)
Date: 2004-06-09 09:26

Message:
Logged In: YES 
user_id=308438

The problem appears to be related to some underlying 
problem with sys._getframe(). Can you please download the 
attached stackwalk.tar.gz and run it on both FreeBSD and 
Linux? Please post your findings here, thanks. Note that the 
stackwalk stuff contains no calls to the logging package.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=968245&group_id=5470


More information about the Python-bugs-list mailing list