Edgewall Software
Modify

Opened 16 years ago

Closed 15 years ago

Last modified 8 years ago

#2844 closed enhancement (fixed)

[PATCH] Project identificator in Trac's log

Reported by: tomas.ruden@… 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)

log_project_path.diff (559 bytes ) - added by maz <mzizka@…> 15 years ago.
Add project path to log output
log_format-r4543.diff (4.2 KB ) - added by Christian Boos 15 years ago.
Configurable format for the log messages.

Download all attachments as: .zip

Change History (12)

comment:1 by Matthew Good, 15 years ago

#3657 has been marked as a duplicate.

by maz <mzizka@…>, 15 years ago

Attachment: log_project_path.diff added

Add project path to log output

comment:2 by maz <mzizka@…>, 15 years ago

Cc: mzizka@… added
Milestone: 0.10.4
Summary: Project identificator in Trac's log[PATCH] Project identificator in Trac's log
Version: 0.9.30.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:3 by Christian Boos, 15 years ago

Owner: changed from Jonas Borgström to Christian Boos

It's OK for me.

in reply to:  3 comment:4 by Emmanuel Blot, 15 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

comment:5 by Christian Boos, 15 years ago

Status: newassigned

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 Christian Boos, 15 years ago

Attachment: log_format-r4543.diff added

Configurable format for the log messages.

in reply to:  5 comment:6 by Emmanuel Blot, 15 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 Christian Boos, 15 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 maz <mzizka@…>, 15 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 Christian Boos, 15 years ago

Keywords: logging added

Improved patch applied in r4546 (trunk) and r4547 (0.10-stable).

Oops, sorry maz, just realized I copy/pasted your name and your e-mail in the commit message…

comment:10 by Christian Boos, 15 years ago

Resolution: fixed
Status: assignedclosed

(and now forgot to close it… need a break ;) )

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.