Repository navigation
logging
back to home
Most classes write out debug messages if the necessary parameters are given, e.g. Debug mode.
To activate the logging, debug has to be activated (cfs has to be compiled with DEBUG=ON).
Then cfs has to be run using the -l log.xml option.
What log-output is written where is specified in the XML file.
An example can be found in share/xml/config/log.xml.
Just set the name
DEFINE_LOG(algSys, "algSys")
and then use it to output information
LOG_DBG(algSys) << "Creating linear system";
You can use several debug levels, i.e. LOG_<XXX> where, described in log.xml.
Examples above taken from https://github.com/openCFS/cfs/tree/a905dbbe6676da04b69114a8a6494b54a306c625/source/OLAS/algsys/AlgebraicSys.cc#L43
It is not necessary to have a debug stream for every class, there can be only one DEFINE_LOG(assemble, "assemble") but the DECLARE_LOG(assemble) can be in multiple files.
- "DEFINE_LOG(foo1, "foo2")" can not set the name identical to the actual class name, otherwise the compiler will complain if a log call is made.
- The log file will not through any errors if the name of the desired class is misspelled or does not exist. The missing log file after executing cfs will give away that something went wrong.
It is often helpful to compare the logs of different cfs (e.g. to trace a bug). Then, by a change in the line numbers a diff (kompare) finds too many differences. The header (stream name and line number, e.g. "[scpip_base] 336:" can be removed by the following command:
sed -i 's/^[^:]*: //' log.txtNote, that by -i the file itself is replaced. With -e the new content is written to stdout