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
f0a4ddd7
Unverified
Commit
f0a4ddd7
authored
Jan 06, 2021
by
Charles Milette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix character issues in test_errors.cpp
parent
c691769e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
tests/test_errors.cpp
tests/test_errors.cpp
+10
-7
No files found.
tests/test_errors.cpp
View file @
f0a4ddd7
...
...
@@ -5,6 +5,9 @@
#include <iostream>
#define SIMPLE_LOG "test_logs/simple_log.txt"
#define SIMPLE_ASYNC_LOG "test_logs/simple_async_log.txt"
class
failing_sink
:
public
spdlog
::
sinks
::
base_sink
<
std
::
mutex
>
{
protected:
...
...
@@ -22,7 +25,7 @@ protected:
TEST_CASE
(
"default_error_handler"
,
"[errors]]"
)
{
prepare_logdir
();
s
td
::
string
filename
=
"test_logs/simple_log.txt"
;
s
pdlog
::
filename_t
filename
=
SPDLOG_FILENAME_T
(
SIMPLE_LOG
)
;
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
basic_file_sink_mt
>
(
"test-error"
,
filename
,
true
);
logger
->
set_pattern
(
"%v"
);
...
...
@@ -31,8 +34,8 @@ TEST_CASE("default_error_handler", "[errors]]")
logger
->
flush
();
using
spdlog
::
details
::
os
::
default_eol
;
REQUIRE
(
file_contents
(
filename
)
==
fmt
::
format
(
"Test message 2{}"
,
default_eol
));
REQUIRE
(
count_lines
(
filename
)
==
1
);
REQUIRE
(
file_contents
(
SIMPLE_LOG
)
==
fmt
::
format
(
"Test message 2{}"
,
default_eol
));
REQUIRE
(
count_lines
(
SIMPLE_LOG
)
==
1
);
}
struct
custom_ex
...
...
@@ -40,7 +43,7 @@ struct custom_ex
TEST_CASE
(
"custom_error_handler"
,
"[errors]]"
)
{
prepare_logdir
();
s
td
::
string
filename
=
"test_logs/simple_log.txt"
;
s
pdlog
::
filename_t
filename
=
SPDLOG_FILENAME_T
(
SIMPLE_LOG
)
;
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
basic_file_sink_mt
>
(
"logger"
,
filename
,
true
);
logger
->
flush_on
(
spdlog
::
level
::
info
);
logger
->
set_error_handler
([
=
](
const
std
::
string
&
)
{
throw
custom_ex
();
});
...
...
@@ -48,7 +51,7 @@ TEST_CASE("custom_error_handler", "[errors]]")
REQUIRE_THROWS_AS
(
logger
->
info
(
"Bad format msg {} {}"
,
"xxx"
),
custom_ex
);
logger
->
info
(
"Good message #2"
);
require_message_count
(
filename
,
2
);
require_message_count
(
SIMPLE_LOG
,
2
);
}
TEST_CASE
(
"default_error_handler2"
,
"[errors]]"
)
...
...
@@ -72,7 +75,7 @@ TEST_CASE("async_error_handler", "[errors]]")
prepare_logdir
();
std
::
string
err_msg
(
"log failed with some msg"
);
s
td
::
string
filename
=
"test_logs/simple_async_log.txt"
;
s
pdlog
::
filename_t
filename
=
SPDLOG_FILENAME_T
(
SIMPLE_ASYNC_LOG
)
;
{
spdlog
::
init_thread_pool
(
128
,
1
);
auto
logger
=
spdlog
::
create_async
<
spdlog
::
sinks
::
basic_file_sink_mt
>
(
"logger"
,
filename
,
true
);
...
...
@@ -90,7 +93,7 @@ TEST_CASE("async_error_handler", "[errors]]")
spdlog
::
drop
(
"logger"
);
// force logger to drain the queue and shutdown
}
spdlog
::
init_thread_pool
(
128
,
1
);
require_message_count
(
filename
,
2
);
require_message_count
(
SIMPLE_ASYNC_LOG
,
2
);
REQUIRE
(
file_contents
(
"test_logs/custom_err.txt"
)
==
err_msg
);
}
...
...
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