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
6c5bbca0
Commit
6c5bbca0
authored
Aug 25, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added clone tests
parent
447a6a15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
README.md
README.md
+1
-1
tests/test_misc.cpp
tests/test_misc.cpp
+45
-0
No files found.
README.md
View file @
6c5bbca0
...
@@ -159,7 +159,7 @@ void daily_example()
...
@@ -159,7 +159,7 @@ void daily_example()
```
```
---
---
#### Cloning loggers
#### Cloning loggers
```
c++
```
c++
// clone a logger and give it new name.
// clone a logger and give it new name.
// Useful for creating subsystem loggers from some "root" logger
// Useful for creating subsystem loggers from some "root" logger
...
...
tests/test_misc.cpp
View file @
6c5bbca0
...
@@ -91,3 +91,48 @@ TEST_CASE("periodic flush", "[periodic_flush]")
...
@@ -91,3 +91,48 @@ TEST_CASE("periodic flush", "[periodic_flush]")
spdlog
::
flush_every
(
std
::
chrono
::
seconds
(
0
));
spdlog
::
flush_every
(
std
::
chrono
::
seconds
(
0
));
spdlog
::
drop_all
();
spdlog
::
drop_all
();
}
}
TEST_CASE
(
"clone"
,
"[clone]"
)
{
using
namespace
spdlog
;
auto
logger
=
spdlog
::
create
<
sinks
::
test_sink_mt
>
(
"orig"
);
auto
cloned
=
logger
->
clone
(
"clone"
);
REQUIRE
(
cloned
->
name
()
==
"clone"
);
REQUIRE
(
logger
->
sinks
()
==
cloned
->
sinks
());
REQUIRE
(
logger
->
level
()
==
cloned
->
level
());
REQUIRE
(
logger
->
flush_level
()
==
cloned
->
flush_level
());
logger
->
info
(
"Some message 1"
);
cloned
->
info
(
"Some message 2"
);
auto
test_sink
=
std
::
static_pointer_cast
<
sinks
::
test_sink_mt
>
(
cloned
->
sinks
()[
0
]);
REQUIRE
(
test_sink
->
msg_counter
()
==
2
);
spdlog
::
drop_all
();
}
TEST_CASE
(
"clone async"
,
"[clone]"
)
{
using
namespace
spdlog
;
auto
logger
=
spdlog
::
create_async
<
sinks
::
test_sink_mt
>
(
"orig"
);
auto
cloned
=
logger
->
clone
(
"clone"
);
REQUIRE
(
cloned
->
name
()
==
"clone"
);
REQUIRE
(
logger
->
sinks
()
==
cloned
->
sinks
());
REQUIRE
(
logger
->
level
()
==
cloned
->
level
());
REQUIRE
(
logger
->
flush_level
()
==
cloned
->
flush_level
());
logger
->
info
(
"Some message 1"
);
cloned
->
info
(
"Some message 2"
);
spdlog
::
details
::
os
::
sleep_for_millis
(
10
);
auto
test_sink
=
std
::
static_pointer_cast
<
sinks
::
test_sink_mt
>
(
cloned
->
sinks
()[
0
]);
REQUIRE
(
test_sink
->
msg_counter
()
==
2
);
spdlog
::
drop_all
();
}
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