Re: glue between apache and python logging

2005-10-21 Thread Graham Dumpleton
On 22/10/2005, at 8:05 AM, Nick wrote: As to providing "handler()" this is again because it is a separate sample distinct from mod_python. If a part of mod_python that can all be done transparently. I didn't want to provide a sample where people had to hack on their mod_python installation

Re: glue between apache and python logging

2005-10-21 Thread Nick
Graham Dumpleton wrote: The strange stuff with sys.modules stuff was to protect against any problems that can occur if people decided to take the sample code and put it straight in their document tree somewhere where it could be reloaded. You'll have to trust me that module reloading can cause so

Re: glue between apache and python logging

2005-10-21 Thread Graham Dumpleton
On 22/10/2005, at 12:36 AM, Nick wrote: Graham Dumpleton wrote: Anyway, I have attached an updated version of my log handler. This fixes the issue with log levels that don't exactly map to any defined level. Eliminates the explicit stack for storing request objects and in general tries

Re: glue between apache and python logging

2005-10-21 Thread Nic Ferrier
Jim Gallacher <[EMAIL PROTECTED]> writes: > For some reason all this talk of logging makes me want to sing, sing, > sing... > > Well I'm a lumberjack and I'm OK... Shurely the wrong song, it should be the song of our alma mater: Ohh! John Stewart Mill of his own free will Drank elev

Re: glue between apache and python logging

2005-10-21 Thread Graham Dumpleton
Graham Dumpleton wrote .. > It is only recently that I realised that a nested function like that > could access stack variables of the enclosing function. I should have added, "when the execution of the enclosing function has already finished and the nested function is called at a later time". I'm

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'

Re: glue between apache and python logging

2005-10-19 Thread Jim Gallacher
Nic Ferrier wrote: Jim Gallacher <[EMAIL PROTECTED]> writes: Here are some further things to consider if anyone wants to persue it. Consider the following code: import logging from mod_python import apache from proposed_mp_logging_module import ApacheLogHandler def handler(req) req.conten

Re: glue between apache and python logging

2005-10-19 Thread Jorey Bump
Where do I file a documentation bug? Rule #6 appears to be missing. ;) Sydney Nolan Nick wrote: In that case, let us just apply Rule #6 to this situation. Bruce Jim Gallacher wrote: Well, this is python, so everyone really should be called Bruce. Maybe that will help. Regards, Bruce

Re: glue between apache and python logging

2005-10-19 Thread Nick
Nic Ferrier wrote: But it's difficult to change your mind if you say "prove that logging is the most widely used logging available and then I'll think about it but I don't use it anyway because I wrote my own". Well, that's not what I said. What I said was: 1. I'm not convinced that a logger

Re: glue between apache and python logging

2005-10-19 Thread Nic Ferrier
Jim Gallacher <[EMAIL PROTECTED]> writes: > Nicolas Lehuen wrote: >> In that case, setting up the logging handler should be done by the user, >> making sure that it is set up only once per interpreter, even in the >> context of a multi-threaded MPM. It's not a trivial thing ; looks like >> this

Re: glue between apache and python logging

2005-10-19 Thread Nic Ferrier
Nicolas Lehuen <[EMAIL PROTECTED]> writes: > One thing to remember : every piece of code we introduce into mod_python is > a liability. We'll have to support it and I can't wait for having to solve > setup problems of people asking the list "where are my log entries going ?" > or "my log entries a

Re: glue between apache and python logging

2005-10-19 Thread Nic Ferrier
Nick <[EMAIL PROTECTED]> writes: > Maybe I just don't have enough exposure, but I don't see the logging > module used as ubiquitously as you seem to imply. I could agree with > you if logging was used everywhere, even in Python and its standard > modules. I could be wrong, but I just don't se

Re: glue between apache and python logging

2005-10-19 Thread Nic Ferrier
Nicolas Lehuen <[EMAIL PROTECTED]> writes: > In that case, setting up the logging handler should be done by the user, > making sure that it is set up only once per interpreter, even in the context > of a multi-threaded MPM. It's not a trivial thing ; looks like this is a job > for PythonImport. H

Re: glue between apache and python logging

2005-10-19 Thread Jim Gallacher
Nicolas Lehuen wrote: 2005/10/19, Nic Ferrier <[EMAIL PROTECTED] >: Is everyone here called Nic[h]olas? Nicolas Lehuen <[EMAIL PROTECTED] > writes: > Nic, there is something I need to understand before giving my advice

Re: glue between apache and python logging

2005-10-19 Thread Nicolas Lehuen
2005/10/19, Nic Ferrier <[EMAIL PROTECTED]>: Is everyone here called Nic[h]olas?Nicolas Lehuen <[EMAIL PROTECTED]> writes:> Nic, there is something I need to understand before giving my advice on the > subject. I'm not familiar with the logging API, can you tell me how you> configure Python to use

Re: glue between apache and python logging

2005-10-19 Thread Nic Ferrier
Is everyone here called Nic[h]olas? Nicolas Lehuen <[EMAIL PROTECTED]> writes: > Nic, there is something I need to understand before giving my advice on the > subject. I'm not familiar with the logging API, can you tell me how you > configure Python to use this logging implementation ? Looks lik

Re: glue between apache and python logging

2005-10-19 Thread Nic Ferrier
Nicolas Lehuen <[EMAIL PROTECTED]> writes: > OK now this is totally weird, we've got a Nic, a Nick and a Nicolas in the > thread, watch out for mass confusion ! Bah. You got the joke first. Nic

Re: glue between apache and python logging

2005-10-19 Thread Nicolas Lehuen
OK now this is totally weird, we've got a Nic, a Nick and a Nicolas in the thread, watch out for mass confusion !2005/10/19, Nicolas Lehuen < [EMAIL PROTECTED]>:Nic, there is something I need to understand before giving my advice on the subject. I'm not familiar with the logging API, can you tell m

Re: glue between apache and python logging

2005-10-19 Thread Nicolas Lehuen
Nic, there is something I need to understand before giving my advice on the subject. I'm not familiar with the logging API, can you tell me how you configure Python to use this logging implementation ? Looks like we have to manipulate configuration object, set up handlers and so on... If so I guess

Re: glue between apache and python logging

2005-10-19 Thread Nick
Nic Ferrier wrote: Nic Ferrier wrote: And again I renew my argument that there needs to be some kind of contrib archive that is probably separate from mod_python and unsupported in the core distribution. Maybe a wiki or code repository or something to support all the contributions like this.

Re: glue between apache and python logging

2005-10-19 Thread Nick
Nic Ferrier wrote: Nick <[EMAIL PROTECTED]> writes: Nic Ferrier wrote: I just joined this list (at the suggestion of Graham Dumpleton) to try and get you guys to consider adding some glue to connect python >2.2 logging to Apache's logging. I have done this before, and although I haven't che

Re: glue between apache and python logging

2005-10-19 Thread Nic Ferrier
Nick <[EMAIL PROTECTED]> writes: >> Nic Ferrier wrote: >>> >>> I just joined this list (at the suggestion of Graham Dumpleton) to try >>> and get you guys to consider adding some glue to connect python >2.2 >>> logging to Apache's logging. > I have done this before, and although I haven't checked

Re: glue between apache and python logging

2005-10-19 Thread Nick
Jim Gallacher wrote: Nic Ferrier wrote: Hello mod_python developers. I just joined this list (at the suggestion of Graham Dumpleton) to try and get you guys to consider adding some glue to connect python >2.2 logging to Apache's logging. This means adding a small extra source file to the mod_

Re: glue between apache and python logging

2005-10-18 Thread Jim Gallacher
Nic Ferrier wrote: Hello mod_python developers. I just joined this list (at the suggestion of Graham Dumpleton) to try and get you guys to consider adding some glue to connect python >2.2 logging to Apache's logging. This means adding a small extra source file to the mod_python codebase. Here's