Bug 384057 - [PATCH] TCF agent logging system does not cope well with daemon mode
Summary: [PATCH] TCF agent logging system does not cope well with daemon mode
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.1   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-02 11:16 EDT by Vincent Rubiolo CLA
Modified: 2013-06-05 04:40 EDT (History)
0 users

See Also:


Attachments
Proposed fix (2.33 KB, patch)
2012-07-02 11:16 EDT, Vincent Rubiolo CLA
no flags Details | Diff
Better patch (1.85 KB, patch)
2012-07-02 12:36 EDT, Vincent Rubiolo CLA
no flags Details | Diff
Version with fewer changes and agent updated help text (2.23 KB, patch)
2012-07-02 12:39 EDT, Vincent Rubiolo CLA
mober.at+eclipse: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Rubiolo CLA 2012-07-02 11:16:13 EDT
Build Identifier: 

When the TCF agent runs in daemon mode, its associated output is sent to the system logger. This becomes problematic when the user asks for logging to be enabled using the -L /path/to/log/file option. In this case, the agent will indeed enable logging but the user log file will remain empty.

The attached patch (on today's HEAD) fixes this with the following behavior:
1. The command line no more accepts both -d and -L options at the same time. An error message is shown instead.
2. The tracing infrastructure now also checks whether daemon mode is enabled to know when to output trace messages.

I am not sure whether point #2 above has performance issues (two tests instead of one). Other possible approaches :
a. setting log_name to '-' (stderr). This meant #defining a constant for the associated option (currently only open_log_file() knows about it).
b. setting log_file to stderr but this modifies the variable from another source file. It is indeed a global but I am not sure whether it is the best way to do it.

A limitation of the current patch is that since we cannot use -L w/ -d, the logging level has to be set by means of -l.

I welcome your guidance on these two aspects. I can submit another patch if needed.

In addition, I have modified the small agent help text (see #384049 for more info about it) to clearly state that messages are sent to the system logger when in daemon mode.

Reproducible: Always

Steps to Reproduce:
1. Clone the agent git repo and build it.
2. On a Unix system, run the agent in daemon mode with both '-d' and '-L foo' specified.
3. Note how 'foo' remains empty.
Comment 1 Vincent Rubiolo CLA 2012-07-02 11:16:34 EDT
Created attachment 218171 [details]
Proposed fix
Comment 2 Vincent Rubiolo CLA 2012-07-02 12:36:38 EDT
Created attachment 218176 [details]
Better patch

This new patch touches less code and only adds an error when the user attempts to log to something else than stderr when in daemon mode.

This version is better performance-wise (no additional handling in trace() macro) and allows to still enable logging by means of -L- (i.e default log level continues to work).
Comment 3 Vincent Rubiolo CLA 2012-07-02 12:39:42 EDT
Created attachment 218177 [details]
Version with fewer changes and agent updated help text

This version adds the small update to the agent help text.
Comment 4 Eugene Tarassov CLA 2012-07-03 19:11:02 EDT
The last version of the patch looks very good.
Committed.
Thanks!
Comment 5 Martin Oberhuber CLA 2013-05-24 18:47:09 EDT
Comment on attachment 218177 [details]
Version with fewer changes and agent updated help text

iplog- since git has the author:

http://git.eclipse.org/c/tcf/org.eclipse.tcf.agent.git/commit/?id=219157000832ba8201a6043abe79591480aa0eda