Graham Dumpleton
graham.dumpleton at gmail.com
Tue Nov 6 15:54:03 EST 2007
On 07/11/2007, Graham Dumpleton <graham.dumpleton at gmail.com> wrote: > On 07/11/2007, Kathryn Van Stone <kvs at acm.org> wrote: > > > > I am currently using mod_python version 3.3.1 with Apache 2.2.4 (and > > Python 2.5.1). I've notice a difference between using > > apache.log_error and req.log_error. I modified mptest.py to the > > following: > > > > from mod_python import apache > > > > def handler(req): > > apache.log_error('Test log from apache', apache.APLOG_DEBUG) > > req.log_error('Test log from request', apache.APLOG_DEBUG) > > req.content_type = 'text/plain' > > req.write('Hello World') > > return apache.OK > > > > > > I modified the apache configuration to set the log level to debug. I > > get the request log message, but not the apache log message. When the > > log level is raised to APLOG_NOTICE, I get both messages. > > Known issue, or at least I knew about it. I can't see that I created > an issue for it in the bug tracker though. I also can't remember the > full details at the moment. I know I made sure I didn't make the same > mistake in mod_wsgi though. :-) > > > Any thoughts on why there is a difference? We have areas where > > getting the request object is a hassle and would like to use > > apache.log_error. (Also there are members of my team who don't like > > the 'requestobject.c(823)' showing up in the log as it adds almost no > > information) > > That requestobject.c always show for DEBUG level statements is a > result of how Apache works, in that it in embeds the C code file/line > number of where ap_log_rerror() is called. It is non trivial and > perhaps not entirely reliable, to try and dynamically work out where > in the Python code the call to the Python wrapper for the function was > called. It may be possible to fudge things at the level of the call to > ap_log_rerror() and not pass APLOG_MARK as argument and split it out > into two separate zero arguments. Presume that ap_log_rerror() will > not crash if line information not supplied. Quick one as bit rushed right now. Use: from mod_python import apache apache.main_server.log_error(......) for now. This should mean values of LogLevel will be honoured. I remember what the issues were now, but no time to go in to it. Graham
|