Logging

Examples Index

Environment Variables

To enable/disable logging at runtime globally, set the configuration flag DASH_ENABLE_LOGGING as environment variable or in code:

export DASH_ENABLE_LOGGING=off|on

Logging can be activated and deactivated at any time once DASH has been initialized using dash::util::Config. As changes to the DASH configuration have local effect, defining unit-specific configurations is straightforward:

// Enable logging for units 0, 2, 4, ...
if (dash::myid() % 2) {
  dash::util::Config::set("DASH_ENABLE_LOGGING", true);
} else {
  dash::util::Config::set("DASH_ENABLE_LOGGING", false);
}

This is useful to limit log messages to specific aspects in program flow such as communication between specific units:

dash::util::Config::set("DASH_ENABLE_LOGGING", false);

// ...
dash::Shared<int> shared(0);
// ...

if (dash::myid() == 0) {
  dash::util::Config::set("DASH_ENABLE_LOGGING", true);
  shared.set(102);
  dash::util::Config::set("DASH_ENABLE_LOGGING", false);
}
if (dash::myid() == 3) {
  dash::util::Config::set("DASH_ENABLE_LOGGING", true);
  int val = shared.get();
  dash::util::Config::set("DASH_ENABLE_LOGGING", false);
}