Logger: the version line once per service name
Every Logger construction printed the version line, and a rugnux run makes a logger per FFT indexer of its first-pass ladder: about 180 version lines in a 20 s live run. The line now goes out the first time a service name is seen. The set is a function-local static, as jfjoch_writer's logger is a global made before this file's own namespace-scope statics. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK
This commit is contained in:
1 parent
c9704d1c5c
commit
d2e4e4d878
1 file changed
+10
@@ -7,6 +7,7 @@
|
||||
#include "spdlog/fmt/bin_to_hex.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "Logger.h"
|
||||
#include "GitInfo.h"
|
||||
@@ -64,6 +65,15 @@ Logger::Logger(const std::string &service_name, const std::string &file_name) {
|
||||
spdlog_logger = std::make_shared<spdlog::logger>(service_name, std::begin(sinks), std::end(sinks));
|
||||
if (const auto it = service_levels.find(service_name); it != service_levels.end())
|
||||
spdlog_logger->set_level(it->second);
|
||||
{
|
||||
// The version line goes out once per service: a run makes many loggers of one service (every FFT indexer
|
||||
// is one). Function-local, as a static Logger (jfjoch_writer's) is made before this file's own statics.
|
||||
static std::mutex version_mutex;
|
||||
static std::set<std::string> version_logged;
|
||||
std::unique_lock ul(version_mutex);
|
||||
if (!version_logged.insert(service_name).second)
|
||||
return;
|
||||
}
|
||||
if (jfjoch_git_sha1().empty())
|
||||
spdlog_logger->info("Version {} {}", jfjoch_version(), variant);
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user