Skip to content

Commit 084a44d

Browse files
committed
If error logs are being used, recoverable errors will also be printed to cerr
1 parent 9d4507a commit 084a44d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/util/error.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ namespace chimbuko{
1414

1515
void ErrorWriter::recoverable(const std::string &msg, const std::string &func, const std::string &file, const unsigned long line){
1616
std::lock_guard<std::mutex> _(m_mutex);
17-
*m_ostream << getErrStr("recoverable", msg, func, file, line);
17+
std::string err = getErrStr("recoverable", msg, func, file, line);
18+
*m_ostream << err;
19+
m_ostream->flush();
20+
if(m_ostream != &std::cerr){
21+
std::cerr << err;
22+
std::cerr.flush();
23+
}
1824
}
1925
void ErrorWriter::fatal(const std::string &msg, const std::string &func, const std::string &file, const unsigned long line){
2026
std::string err = getErrStr("FATAL", msg, func, file, line);
@@ -42,6 +48,7 @@ namespace chimbuko{
4248
void ErrorWriter::flushError(const std::exception &e){
4349
std::lock_guard<std::mutex> _(m_mutex);
4450
(*m_ostream) << e.what();
51+
m_ostream->flush();
4552
}
4653

4754
ErrorWriter & Error(){

0 commit comments

Comments
 (0)