mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 10:01:33 +08:00
Minor cleanup
This commit is contained in:
parent
90454a93b2
commit
601bdfb1b4
@ -145,7 +145,7 @@ public:
|
||||
|
||||
// get user token
|
||||
std::vector<unsigned char> buffer(static_cast<size_t>(tusize));
|
||||
if (!GetTokenInformation(current_process_token.token_handle_, TokenUser, (LPVOID)buffer.data(), tusize, &tusize))
|
||||
if (!::GetTokenInformation(current_process_token.token_handle_, TokenUser, (LPVOID)buffer.data(), tusize, &tusize))
|
||||
{
|
||||
SPDLOG_THROW(win32_error("GetTokenInformation"));
|
||||
}
|
||||
@ -207,9 +207,11 @@ private:
|
||||
{
|
||||
if (!hEventLog_)
|
||||
{
|
||||
hEventLog_ = RegisterEventSource(nullptr, source_.c_str());
|
||||
if (!hEventLog_ || hEventLog_ == (HANDLE) ERROR_ACCESS_DENIED)
|
||||
hEventLog_ = ::RegisterEventSource(nullptr, source_.c_str());
|
||||
if (!hEventLog_ || hEventLog_ == (HANDLE)ERROR_ACCESS_DENIED)
|
||||
{
|
||||
SPDLOG_THROW(internal::win32_error("RegisterEventSource"));
|
||||
}
|
||||
}
|
||||
|
||||
return hEventLog_;
|
||||
@ -225,7 +227,7 @@ protected:
|
||||
formatted.push_back('\0');
|
||||
LPCSTR lp_str = static_cast<LPCSTR>(formatted.data());
|
||||
|
||||
bool succeeded = ReportEvent(
|
||||
auto succeeded = ::ReportEvent(
|
||||
event_log_handle(),
|
||||
eventlog::get_event_type(msg),
|
||||
eventlog::get_event_category(msg),
|
||||
@ -237,7 +239,9 @@ protected:
|
||||
nullptr);
|
||||
|
||||
if (!succeeded)
|
||||
{
|
||||
SPDLOG_THROW(win32_error("ReportEvent"));
|
||||
}
|
||||
}
|
||||
|
||||
void flush_() override {}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#if _WIN32
|
||||
|
||||
#include "includes.h"
|
||||
#include "test_sink.h"
|
||||
|
||||
#if _WIN32
|
||||
|
||||
#include "spdlog/sinks/win_eventlog_sink.h"
|
||||
|
||||
static const LPCSTR TEST_SOURCE = "spdlog_test";
|
||||
@ -66,4 +66,4 @@ TEST_CASE("eventlog", "[eventlog]")
|
||||
test_single_print([&test_logger] (std::string const& msg) { test_logger.critical(msg); }, "my critical message", EVENTLOG_ERROR_TYPE);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif //_WIN32
|
Loading…
Reference in New Issue
Block a user