-
Notifications
You must be signed in to change notification settings - Fork 20
Logging
Logging provides a way to track the execution state of GAMS during and after execution.
The log level is used for specifying the level of information desired in the log output. Several values are defined in the Log_Levels enum in C++ at Global_Logger.h and in the LogLevel enum in Java at Logging.java.
| Enum | Value |
|---|---|
| LOG_EMERGENCY | 0 |
| LOG_ALWAYS | 0 |
| LOG_ERROR | 1 |
| LOG_WARNING | 2 |
| LOG_MAJOR | 3 |
| LOG_MINOR | 4 |
| LOG_TRACE | 5 |
| LOG_DETAILED | 6 |
| LOG_MAX | 6 |
Logging is turned on through the logger pointer. In C++, #include "gams/loggers/Global_Logger.h" and
use some variant of one of the following two lines:
gams::loggers::global_logger->set_level (3);
gams::loggers::global_logger->set_level (gams::loggers::LOG_MAJOR);
In Java, import com.gams.utility.Logging and use some variant of one of the following two lines:
Logging.setLevel(3);
Logging.setLevel(Logging.LogLevel.LOG_MAJOR);
By default, all logging goes to standard error. On Android, the output is redirected to logcat.
#include "gams/loggers/Global_Logger.h"
The logging system can be used by including the Global_Logger file.
madara_logger_ptr_log (gams::loggers::global_logger.get (),
gams::loggers::LOG_ERROR,
"gams::algorithms::area_coverage::Uniform_Random_Edge_Coverage_Factory::create:" \
" error creating algorithm\n");
This example from Uniform_Random_Edge_Coverage.cpp:188 helps debugging algorithm creation. The first argument is the pointer to the logger to use. The second argument is the level for the logging statement. If the log level is greater than the level used here, then the output will be performed, otherwise it is ignored. The third argument is the log information to output.
madara_logger_ptr_log (gams::loggers::global_logger.get (),
gams::loggers::LOG_DETAILED,
"gams::utility::Search_Area::get_convex_hull:" \
" point %u is \"%f,%f,%f\"\n", idx++,
regions_[i].vertices[j].x, regions_[i].vertices[j].y, regions_[i].vertices[j].z);
There is also an option to use printf style output to get more detailed runtime analysis.