mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-20 04:40:08 +01:00
logger: don't crash on failing to print to stdout
This commit is contained in:
parent
9f8e158dbd
commit
2f2413801b
1 changed files with 7 additions and 2 deletions
|
|
@ -131,8 +131,13 @@ void CLoggerImpl::log(eLogLevel level, const std::string_view& msg, const std::s
|
||||||
logMsg += "]: ";
|
logMsg += "]: ";
|
||||||
logMsg += msg;
|
logMsg += msg;
|
||||||
|
|
||||||
if (m_stdoutEnabled)
|
if (m_stdoutEnabled) {
|
||||||
std::println("{}{}", m_colorEnabled ? logPrefixColor : logPrefix, logMsg);
|
try {
|
||||||
|
std::println("{}{}", m_colorEnabled ? logPrefixColor : logPrefix, logMsg);
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
; // this could be e.g. stdout closed
|
||||||
|
}
|
||||||
|
}
|
||||||
if (m_fileEnabled)
|
if (m_fileEnabled)
|
||||||
m_logOfs << logPrefix << logMsg << "\n";
|
m_logOfs << logPrefix << logMsg << "\n";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue