-
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.
Currently only converts some `fmt::print` calls to spdlog. Redirects all messages to syslog, and warnings or worse to stdout.
- Loading branch information
Showing
11 changed files
with
96 additions
and
18 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
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
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,28 @@ | ||
#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(spdlog::level::level_enum console_log_level, | ||
spdlog::level::level_enum syslog_log_level) { | ||
auto console_sink = std::make_shared<spdlog::sinks::stderr_color_sink_st>(); | ||
console_sink->set_level(console_log_level); | ||
|
||
auto syslog_sink = std::make_shared<spdlog::sinks::syslog_sink_st>( | ||
"uenv", LOG_PID, 0, false); | ||
syslog_sink->set_level(syslog_log_level); | ||
|
||
// The default logger is a combined logger that dispatches to the console | ||
// and syslog. We explicitly set the level to trace to allow all messages to | ||
// pass through the combined logger. The lower level loggers will filter | ||
// messages at their level. | ||
spdlog::set_default_logger(std::make_shared<spdlog::logger>( | ||
"uenv", spdlog::sinks_init_list({console_sink, syslog_sink}))); | ||
spdlog::set_level(spdlog::level::trace); | ||
spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%n] [%^%l%$] %v"); | ||
} | ||
} // 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,6 @@ | ||
#include <spdlog/spdlog.h> | ||
|
||
namespace uenv { | ||
void init_log(spdlog::level::level_enum console_log_level, | ||
spdlog::level::level_enum syslog_log_level); | ||
} |
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,13 @@ | ||
[wrap-file] | ||
directory = spdlog-1.14.1 | ||
source_url = https://github.com/gabime/spdlog/archive/refs/tags/v1.14.1.tar.gz | ||
source_filename = spdlog-1.14.1.tar.gz | ||
source_hash = 1586508029a7d0670dfcb2d97575dcdc242d3868a259742b69f100801ab4e16b | ||
patch_filename = spdlog_1.14.1-1_patch.zip | ||
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.14.1-1/get_patch | ||
patch_hash = ae878e732330ea1048f90d7e117c40c0cd2a6fb8ae5492c7955818ce3aaade6c | ||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/spdlog_1.14.1-1/spdlog-1.14.1.tar.gz | ||
wrapdb_version = 1.14.1-1 | ||
|
||
[provide] | ||
spdlog = spdlog_dep |
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 |
---|---|---|
@@ -1,2 +1,10 @@ | ||
#define CATCH_CONFIG_MAIN | ||
#include <catch2/catch_all.hpp> | ||
|
||
#include <uenv/log.h> | ||
|
||
static struct unit_init_log { | ||
unit_init_log() { | ||
uenv::init_log(spdlog::level::trace, spdlog::level::off); | ||
} | ||
} uil{}; |