diff --git a/libnecrolog/necrolog.cpp b/libnecrolog/necrolog.cpp index 73cf585..55e9006 100644 --- a/libnecrolog/necrolog.cpp +++ b/libnecrolog/necrolog.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #ifdef __unix #include @@ -100,9 +101,7 @@ bool NecroLog::shouldLog(Level level, const LogContext &context) NecroLog::MessageHandler NecroLog::setMessageHandler(NecroLog::MessageHandler h) { - MessageHandler ret = globalOptions().messageHandler; - globalOptions().messageHandler = h; - return ret; + return std::exchange(globalOptions().messageHandler, h); } namespace {