Re: glue between apache and python logging

2005-10-20 Thread Graham Dumpleton
Nick wrote .. > Graham Dumpleton wrote: > >>Graham Dumpleton wrote: > > Unfortunately you can't do that as all Python request objects in that > > chain are created fresh for the handler which is the target of the > > internal redirect. When the internal redirect returned, the cached > > would then

Re: glue between apache and python logging

2005-10-20 Thread Nick
Graham Dumpleton wrote: Graham Dumpleton wrote: Unfortunately you can't do that as all Python request objects in that chain are created fresh for the handler which is the target of the internal redirect. When the internal redirect returned, the cached would then be actually different to the orig

Re: glue between apache and python logging

2005-10-20 Thread Graham Dumpleton
Nick wrote .. > Graham Dumpleton wrote: > > Yes, effectively the same as what I was doing. As I highlighted in prior > > email though about request cache implementations, not sure it would > > work correctly if an internal redirect occurred and both original handler > > and target of internal redir

Re: glue between apache and python logging

2005-10-20 Thread Nick
Graham Dumpleton wrote: Yes, effectively the same as what I was doing. As I highlighted in prior email though about request cache implementations, not sure it would work correctly if an internal redirect occurred and both original handler and target of internal redirect had registered request obj

Re: glue between apache and python logging

2005-10-20 Thread Nic Ferrier
"Graham Dumpleton" <[EMAIL PROTECTED]> writes: > Either way, to get the flexibility you want, user code still has to do > the association of a log handler to a specific logger at some point, eg. > preferably in a PythonImport module and only once. Adding a default > apache log handler against "mod

Re: glue between apache and python logging

2005-10-20 Thread Graham Dumpleton
Yes, effectively the same as what I was doing. As I highlighted in prior email though about request cache implementations, not sure it would work correctly if an internal redirect occurred and both original handler and target of internal redirect had registered request object. One needs to use a st

Re: glue between apache and python logging

2005-10-20 Thread Graham Dumpleton
Nic Ferrier wrote .. > "Graham Dumpleton" <[EMAIL PROTECTED]> writes: > > > Nic wrote: > >> Programmers may or may not want to redirect logging through Apache. > If > >> mod_python used the system you describe there would either have to be: > >> > >> 1. config syntax to allow module 'logging' glue

Re: glue between apache and python logging

2005-10-20 Thread Nick
Graham Dumpleton wrote: Hopefully everyone follows what I am talking about. I will try and get together a working example today of what I am talking about, but Nick, you may want to consider posting your code and how you are using it as it probably will not be too different. Here's my sample co

Re: glue between apache and python logging

2005-10-20 Thread Nic Ferrier
"Graham Dumpleton" <[EMAIL PROTECTED]> writes: > Nic wrote: >> Programmers may or may not want to redirect logging through Apache. If >> mod_python used the system you describe there would either have to be: >> >> 1. config syntax to allow module 'logging' glue to be turned off >> >> 2. removal o

Re: glue between apache and python logging

2005-10-20 Thread Graham Dumpleton
Nic Ferrier wrote .. > "Graham Dumpleton" <[EMAIL PROTECTED]> writes: > > > That is, a global log handler instance is created once only. No instance > per > > request handler invocation. > > > > As you point out you need though to do caching of request objects. I > have > > previously posted on a

Re: glue between apache and python logging

2005-10-20 Thread Graham Dumpleton
Graham Dumpleton wrote .. > Graham Dumpleton wrote .. > > Hopefully everyone follows what I am talking about. I will try and get > > together a working example today of what I am talking about, but Nick, > > you may want to consider posting your code and how you are using it > > as it probably will

Re: glue between apache and python logging

2005-10-20 Thread Graham Dumpleton
Graham Dumpleton wrote .. > Hopefully everyone follows what I am talking about. I will try and get > together a working example today of what I am talking about, but Nick, > you may want to consider posting your code and how you are using it > as it probably will not be too different. Okay, here i

Re: glue between apache and python logging

2005-10-20 Thread Nic Ferrier
"Graham Dumpleton" <[EMAIL PROTECTED]> writes: > That is, a global log handler instance is created once only. No instance per > request handler invocation. > > As you point out you need though to do caching of request objects. I have > previously posted on a safe way of doing this which works for

Re: glue between apache and python logging

2005-10-20 Thread Jim Gallacher
Nic Ferrier wrote: Jim Gallacher <[EMAIL PROTECTED]> writes: There is a typo in your code: s/logging.debug/logging.DEBUG/ Got me. It ran for me though... Beyond that it still segfaults for me. I can't get it to segfault. Can you share your test? Sure, but it's not doing anything f

Re: glue between apache and python logging

2005-10-20 Thread Graham Dumpleton
On 21/10/2005, at 2:41 AM, Nic Ferrier wrote: There is one remaining problem that I am aware of. When you do: logger = logging.getLogger("webapp") you are always gauranteed to get the same logger. That's bad in a multi-programming environment. The traditional approach to this is to creat

Re: glue between apache and python logging

2005-10-20 Thread Nic Ferrier
Jim Gallacher <[EMAIL PROTECTED]> writes: > There is a typo in your code: s/logging.debug/logging.DEBUG/ Got me. It ran for me though... > Beyond that it still segfaults for me. I can't get it to segfault. Can you share your test? > The other problem is that you are not removing the handle

Re: glue between apache and python logging

2005-10-20 Thread Nick
Jim Gallacher wrote: Beyond that it still segfaults for me. The other problem is that you are not removing the handler instance from the logging instance so you still have a memory leak. 100k requests would result in 100k handler instances. Oh, and there might be a bit of a performance issue wh

Re: glue between apache and python logging

2005-10-20 Thread Jim Gallacher
Nic Ferrier wrote: Jim Gallacher <[EMAIL PROTECTED]> writes: My gut was right. Your current version segfaults (using mpm-prefork). It might work if you register a cleanup to remove the reference to your logging handler (untested): req.register_cleanup(log.removeHandler, hdlr) The problem h

Re: glue between apache and python logging

2005-10-20 Thread Nic Ferrier
Jim Gallacher <[EMAIL PROTECTED]> writes: > My gut was right. Your current version segfaults (using mpm-prefork). It > might work if you register a cleanup to remove the reference to your > logging handler (untested): > > req.register_cleanup(log.removeHandler, hdlr) > > The problem here is that

Re: glue between apache and python logging

2005-10-20 Thread Nic Ferrier
Jim Gallacher <[EMAIL PROTECTED]> writes: >>>Furthermore, you can't depend on the request object being valid once >>>the request processing has completed. At some point request_tp_clear (in >>>requestobject.c) will get called and request->server will be set to >>>NULL. (At least I think this is

Re: glue between apache and python logging

2005-10-20 Thread Graham Dumpleton
On 20/10/2005, at 5:49 PM, Nicolas Lehuen wrote: > And I agree with all these points except that I don't think it's > trivial to get it right. In fact, that it is *not* trivial may be best > argument for inclusion in mod_python. Having everyone write seemingly > trivial logging code which

Re: glue between apache and python logging

2005-10-20 Thread Nicolas Lehuen
2005/10/20, David Fraser <[EMAIL PROTECTED]>: Jim Gallacher wrote:> Nic Ferrier wrote:>>> All that I asked is that a module similar to mine be included in>> mod_python's dist so that it can be available to programmers by>> default. >> Yes, I understand this. I just think if the decision was made to

Re: glue between apache and python logging

2005-10-20 Thread David Fraser
Jim Gallacher wrote: Nic Ferrier wrote: All that I asked is that a module similar to mine be included in mod_python's dist so that it can be available to programmers by default. Yes, I understand this. I just think if the decision was made to include this feature it should be rock solid. I'