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
75adf9e7
Commit
75adf9e7
authored
Aug 27, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved test_sink in unit tests
parent
0fa09f6a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
tests/test_sink.h
tests/test_sink.h
+18
-5
No files found.
tests/test_sink.h
View file @
75adf9e7
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include "spdlog/details/null_mutex.h"
#include "spdlog/details/null_mutex.h"
#include "spdlog/sinks/base_sink.h"
#include "spdlog/sinks/base_sink.h"
#include "spdlog/fmt/fmt.h"
#include <chrono>
#include <chrono>
#include <mutex>
#include <mutex>
#include <thread>
#include <thread>
...
@@ -36,9 +36,20 @@ public:
...
@@ -36,9 +36,20 @@ public:
delay_
=
delay
;
delay_
=
delay
;
}
}
// return last output without the eol
std
::
string
last_output
()
{
std
::
lock_guard
<
Mutex
>
lock
(
base_sink
<
Mutex
>::
mutex_
);
auto
eol_len
=
strlen
(
spdlog
::
details
::
os
::
default_eol
);
return
std
::
string
(
last_output_
.
begin
(),
last_output_
.
end
()
-
eol_len
);
}
protected:
protected:
void
sink_it_
(
const
details
::
log_msg
&
)
override
void
sink_it_
(
const
details
::
log_msg
&
msg
)
override
{
{
fmt
::
memory_buffer
formatted
;
base_sink
<
Mutex
>::
formatter_
->
format
(
msg
,
formatted
);
last_output_
.
assign
(
formatted
.
begin
(),
formatted
.
end
());
msg_counter_
++
;
msg_counter_
++
;
std
::
this_thread
::
sleep_for
(
delay_
);
std
::
this_thread
::
sleep_for
(
delay_
);
}
}
...
@@ -47,9 +58,11 @@ protected:
...
@@ -47,9 +58,11 @@ protected:
{
{
flush_counter_
++
;
flush_counter_
++
;
}
}
size_t
msg_counter_
{
0
};
size_t
msg_counter_
{
0
};
size_t
flush_counter_
{
0
};
size_t
flush_counter_
{
0
};
std
::
chrono
::
milliseconds
delay_
{
std
::
chrono
::
milliseconds
::
zero
()};
std
::
chrono
::
milliseconds
delay_
{
std
::
chrono
::
milliseconds
::
zero
()};
std
::
string
last_output_
;
};
};
using
test_sink_mt
=
test_sink
<
std
::
mutex
>
;
using
test_sink_mt
=
test_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