-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set default spdlog logger to log to syslog and stdout
- Loading branch information
Showing
4 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <memory> | ||
|
||
#include "spdlog/sinks/stdout_color_sinks.h" | ||
#include "spdlog/sinks/syslog_sink.h" | ||
#include <spdlog/spdlog.h> | ||
|
||
#include "log.h" | ||
|
||
namespace uenv { | ||
void init_log() { | ||
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>(); | ||
console_sink->set_level(spdlog::level::warn); | ||
|
||
auto syslog_sink = std::make_shared<spdlog::sinks::syslog_sink_mt>( | ||
"uenv", LOG_PID, 0, false); | ||
syslog_sink->set_level(spdlog::level::trace); | ||
|
||
spdlog::set_default_logger(std::make_shared<spdlog::logger>( | ||
"uenv", spdlog::sinks_init_list({console_sink, syslog_sink}))); | ||
} | ||
} // namespace uenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace uenv { | ||
void init_log(); | ||
} |