From d8701890b2a6625f708dcdf79fcd795e0b3e920c Mon Sep 17 00:00:00 2001 From: bandana2004 Date: Sun, 9 Feb 2020 18:12:54 +0200 Subject: [PATCH] cleanup win_eventlog_sink --- include/spdlog/sinks/win_eventlog_sink.h | 39 ++++++------------------ 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/include/spdlog/sinks/win_eventlog_sink.h b/include/spdlog/sinks/win_eventlog_sink.h index b2ec3dbd..28716fdd 100644 --- a/include/spdlog/sinks/win_eventlog_sink.h +++ b/include/spdlog/sinks/win_eventlog_sink.h @@ -60,27 +60,6 @@ struct utils { report(message.c_str()); } - - /** Runs a func and reports an exception to stderr if any */ - template - static Result report_exceptions(std::function func, Result defaultValue) - { - try - { - return func(); - } - catch (std::exception const& e) - { - report(e.what()); - return defaultValue; - } - } - - /** Runs a func and reports an exception to stderr if any */ - static void report_exceptions(std::function func) - { - report_exceptions([&func] () { func(); return 0; }, 0); - } }; /** Windows error */ @@ -279,20 +258,22 @@ public: : source_(source) { using namespace internal; - - utils::report_exceptions([this] () { + try + { current_user_sid_ = sid_t::get_current_user_sid(); - }); + } + catch (std::exception const& e) + { + utils::report(e.what()); + } } ~win_eventlog_sink() { using namespace internal; - utils::report_exceptions([this]() - { - if (hEventLog_ && !DeregisterEventSource(hEventLog_)) - utils::report(win32_error::format("DeregisterEventSource")); - }); + + if (hEventLog_ && !DeregisterEventSource(hEventLog_)) + utils::report(win32_error::format("DeregisterEventSource")); } /**