Add CMake flag to log C API invocations, to aid debugging (#5925)

* Add CMake flag to log C API invocations, to aid debugging

* Remove unnecessary parentheses
This commit is contained in:
Philip Hyunsu Cho
2020-07-30 19:24:28 -07:00
committed by GitHub
parent 3b88bc948f
commit 3fcfaad577
6 changed files with 18 additions and 1 deletions

View File

@@ -10,7 +10,12 @@
#include <dmlc/logging.h>
/*! \brief macro to guard beginning and end section of all functions */
#ifdef LOG_CAPI_INVOCATION
#define API_BEGIN() \
LOG(CONSOLE) << "[XGBoost C API invocation] " << __PRETTY_FUNCTION__; try {
#else // LOG_CAPI_INVOCATION
#define API_BEGIN() try {
#endif // LOG_CAPI_INVOCATION
/*! \brief every function starts with API_BEGIN();
and finishes with API_END() or API_END_HANDLE_ERROR */
#define API_END() } catch(dmlc::Error &_except_) { return XGBAPIHandleException(_except_); } return 0; // NOLINT(*)