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
62e09e73
Commit
62e09e73
authored
Nov 09, 2019
by
Václav Šmilauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
defer formatting, use log_msg_buffer for intermediate storage
parent
daef0a23
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
ringbuffer_sink-inl.h
include/spdlog/sinks/ringbuffer_sink-inl.h
+6
-6
ringbuffer_sink.h
include/spdlog/sinks/ringbuffer_sink.h
+2
-1
No files found.
include/spdlog/sinks/ringbuffer_sink-inl.h
View file @
62e09e73
...
...
@@ -16,15 +16,13 @@ namespace sinks {
template
<
typename
Mutex
>
SPDLOG_INLINE
ringbuffer_sink
<
Mutex
>::
ringbuffer_sink
(
size_t
buf_size
)
{
buf
=
details
::
circular_q
<
std
::
string
>
(
buf_size
);
buf
_
=
details
::
circular_q
<
details
::
log_msg_buffer
>
(
buf_size
);
}
template
<
typename
Mutex
>
SPDLOG_INLINE
void
ringbuffer_sink
<
Mutex
>::
sink_it_
(
const
details
::
log_msg
&
msg
)
{
memory_buf_t
formatted
;
base_sink
<
Mutex
>::
formatter_
->
format
(
msg
,
formatted
);
buf
.
push_back
(
fmt
::
to_string
(
formatted
));
buf_
.
push_back
(
details
::
log_msg_buffer
{
msg
});
}
template
<
typename
Mutex
>
...
...
@@ -34,9 +32,11 @@ SPDLOG_INLINE std::vector<std::string> ringbuffer_sink<Mutex>::last(size_t lim)
std
::
vector
<
std
::
string
>
ret
;
ret
.
reserve
(
lim
);
size_t
num
=
0
;
for
(
size_t
i
=
0
;
i
<
buf
.
size
();
i
++
){
for
(
size_t
i
=
0
;
i
<
buf
_
.
size
();
i
++
){
num
++
;
ret
.
push_back
(
buf
.
at
(
i
));
memory_buf_t
formatted
;
base_sink
<
Mutex
>::
formatter_
->
format
(
buf_
.
at
(
i
),
formatted
);
ret
.
push_back
(
fmt
::
to_string
(
formatted
));
if
(
lim
>
0
&&
num
==
lim
)
break
;
}
return
ret
;
...
...
include/spdlog/sinks/ringbuffer_sink.h
View file @
62e09e73
...
...
@@ -7,6 +7,7 @@
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/synchronous_factory.h"
#include "spdlog/details/circular_q.h"
#include "spdlog/details/log_msg_buffer.h"
#include <mutex>
#include <string>
...
...
@@ -29,7 +30,7 @@ protected:
void
flush_
()
override
{};
private
:
details
::
circular_q
<
std
::
string
>
buf
;
details
::
circular_q
<
details
::
log_msg_buffer
>
buf_
;
};
using
ringbuffer_sink_mt
=
ringbuffer_sink
<
std
::
mutex
>
;
...
...
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