Ticket #824 (defect)
Opened 4 months ago
Last modified 4 months ago
_cplogging.LogManager.access method not handling unicode in login names properly
Status: closed (fixed)
| Reported by: | guest | Assigned to: | fumanchu |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1 |
| Component: | CherryPy code | Keywords: | logging |
| Cc: | ps@brainwavelive.com |
The tmpl being written to the access log is not handling unicode strings in
getattr(request, "login", None) or "-"
The code should be:
tmpl = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'
u = getattr(request, "login", None) or "-"
u = u.encode("utf-8") if isinstance(u, unicode) else u
s = tmpl % {'h': remote.name or remote.ip,
'l': '-',
'u': u,
't': self.time(),
'r': request.request_line,
's': response.status.split(" ", 1)[0],
'b': outheaders.get('Content-Length', '') or "-",
'f': inheaders.get('referer', ''),
'a': inheaders.get('user-agent', ''),
}
try:
self.access_log.log(logging.INFO, s)
except:
self(traceback=True)
OR.... you can do this in a more complete manner by making tmpl unicode and converting everything to unicode and encoding at the end....
Change History
06/22/08 16:12:50: Modified by fumanchu
- status changed from new to closed.
- resolution set to fixed.
- milestone set to 3.1.


Way fixed in [1984].