common: Add JUL logging to TraceCompass
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Tue, 14 Jun 2016 15:19:06 +0000 (11:19 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Wed, 29 Jun 2016 20:09:22 +0000 (16:09 -0400)
commit47c79d9566541f5a30244b5d7569a8a893859d59
tree580235541a719545ff8117014086bb08dc9994ea
parent346ede8436acaf1e0fed78dcf9d1270dfbee13ec
common: Add JUL logging to TraceCompass

Logging allows to add tracepoints at various places in the code, and at runtime
enable log handlers for specific components to produce log files that can then
be analyzed by various tools... like Trace Compass!

This patch is a first suggestion for adding logging facility to TraceCompass.
Here is the suggested approach:

* Logging has a small overhead, so they should have a negligible performance
impact performance if they are not overly used.

* Logging must be explicitly enabled at runtime by setting a parameter to true:
-Dorg.eclipse.tracecompass.logging=true in the vmargs

* Each class should have their own logger, using the class's full name
(canonical name). It is thus easy to filter which classes to log using per
logger name. For example, logging org.eclipse.tracecompass.tmf will log all
loggers that start with o.e.t.tmf.*

* Abstract classes should use their concrete class's name, to match the log
statements to their concrete component.

* The TraceCompassLog class contains a wrapper methods to retrieve loggers.
Calling it makes sure that the main logger's level has been set and the default
values set by java (info level with ConsoleLogger) are not used.

* What is non-negligible in logging is often the message being logged. To be
meaningful, the message will often add parameters concatenated to a string
and that can be very costly. Messages should be lazily constructed using
the logging statements taking Supplier<String> in parameter. For example:

LOGGER.log(() -> "My msg " + param1 + " " + param2);

* Log levels, handlers, etc can be controlled via a configuration file set in
the vmargs: -Djava.util.logging.config.file=/path/to/logger.properties. An
example logger.properties file can be found here:
https://wiki.eclipse.org/Swordfish_Documentation:_Turning_On_Logging

* To help logging trace parsing, the log strings should have the following
format: [EventName:MayContainSemiColon] paramName1=param1, paramName2=param2

Change-Id: Ia6cde4256799705a9f13c71b70576eb09cc3d427
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/71819
Reviewed-by: Hudson CI
common/org.eclipse.tracecompass.common.core/META-INF/MANIFEST.MF
common/org.eclipse.tracecompass.common.core/annotations/java/util/logging/Logger.eea [new file with mode: 0644]
common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/log/TraceCompassLog.java [new file with mode: 0644]
common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/log/package-info.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractStateSystemTimeGraphView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java
This page took 0.026236 seconds and 5 git commands to generate.