pid-log
3.1.8
|
pid-log package provides a little API to manage logs in a clean and really configurable way. It is based on Boost.Log meta logging system. Its usage is completely bound to the use of PID system.
The pid-log
package implement the runtime logging facility of PID. By logging we mean generating messages that inform about the state of a running program. These messages can be read from standard outputs or files and may be useful to notify some tools of interesting events, to provide debug information to developpers, or traces of program execution.
pid-log
intend to provide a powerful but easy to configure logging tool for developpers with features:
Basically, to use logging system of PID, a package (let's call ot my-package
) needs to depend on the pid-log
package. In root CMakeLists.txt
of the package:
Then for a component my-component
that needs to generate log traces, in the adequate CMakeLists.txt
:
The LOGGABLE
argument tells PID to generate a specific header file (in the current example pid/log/my-package_my-component.h
) that is included in public headers of my-component
.
Then in my-component
source code:
The pid_log
object is used to access logging system: it is used as a stream operator to generate log trace, with first input being the severity (e.g. pid::error
). The log trace is generated when pid::flush
is inserted in this stream, allowing trace construction on multiple lines of code if needed.
Now let's suppose that component my-application
depends on my-component
, it can control log traces generated by the library
In this example only traces generated with pid::error
or pid::critical
modifiers will be printed to standard output. The PID_LOGGER
macro gives you the access to the global logger object. If the logger is not configured explicilty of if the program use the "pid_log/default_logs.yaml"
then everything except debug traces will be printed to standard output. There are a few base configurations for the logger but you can define new ones (writing to specific file, standard error, filtering traces coming from specific libraries, etc.).
With default configruation, output in terminal would look like (no debug trace printed):
Otherwise, you may want to deactivate all logs:
And nothing will be printed in console.
There are a few things to learn to use all the power of pid-log
system, please read the online tutorial for more details.
The license that applies to the whole package content is CeCILL-C. Please look at the license.txt file at the root of this repository for more details.
pid-log has been developed by following authors:
Please contact Robin Passama (robin) - CNRS/LIRMM for more information or questions. .pas sama@ lirm m.fr