#2844 closed enhancement (fixed)
[PATCH] Project identificator in Trac's log
Reported by: | Owned by: | Christian Boos | |
---|---|---|---|
Priority: | normal | Milestone: | 0.10.4 |
Component: | general | Version: | 0.10.3 |
Severity: | normal | Keywords: | logging |
Cc: | mzizka@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
It would be useful if the trac log contained a string identifying project. When directing log to syslog this would make it possible to distinguish log entries for different projects.
Attachments (2)
Change History (12)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
Cc: | added |
---|---|
Milestone: | → 0.10.4 |
Summary: | Project identificator in Trac's log → [PATCH] Project identificator in Trac's log |
Version: | 0.9.3 → 0.10.3 |
I attached a simple patch against 10.3 that adds the (absolute) project path to the log output. Works for me, but feel free to use another format.
I'm taking the liberty of setting milestone to 0.10.4 but again, change this to whatever is most convenient.
comment:4 by , 18 years ago
Replying to cboos:
It's OK for me.
Not to me.
This feature should be optional: when a log file contains the traces of a single project, this addition would add useless information, make the log file harder to read, and make it grow faster.
I think a better approach - in order to avoid several options to define the log format - would be to use a customizable string as Apache does. Define some magic characters that would be replaced with the actual content, such as:
%P
: project name%p
: project path%t
: time%s
: the original log message- …
and a single log format option:
[log] format = [%t] Trac %p/%P %s
follow-up: 6 comment:5 by , 18 years ago
Status: | new → assigned |
---|
OK, what about that log_format-r4543.diff?
I prefer to use long names in the log format, instead of cryptic one-letter codes: not only is that clearer to someone reading the trac.ini file, but it allows to use the full range of keys supported by the logger, among which I find the "thread" one to be quite useful…
If you have an idea about how to circumvent the interpretation of "%(…)s" strings by the ConfigParser better than using "$(…)s" instead, let me know.
by , 18 years ago
Attachment: | log_format-r4543.diff added |
---|
Configurable format for the log messages.
comment:6 by , 18 years ago
Replying to cboos:
OK, what about that log_format-r4543.diff?
I have not tried it, but the description seems great, thanks. Ok with the long name syntax.
I'm not sure to understand the choice of logid
for the full environment path though.
comment:7 by , 18 years ago
Well, simply there was already an argument called logid
in the logger_factory
function, used to provide an unique identifier for the logger. That happens to be the path name when called from env.py.
Makes me think that I should balance the code between env.py and log.py a bit differently…
comment:8 by , 18 years ago
Nice work. This way the format doesn't change by default, and people who use scripts to parse the log will not have to change anything.
comment:9 by , 18 years ago
Keywords: | logging added |
---|
comment:10 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(and now forgot to close it… need a break ;) )
#3657 has been marked as a duplicate.