Edgewall Software

Ticket #2844 (closed enhancement: fixed)

Opened 3 years ago

Last modified 23 months ago

[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@…

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

log_project_path.diff (0.5 KB) - added by maz <mzizka@…> 23 months ago.
Add project path to log output
log_format-r4543.diff (4.2 KB) - added by cboos 23 months ago.
Configurable format for the log messages.

Change History

  Changed 2 years ago by mgood

#3657 has been marked as a duplicate.

Changed 23 months ago by maz <mzizka@…>

Add project path to log output

  Changed 23 months ago by maz <mzizka@…>

  • cc mzizka@… added
  • 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
  • milestone set to 0.10.4

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.

follow-up: ↓ 4   Changed 23 months ago by cboos

  • owner changed from jonas to cboos

It's OK for me.

in reply to: ↑ 3   Changed 23 months 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

follow-up: ↓ 6   Changed 23 months 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 23 months ago by cboos

Configurable format for the log messages.

in reply to: ↑ 5   Changed 23 months 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.

  Changed 23 months 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...

  Changed 23 months 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.

  Changed 23 months 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...

  Changed 23 months ago by cboos

  • status changed from assigned to closed
  • resolution set to fixed

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

Add/Change #2844 ([PATCH] Project identificator in Trac's log)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from cboos. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.