Skip to content

Commit

Permalink
[R] Use R's error stream for printing warnings (#9965)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cortes committed Jan 8, 2024
1 parent b3eb5d0 commit 7ff6d44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion R-package/src/xgboost_custom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ namespace xgboost {
ConsoleLogger::~ConsoleLogger() {
if (cur_verbosity_ == LogVerbosity::kIgnore ||
cur_verbosity_ <= GlobalVerbosity()) {
dmlc::CustomLogMessage::Log(log_stream_.str());
if (cur_verbosity_ == LogVerbosity::kWarning) {
REprintf("%s\n", log_stream_.str().c_str());
} else {
dmlc::CustomLogMessage::Log(log_stream_.str());
}
}
}
TrackerLogger::~TrackerLogger() {
Expand Down
3 changes: 2 additions & 1 deletion R-package/tests/testthat/test_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 7ff6d44

Please sign in to comment.