xgboost/src/logging.cc
Morten Hustveit 8b9d9669bb Have ConsoleLogger log to stderr instead of stdout (#1714)
On Unix systems, it's common for programs to read their input from stdin, and
write their output to stdout.  Messages should be written to stderr, where they
won't corrupt a program's output, and where they can be seen by the user even
if the output is being redirected.

This is mostly a problem when XGBoost is being used from Python or from another
program.
2016-11-10 12:39:52 -08:00

24 lines
470 B
C++

/*!
* Copyright 2015 by Contributors
* \file logging.cc
* \brief Implementation of loggers.
* \author Tianqi Chen
*/
#include <xgboost/logging.h>
#include <iostream>
#include "./common/sync.h"
namespace xgboost {
#if XGBOOST_CUSTOMIZE_LOGGER == 0
ConsoleLogger::~ConsoleLogger() {
std::cerr << log_stream_.str() << std::endl;
}
TrackerLogger::~TrackerLogger() {
log_stream_ << '\n';
rabit::TrackerPrint(log_stream_.str());
}
#endif
} // namespace xgboost