Skip to content

logging

Mirror Bot edited this page Aug 31, 2026 · 2 revisions

title: Logging

back to home

Most classes write out debug messages if the necessary parameters are given, e.g. Debug mode.

Activating logging

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.

Defining a LOG stream

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

Using the same debug stream in different classes

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.

Important Notice

⚠️ Maybe Outdated!: Spend some time if you feel like it!

  • "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.

Postprocess Ouptut

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.txt

Note, that by -i the file itself is replaced. With -e the new content is written to stdout

Clone this wiki locally