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
0f25b25b
Commit
0f25b25b
authored
May 13, 2017
by
Alexander Zilberkant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add async_logger tests
cover discarded messages use-case
parent
42258a10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
tests/CMakeLists.txt
tests/CMakeLists.txt
+1
-1
tests/async_logger.cpp
tests/async_logger.cpp
+38
-0
No files found.
tests/CMakeLists.txt
View file @
0f25b25b
...
...
@@ -10,7 +10,7 @@ find_package(Threads)
add_library
(
catch INTERFACE
)
target_include_directories
(
catch INTERFACE
${
CMAKE_CURRENT_SOURCE_DIR
}
)
file
(
GLOB catch_tests LIST_DIRECTORIES false RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
*.cpp
)
file
(
GLOB catch_tests LIST_DIRECTORIES false RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
*.cpp
*.h *.hpp
)
add_executable
(
catch_tests
${
catch_tests
}
)
target_link_libraries
(
catch_tests spdlog
${
CMAKE_THREAD_LIBS_INIT
}
)
...
...
tests/async_logger.cpp
0 → 100644
View file @
0f25b25b
#include <iostream>
#include "includes.h"
#include "../include/spdlog/common.h"
#include "../include/spdlog/tweakme.h"
TEST_CASE
(
"async_logging_overflow "
,
"[async_logging]"
)
{
std
::
string
filename
=
"logs/async_log_overflow.txt"
;
auto
sink
=
std
::
make_shared
<
spdlog
::
sinks
::
simple_file_sink_st
>
(
filename
,
true
);
auto
logger
=
std
::
make_shared
<
spdlog
::
async_logger
>
(
"overflow_logger"
,
sink
,
2
,
// queue size
spdlog
::
async_overflow_policy
::
discard_log_msg
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
logger
->
info
(
"Message #{}"
,
i
);
}
logger
->
flush
();
logger
.
reset
();
std
::
string
the_log
=
file_contents
(
filename
);
#if defined(SPDLOG_ASYNC_COUNT_DISCARDED_MSG)
std
::
cout
<<
the_log
<<
std
::
endl
;
REQUIRE
(
the_log
.
find
(
"Dropped 6 messages"
)
!=
std
::
string
::
npos
);
#endif
}
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