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
81f29a9a
Commit
81f29a9a
authored
Jul 10, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed wchar support in messages
parent
898e1f26
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
21 deletions
+24
-21
include/spdlog/common.h
include/spdlog/common.h
+1
-1
include/spdlog/details/logger_impl.h
include/spdlog/details/logger_impl.h
+17
-16
include/spdlog/logger.h
include/spdlog/logger.h
+6
-4
No files found.
include/spdlog/common.h
View file @
81f29a9a
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#include <string>
#include <string>
#include <unordered_map>
#include <unordered_map>
#if defined(
_WIN32) && defined(SPDLOG_WCHAR_FILENAMES
)
#if defined(
SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT
)
#include <codecvt>
#include <codecvt>
#include <locale>
#include <locale>
#endif
#endif
...
...
include/spdlog/details/logger_impl.h
View file @
81f29a9a
...
@@ -173,24 +173,25 @@ inline void spdlog::logger::critical(const T &msg)
...
@@ -173,24 +173,25 @@ inline void spdlog::logger::critical(const T &msg)
}
}
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
#include <codecvt>
#include <locale>
template
<
typename
...
Args
>
inline
void
spdlog
::
logger
::
log
(
level
::
level_enum
lvl
,
const
wchar_t
*
msg
)
{
std
::
wstring_convert
<
std
::
codecvt_utf8
<
wchar_t
>>
conv
;
log
(
lvl
,
conv
.
to_bytes
(
msg
));
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
void
spdlog
::
logger
::
log
(
level
::
level_enum
lvl
,
const
wchar_t
*
fmt
,
const
Args
&
...
args
)
inline
void
spdlog
::
logger
::
log
(
level
::
level_enum
lvl
,
const
wchar_t
*
fmt
,
const
Args
&
...
args
)
{
{
fmt
::
WMemoryWriter
wWriter
;
if
(
!
should_log
(
lvl
))
{
return
;
}
decltype
(
wstring_converter_
)
::
byte_string
utf8_string
;
wWriter
.
write
(
fmt
,
args
...);
try
log
(
lvl
,
wWriter
.
c_str
());
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
wstring_converter_mutex_
);
utf8_string
=
wstring_converter_
.
to_bytes
(
fmt
);
}
log
(
lvl
,
utf8_string
.
c_str
(),
args
...);
}
SPDLOG_CATCH_AND_HANDLE
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
...
...
include/spdlog/logger.h
View file @
81f29a9a
...
@@ -64,9 +64,6 @@ public:
...
@@ -64,9 +64,6 @@ public:
void
critical
(
const
char
*
fmt
,
const
Args
&
...
args
);
void
critical
(
const
char
*
fmt
,
const
Args
&
...
args
);
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
template
<
typename
...
Args
>
void
log
(
level
::
level_enum
lvl
,
const
wchar_t
*
msg
);
template
<
typename
...
Args
>
template
<
typename
...
Args
>
void
log
(
level
::
level_enum
lvl
,
const
wchar_t
*
fmt
,
const
Args
&
...
args
);
void
log
(
level
::
level_enum
lvl
,
const
wchar_t
*
fmt
,
const
Args
&
...
args
);
...
@@ -152,6 +149,11 @@ protected:
...
@@ -152,6 +149,11 @@ protected:
log_err_handler
err_handler_
;
log_err_handler
err_handler_
;
std
::
atomic
<
time_t
>
last_err_time_
;
std
::
atomic
<
time_t
>
last_err_time_
;
std
::
atomic
<
size_t
>
msg_counter_
;
std
::
atomic
<
size_t
>
msg_counter_
;
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
std
::
wstring_convert
<
std
::
codecvt_utf8
<
wchar_t
>>
wstring_converter_
;
std
::
mutex
wstring_converter_mutex_
;
#endif
};
};
}
// namespace spdlog
}
// namespace spdlog
...
...
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