Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
894438d5
Commit
894438d5
authored
Oct 21, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better support for string_view
parent
2ad191ae
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
7 deletions
+15
-7
common.h
include/spdlog/common.h
+7
-0
fmt_helper.h
include/spdlog/details/fmt_helper.h
+3
-3
log_msg.h
include/spdlog/details/log_msg.h
+2
-2
pattern_formatter.h
include/spdlog/details/pattern_formatter.h
+2
-1
thread_pool.h
include/spdlog/details/thread_pool.h
+1
-1
No files found.
include/spdlog/common.h
View file @
894438d5
...
...
@@ -56,6 +56,13 @@ using sink_ptr = std::shared_ptr<sinks::sink>;
using
sinks_init_list
=
std
::
initializer_list
<
sink_ptr
>
;
using
log_err_handler
=
std
::
function
<
void
(
const
std
::
string
&
err_msg
)
>
;
// string_view type - either std::string_view or fmt::string_view (pre c++17)
#if defined(FMT_USE_STD_STRING_VIEW)
using
string_view_type
=
std
::
string_view
;
#else
using
string_view_type
=
fmt
::
string_view
;
#endif
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
using
level_t
=
details
::
null_atomic_int
;
#else
...
...
include/spdlog/details/fmt_helper.h
View file @
894438d5
...
...
@@ -14,9 +14,9 @@ namespace details {
namespace
fmt_helper
{
template
<
size_t
Buffer_Size
>
inline
fmt
::
string_view
to_string_view
(
const
fmt
::
basic_memory_buffer
<
char
,
Buffer_Size
>
&
buf
)
SPDLOG_NOEXCEPT
inline
spdlog
::
string_view_type
to_string_view
(
const
fmt
::
basic_memory_buffer
<
char
,
Buffer_Size
>
&
buf
)
SPDLOG_NOEXCEPT
{
return
fmt
::
string_view
(
buf
.
data
(),
buf
.
size
());
return
spdlog
::
string_view_type
(
buf
.
data
(),
buf
.
size
());
}
template
<
size_t
Buffer_Size1
,
size_t
Buffer_Size2
>
inline
void
append_buf
(
const
fmt
::
basic_memory_buffer
<
char
,
Buffer_Size1
>
&
buf
,
fmt
::
basic_memory_buffer
<
char
,
Buffer_Size2
>
&
dest
)
...
...
@@ -26,7 +26,7 @@ inline void append_buf(const fmt::basic_memory_buffer<char, Buffer_Size1> &buf,
}
template
<
size_t
Buffer_Size
>
inline
void
append_string_view
(
fmt
::
string_view
view
,
fmt
::
basic_memory_buffer
<
char
,
Buffer_Size
>
&
dest
)
inline
void
append_string_view
(
spdlog
::
string_view_type
view
,
fmt
::
basic_memory_buffer
<
char
,
Buffer_Size
>
&
dest
)
{
auto
*
buf_ptr
=
view
.
data
();
if
(
buf_ptr
!=
nullptr
)
...
...
include/spdlog/details/log_msg.h
View file @
894438d5
...
...
@@ -17,7 +17,7 @@ struct log_msg
{
log_msg
()
=
default
;
log_msg
(
const
std
::
string
*
loggers_name
,
level
::
level_enum
lvl
,
fmt
::
string_view
view
)
log_msg
(
const
std
::
string
*
loggers_name
,
level
::
level_enum
lvl
,
string_view_type
view
)
:
logger_name
(
loggers_name
)
,
level
(
lvl
)
#ifndef SPDLOG_NO_DATETIME
...
...
@@ -44,7 +44,7 @@ struct log_msg
mutable
size_t
color_range_start
{
0
};
mutable
size_t
color_range_end
{
0
};
const
fmt
::
string_view
payload
;
const
string_view_type
payload
;
};
}
// namespace details
}
// namespace spdlog
include/spdlog/details/pattern_formatter.h
View file @
894438d5
...
...
@@ -39,7 +39,7 @@ class name_formatter : public flag_formatter
void
format
(
const
details
::
log_msg
&
msg
,
const
std
::
tm
&
,
fmt
::
memory_buffer
&
dest
)
override
{
// fmt_helper::append_str(*msg.logger_name, dest);
fmt_helper
::
append_string_view
(
*
msg
.
logger_name
,
dest
);
fmt_helper
::
append_string_view
(
string_view_type
(
*
msg
.
logger_name
)
,
dest
);
}
};
...
...
@@ -49,6 +49,7 @@ class level_formatter : public flag_formatter
void
format
(
const
details
::
log_msg
&
msg
,
const
std
::
tm
&
,
fmt
::
memory_buffer
&
dest
)
override
{
// fmt_helper::append_string_view(level::to_c_str(msg.level), dest);
spdlog
::
string_view_type
t
(
"SSSSSSS"
);
fmt_helper
::
append_string_view
(
level
::
to_c_str
(
msg
.
level
),
dest
);
}
};
...
...
include/spdlog/details/thread_pool.h
View file @
894438d5
...
...
@@ -94,7 +94,7 @@ struct async_msg
// copy into log_msg
log_msg
to_log_msg
()
{
log_msg
msg
(
&
worker_ptr
->
name
(),
level
,
fmt
::
string_view
(
raw
.
data
(),
raw
.
size
()));
log_msg
msg
(
&
worker_ptr
->
name
(),
level
,
string_view_type
(
raw
.
data
(),
raw
.
size
()));
msg
.
time
=
time
;
msg
.
thread_id
=
thread_id
;
msg
.
msg_id
=
msg_id
;
...
...
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