One of the nice things -- that took me a while to realize -- is that you're working in a single treaded environment in mod_python. One that's getting reused over and over and over, but while you got it you got it.
I've added an extension to bm_log to allow tracking of all logging related to creating a page. You use it as follows:
- call Log.PageStart
- do stuff
- call Log.PageEnd
In fact, you don't even need to do this, since PageStart and PageEnd are always called in bm_page in the right places, so all you're responsible for is the "do stuff" part.
Now what does this do? Simple:
- PageStart assigns a unique (random) id the logging function and records the start time
- all subsequent calls to Log print the random id and the delta from the start time
- PageEnd clears the unique id

