Skip to content

Commit 2f24138

Browse files
committed
logger: don't crash on failing to print to stdout
1 parent 9f8e158 commit 2f24138

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/cli/Logger.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,13 @@ void CLoggerImpl::log(eLogLevel level, const std::string_view& msg, const std::s
131131
logMsg += "]: ";
132132
logMsg += msg;
133133

134-
if (m_stdoutEnabled)
135-
std::println("{}{}", m_colorEnabled ? logPrefixColor : logPrefix, logMsg);
134+
if (m_stdoutEnabled) {
135+
try {
136+
std::println("{}{}", m_colorEnabled ? logPrefixColor : logPrefix, logMsg);
137+
} catch (std::exception& e) {
138+
; // this could be e.g. stdout closed
139+
}
140+
}
136141
if (m_fileEnabled)
137142
m_logOfs << logPrefix << logMsg << "\n";
138143

0 commit comments

Comments
 (0)