-
Notifications
You must be signed in to change notification settings - Fork 20
Debugging (C)
C++ Guides: GAMS Primer | Creating Algorithms | Creating Platforms
GAMS provides many debugging features. The most powerful of these is a configurable logging system based on the MADARA Logger. Additionally, GAMS exposes a Knowledge_Base and special status variables and containers that track interactions between algorithms and platforms.
Logging is the practice of printing messages to an output sink, usually to help with tracing execution of software. GAMS supports logging internal messages to any combination of terminal windows, system loggers, and files.
Targets for GAMS logging are set in the same way that they are set for any MADARA Logger.
All MADARA loggers start with an output target of stderr. To add or remove targets, you can use any of the functions on the gams::loggers::global_logger instance.
// Clear all logging targets (this would remove terminal output as well)
gams::loggers::global_logger->clear ();
// Add a file output of "some_file.txt" to the logger
gams::loggers::global_logger->add_file ("some_file.txt");
// Add the terminal back to logging targets
gams::loggers::global_logger->add_term ();MADARA loggers allow you to set a logging level that generally goes from high priority (0) to low priority (6+). This is an inverted scale of priority that has helpful enums already setup in the gams::loggers namespace. The GAMS levels in gams::loggers are the following:
LOG_EMERGENCY // (0) use this log level if someone is an emergency
LOG_ALWAYS // (0) the same log level as EMERGENCY
LOG_ERROR // (1) print error information. This is the default log level.
LOG_WARNING // (2) print warning information
LOG_MAJOR // (3) major event information
LOG_MINOR // (4) minor event information
LOG_TRACE // (5) trace information through functions, rarely used
LOG_DETAILED // (6) detailed information about execution. The most verbose logging level in GAMS