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
01f2438c
Unverified
Commit
01f2438c
authored
Jul 24, 2019
by
Gabi Melman
Committed by
GitHub
Jul 24, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1169 from TranslucentTB/v1.x
Add more overloads to spdlog::log and spdlog::logger::log
parents
e0cf16b7
eb51f37c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
4 deletions
+42
-4
include/spdlog/common.h
include/spdlog/common.h
+6
-0
include/spdlog/logger.h
include/spdlog/logger.h
+24
-4
include/spdlog/spdlog.h
include/spdlog/spdlog.h
+12
-0
No files found.
include/spdlog/common.h
View file @
01f2438c
...
...
@@ -95,7 +95,13 @@ using string_view_t = basic_string_view_t<char>;
#error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
#else
using
wstring_view_t
=
basic_string_view_t
<
wchar_t
>
;
template
<
typename
T
>
struct
is_convertible_to_wstring_view
:
std
::
is_convertible
<
T
,
wstring_view_t
>
{
};
#endif // _WIN32
#else
template
<
typename
>
struct
is_convertible_to_wstring_view
:
std
::
false_type
{
};
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
...
...
include/spdlog/logger.h
View file @
01f2438c
...
...
@@ -143,7 +143,7 @@ public:
}
// T can be statically converted to string_view
template
<
class
T
,
typename
std
::
enable_if
<
std
::
is_convertible
<
T
,
spdlog
::
string_view_t
>
::
value
,
T
>::
type
*
=
nullptr
>
template
<
class
T
,
typename
std
::
enable_if
<
std
::
is_convertible
<
const
T
&
,
spdlog
::
string_view_t
>
::
value
,
T
>::
type
*
=
nullptr
>
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
const
T
&
msg
)
{
if
(
!
should_log
(
lvl
))
...
...
@@ -155,8 +155,8 @@ public:
sink_it_
(
log_msg
);
}
// T cannot be statically converted to string_view
template
<
class
T
,
typename
std
::
enable_if
<!
std
::
is_convertible
<
T
,
spdlog
::
string_view_t
>
::
value
,
T
>::
type
*
=
nullptr
>
// T cannot be statically converted to string_view
or wstring_view
template
<
class
T
,
typename
std
::
enable_if
<!
std
::
is_convertible
<
const
T
&
,
spdlog
::
string_view_t
>
::
value
&&
!
is_convertible_to_wstring_view
<
const
T
&
>::
value
,
T
>::
type
*
=
nullptr
>
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
const
T
&
msg
)
{
if
(
!
should_log
(
lvl
))
...
...
@@ -228,7 +228,7 @@ public:
fmt
::
format_to
(
wbuf
,
fmt
,
args
...);
fmt
::
memory_buffer
buf
;
details
::
os
::
wstr_to_utf8buf
(
basic_string_view_t
<
wchar_t
>
(
wbuf
.
data
(),
wbuf
.
size
()),
buf
);
details
::
os
::
wstr_to_utf8buf
(
wstring_view_t
(
wbuf
.
data
(),
wbuf
.
size
()),
buf
);
details
::
log_msg
log_msg
(
source
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
sink_it_
(
log_msg
);
...
...
@@ -277,6 +277,26 @@ public:
{
log
(
level
::
critical
,
fmt
,
args
...);
}
// T can be statically converted to wstring_view
template
<
class
T
,
typename
std
::
enable_if
<
is_convertible_to_wstring_view
<
const
T
&
>
::
value
,
T
>::
type
*
=
nullptr
>
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
const
T
&
msg
)
{
if
(
!
should_log
(
lvl
))
{
return
;
}
try
{
fmt
::
memory_buffer
buf
;
details
::
os
::
wstr_to_utf8buf
(
msg
,
buf
);
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
sink_it_
(
log_msg
);
}
SPDLOG_LOGGER_CATCH
()
}
#endif // _WIN32
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
...
...
include/spdlog/spdlog.h
View file @
01f2438c
...
...
@@ -162,6 +162,12 @@ inline void critical(string_view_t fmt, const Args &... args)
default_logger_raw
()
->
critical
(
fmt
,
args
...);
}
template
<
typename
T
>
inline
void
log
(
source_loc
source
,
level
::
level_enum
lvl
,
const
T
&
msg
)
{
default_logger_raw
()
->
log
(
source
,
lvl
,
msg
);
}
template
<
typename
T
>
inline
void
log
(
level
::
level_enum
lvl
,
const
T
&
msg
)
{
...
...
@@ -205,6 +211,12 @@ inline void critical(const T &msg)
}
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
template
<
typename
...
Args
>
inline
void
log
(
source_loc
source
,
level
::
level_enum
lvl
,
wstring_view_t
fmt
,
const
Args
&
...
args
)
{
default_logger_raw
()
->
log
(
source
,
lvl
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
log
(
level
::
level_enum
lvl
,
wstring_view_t
fmt
,
const
Args
&
...
args
)
{
...
...
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