Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
211478e1
Commit
211478e1
authored
Dec 13, 2020
by
Amir Alperin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert message back to wchar
parent
5e33a7e5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
25 deletions
+13
-25
include/spdlog/sinks/win_eventlog_sink.h
include/spdlog/sinks/win_eventlog_sink.h
+13
-25
No files found.
include/spdlog/sinks/win_eventlog_sink.h
View file @
211478e1
...
...
@@ -39,6 +39,8 @@ Windows Registry Editor Version 5.00
#include <mutex>
#include <string>
#include <vector>
#include <locale>
#include <codecvt>
namespace
spdlog
{
namespace
sinks
{
...
...
@@ -55,8 +57,11 @@ struct win32_error : public spdlog_ex
{
std
::
string
system_message
;
auto
fFormatResult
=
[
&
system_message
](
bool
format_message_succeeded
,
void
*
format_message_result
)
{
LPSTR
format_message_result
{};
auto
format_message_succeeded
=
::
FormatMessageA
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
nullptr
,
error_code
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
(
LPSTR
)
&
format_message_result
,
0
,
nullptr
);
if
(
format_message_succeeded
&&
format_message_result
)
{
system_message
=
fmt
::
format
(
" ({})"
,
format_message_result
);
...
...
@@ -66,23 +71,6 @@ struct win32_error : public spdlog_ex
{
LocalFree
((
HLOCAL
)
format_message_result
);
}
};
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
LPWSTR
format_message_result
{};
auto
format_message_succeeded
=
::
FormatMessageW
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
nullptr
,
error_code
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
(
LPWSTR
)
&
format_message_result
,
0
,
nullptr
);
fFormatResult
(
format_message_succeeded
,
format_message_result
);
#else
LPSTR
format_message_result
{};
auto
format_message_succeeded
=
::
FormatMessageA
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
nullptr
,
error_code
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
(
LPSTR
)
&
format_message_result
,
0
,
nullptr
);
fFormatResult
(
format_message_succeeded
,
format_message_result
);
#endif
return
fmt
::
format
(
"{}: {}{}"
,
user_message
,
error_code
,
system_message
);
}
...
...
@@ -238,10 +226,10 @@ protected:
formatted
.
push_back
(
'\0'
);
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
LPCWSTR
lp_str
=
reinterpret_cast
<
LPCWSTR
>
(
formatted
.
data
());
auto
buf
=
std
::
wstring_convert
<
std
::
codecvt_utf8
<
wchar_t
>>
().
from_bytes
(
formatted
.
data
());
succeeded
=
::
ReportEventW
(
event_log_handle
(),
eventlog
::
get_event_type
(
msg
),
eventlog
::
get_event_category
(
msg
),
event_id_
,
current_user_sid_
.
as_sid
(),
1
,
0
,
&
lp_str
,
nullptr
);
current_user_sid_
.
as_sid
(),
1
,
0
,
(
LPCWSTR
*
)
buf
.
c_str
()
,
nullptr
);
#else
LPCSTR
lp_str
=
reinterpret_cast
<
LPCSTR
>
(
formatted
.
data
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment