[R] Use R's error stream for printing warnings (#9965)

This commit is contained in:
david-cortes 2024-01-08 20:43:21 +01:00 committed by GitHub
parent b3eb5d0945
commit 7ff6d44efa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -17,8 +17,12 @@ namespace xgboost {
ConsoleLogger::~ConsoleLogger() {
if (cur_verbosity_ == LogVerbosity::kIgnore ||
cur_verbosity_ <= GlobalVerbosity()) {
if (cur_verbosity_ == LogVerbosity::kWarning) {
REprintf("%s\n", log_stream_.str().c_str());
} else {
dmlc::CustomLogMessage::Log(log_stream_.str());
}
}
}
TrackerLogger::~TrackerLogger() {
dmlc::CustomLogMessage::Log(log_stream_.str());

View File

@ -83,7 +83,8 @@ test_that("parameter validation works", {
bar = "foo"
)
output <- capture.output(
xgb.train(params = params, data = dtrain, nrounds = nrounds)
xgb.train(params = params, data = dtrain, nrounds = nrounds),
type = "message"
)
print(output)
}