Edgewall Software
Modify

Opened 9 years ago

Closed 9 years ago

Last modified 2 years ago

#2844 closed enhancement (fixed)

[PATCH] Project identificator in Trac's log

Reported by: tomas.ruden@… Owned by: cboos
Priority: normal Milestone: 0.10.4
Component: general Version: 0.10.3
Severity: normal Keywords: logging
Cc: mzizka@…
Release Notes:
API 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@…> 9 years ago.
Add project path to log output
log_format-r4543.diff (4.2 KB) - added by cboos 9 years ago.
Configurable format for the log messages.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 9 years ago by mgood

#3657 has been marked as a duplicate.

Changed 9 years ago by maz <mzizka@…>

Add project path to log output

comment:2 Changed 9 years ago by maz <mzizka@…>

  • Cc mzizka@… added
  • Milestone set to 0.10.4
  • Summary changed from Project identificator in Trac's log to [PATCH] Project identificator in Trac's log
  • Version changed from 0.9.3 to 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:3 follow-up: Changed 9 years ago by cboos

  • Owner changed from jonas to cboos

It's OK for me.

comment:4 in reply to: ↑ 3 Changed 9 years ago by eblot

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 follow-up: Changed 9 years ago by cboos

  • Status changed from new to 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.

Changed 9 years ago by cboos

Configurable format for the log messages.

comment:6 in reply to: ↑ 5 Changed 9 years ago by eblot

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 Changed 9 years ago by cboos

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 Changed 9 years ago by maz <mzizka@…>

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 Changed 9 years ago by cboos

  • 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 Changed 9 years ago by cboos

  • Resolution set to fixed
  • Status changed from assigned to closed

(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 cboos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from cboos 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.