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
This page took 0.044405 seconds and 5 git commands to generate.