Skip to content
Brad Aagaard edited this page Jun 14, 2019 · 1 revision

Coding hints

Adding debugging output

When debugging a C++ object, it is often helpful to temporarily turn on output of various information. Instead of temporarily adding special debugging output or commenting it out, a more robust approach is to use the Pyre journal object to control output.

Here is an example of how this is done to control output of the layout of the solution field within the Problem object.

journal::debug_t debug(PyreComponent::getName());
if (debug.state()) {
    debug << journal::at(__HERE__)
          << "Component '"<<PyreComponent::getIdentifier()<<"': viewing solution field." << journal::endl;
    _solution->view("Problem solution field", pylith::topology::Field::VIEW_LAYOUT);
} // if

Note: This approach should not be used within large for loops, because it introduces overhead in creating the journal::debug_t object.