tools.log_headers broken?

26 views
Skip to first unread message

Shawn

unread,
Jun 24, 2008, 10:18:53 PM6/24/08
to cherrypy-users
It seems as if tools.log_headers only works for error conditions.

I'm doing this for my app:

cherrypy.config.update({
"tools.log_headers.on": True
})

However, I'm not seeing headers going to the log for every request.

A further glance reveals that it is only hooked to
before_error_response:

_d.log_headers = Tool('before_error_response',
cptools.log_request_headers)

Changing _cptools.py to:

_d.log_headers = Tool('on_start_resource',
cptools.log_request_headers)

...seems to do the trick, but this seems wrong.

http://www.cherrypy.org/wiki/BuiltinTools says:

tools.log_headers
When enabled, the headers of every request will be sent to CherryPy's
log.

Have I missed something?

-Shawn

Robert Brewer

unread,
Jun 25, 2008, 12:15:59 PM6/25/08
to cherryp...@googlegroups.com

All I can say is, "it's always been on-error only". I've updated the
wiki page. You're certainly welcome to run the log_request_headers
function at a different hookpoint--this is one of the strengths of the
hook and tool system, not wrong at all! I'd just recommend you make a
new Tool for yourself instead of monkeypatching:

cherrypy.tools.log_all_headers = cherrypy.Tool(
'on_start_resource', cptools.log_request_headers)

Robert Brewer
fuma...@aminus.org

Shawn

unread,
Jun 25, 2008, 3:49:40 PM6/25/08
to cherrypy-users
Yes, I already ended up using a custom tool to do this.

The documentation just didn't jive with the code.

Thanks,
-Shawn
Reply all
Reply to author
Forward
0 new messages