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
18ccd557
Commit
18ccd557
authored
May 19, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed multisink and test in example
parent
87eb5699
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
54 deletions
+0
-54
CMakeLists.txt
example/CMakeLists.txt
+0
-7
multisink.cpp
example/multisink.cpp
+0
-47
No files found.
example/CMakeLists.txt
View file @
18ccd557
...
...
@@ -53,11 +53,4 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android")
target_link_libraries
(
example_header_only log Threads::Threads
)
endif
()
add_executable
(
multisink multisink.cpp
)
target_link_libraries
(
multisink spdlog::spdlog
)
file
(
MAKE_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/logs"
)
enable_testing
()
add_test
(
NAME example COMMAND example
)
add_test
(
NAME example_header_only COMMAND example
)
example/multisink.cpp
deleted
100644 → 0
View file @
87eb5699
#include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_sinks.h"
#include <iostream>
#include <memory>
int
main
(
int
,
char
*
[])
{
bool
enable_debug
=
true
;
try
{
// This other example use a single logger with multiple sinks.
// This means that the same log_msg is forwarded to multiple sinks;
// Each sink can have it's own log level and a message will be logged.
std
::
vector
<
spdlog
::
sink_ptr
>
sinks
;
sinks
.
push_back
(
std
::
make_shared
<
spdlog
::
sinks
::
stdout_sink_mt
>
());
sinks
.
push_back
(
std
::
make_shared
<
spdlog
::
sinks
::
basic_file_sink_mt
>
(
"./log_regular_file.txt"
));
sinks
.
push_back
(
std
::
make_shared
<
spdlog
::
sinks
::
basic_file_sink_mt
>
(
"./log_debug_file.txt"
));
spdlog
::
logger
console_multisink
(
"multisink"
,
sinks
.
begin
(),
sinks
.
end
());
console_multisink
.
set_level
(
spdlog
::
level
::
warn
);
sinks
[
0
]
->
set_level
(
spdlog
::
level
::
trace
);
// console. Allow everything. Default value
sinks
[
1
]
->
set_level
(
spdlog
::
level
::
trace
);
// regular file. Allow everything. Default value
sinks
[
2
]
->
set_level
(
spdlog
::
level
::
off
);
// regular file. Ignore everything.
console_multisink
.
warn
(
"warn: will print only on console and regular file"
);
if
(
enable_debug
)
{
console_multisink
.
set_level
(
spdlog
::
level
::
debug
);
// level of the logger
sinks
[
1
]
->
set_level
(
spdlog
::
level
::
debug
);
// regular file
sinks
[
2
]
->
set_level
(
spdlog
::
level
::
debug
);
// debug file
}
console_multisink
.
debug
(
"Debug: you should see this on console and both files"
);
// Release and close all loggers
spdlog
::
drop_all
();
}
// Exceptions will only be thrown upon failed logger or sink construction (not during logging)
catch
(
const
spdlog
::
spdlog_ex
&
ex
)
{
std
::
cout
<<
"Log init failed: "
<<
ex
.
what
()
<<
std
::
endl
;
return
1
;
}
}
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