Unify logging facilities. (#3982)
* Unify logging facilities. * Enhance `ConsoleLogger` to handle different verbosity. * Override macros from `dmlc`. * Don't use specialized gamma when building with GPU. * Remove verbosity cache in monitor. * Test monitor. * Deprecate `silent`. * Fix doc and messages. * Fix python test. * Fix silent tests.
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include <thrust/device_vector.h>
|
||||
#include <xgboost/base.h>
|
||||
#include "../../../src/common/device_helpers.cuh"
|
||||
#include "../../../src/common/timer.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
struct Shard { int id; };
|
||||
|
||||
32
tests/cpp/common/test_monitor.cc
Normal file
32
tests/cpp/common/test_monitor.cc
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/logging.h>
|
||||
#include <string>
|
||||
#include "../../../src/common/timer.h"
|
||||
|
||||
namespace xgboost {
|
||||
namespace common {
|
||||
TEST(Monitor, Basic) {
|
||||
auto run_monitor =
|
||||
[]() {
|
||||
Monitor monitor_;
|
||||
monitor_.Init("Monitor test");
|
||||
monitor_.Start("basic");
|
||||
monitor_.Stop("basic");
|
||||
};
|
||||
|
||||
std::map<std::string, std::string> args = {std::make_pair("verbosity", "3")};
|
||||
ConsoleLogger::Configure(args.cbegin(), args.cend());
|
||||
testing::internal::CaptureStderr();
|
||||
run_monitor();
|
||||
std::string output = testing::internal::GetCapturedStderr();
|
||||
ASSERT_NE(output.find("Monitor"), std::string::npos);
|
||||
|
||||
args = {std::make_pair("verbosity", "2")};
|
||||
ConsoleLogger::Configure(args.cbegin(), args.cend());
|
||||
testing::internal::CaptureStderr();
|
||||
run_monitor();
|
||||
output = testing::internal::GetCapturedStderr();
|
||||
ASSERT_EQ(output.find("Monitor"), std::string::npos);
|
||||
}
|
||||
} // namespace common
|
||||
} // namespace xgboost
|
||||
Reference in New Issue
Block a user