fix: Load logging config at runtime
Don't use hardcoded default
This commit is contained in:
1 parent
0adff5e042
commit
a174bbc4db
2 files changed
+13
-12
No files matched your search
@@ -2,8 +2,8 @@
|
||||
#include "spark/config/spark_data_directory.h"
|
||||
#include "spark/utils/thread_manager.h"
|
||||
#include "system/logging/logging.h"
|
||||
#include "system/logging/protobufs/logging.h"
|
||||
#include "system/output_switch.h"
|
||||
#include "system/protobufs/logging.pb.h"
|
||||
|
||||
namespace bts {
|
||||
namespace utils {
|
||||
@@ -14,7 +14,7 @@ using bts::system::threading::ThreadManager;
|
||||
static LoggingConfigPoller *poller = nullptr;
|
||||
|
||||
static void init_spark_lib(
|
||||
const logging::protobufs::Logging &logging_cfg,
|
||||
std::optional<logging::protobufs::Logging> logging_cfg,
|
||||
bool hot_reload,
|
||||
bool quiet_console) {
|
||||
system::OutputSwitch cout{&std::cout, quiet_console};
|
||||
@@ -27,20 +27,23 @@ static void init_spark_lib(
|
||||
logging::start_default_logging_thread();
|
||||
cout << "Initializing LoggingConfigPoller" << std::endl;
|
||||
ThreadManager thread_man{ThreadManager::default_thread_config()};
|
||||
auto lcfg = thread_man.get_thread_cfg("logger");
|
||||
const auto logger_thread_cfg = thread_man.get_thread_cfg("logger");
|
||||
if (!logging_cfg) {
|
||||
logging_cfg = config::get<logging::protobufs::Logging>();
|
||||
}
|
||||
const spark::SparkDataDirectory data_dir;
|
||||
if (hot_reload) {
|
||||
poller = new LoggingConfigPoller(
|
||||
logging_cfg, thread_man.get_thread_cfg("logger"),
|
||||
*logging_cfg, thread_man.get_thread_cfg("logger"),
|
||||
data_dir.log_file().string(), data_dir.log_cache_file().string());
|
||||
} else {
|
||||
logging::configure_logging(
|
||||
logging_cfg, lcfg, data_dir.log_file().string());
|
||||
*logging_cfg, logger_thread_cfg, data_dir.log_file().string());
|
||||
}
|
||||
}
|
||||
|
||||
SparkLibInit::SparkLibInit(
|
||||
const logging::protobufs::Logging &logging_cfg,
|
||||
std::optional<logging::protobufs::Logging> logging_cfg,
|
||||
bool hot_reload,
|
||||
bool quiet_console) {
|
||||
init_spark_lib(logging_cfg, hot_reload, quiet_console);
|
||||
@@ -48,9 +51,7 @@ SparkLibInit::SparkLibInit(
|
||||
|
||||
SparkLibInit::~SparkLibInit() { finit_spark_lib(); }
|
||||
|
||||
void init_spark_lib() {
|
||||
init_spark_lib(logging::protobufs::default_logging_config(), true, false);
|
||||
}
|
||||
void init_spark_lib() { init_spark_lib(std::nullopt, true, false); }
|
||||
|
||||
void finit_spark_lib() {
|
||||
LOG(Gen, Diag, "finit_spark_lib");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
#include "bts_export.h"
|
||||
#include "system/logging/protobufs/logging.h"
|
||||
#include "system/protobufs/logging.pb.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
// this is needed because we cannot relly on static initialization do
|
||||
// work reliably in DLL's on Windows. See:
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn633971(v=vs.85).aspx
|
||||
@@ -16,8 +17,7 @@ extern "C" BTS_EXPORT void finit_spark_lib();
|
||||
|
||||
struct SparkLibInit {
|
||||
explicit SparkLibInit(
|
||||
const logging::protobufs::Logging &logging_cfg =
|
||||
logging::protobufs::default_logging_config(),
|
||||
std::optional<logging::protobufs::Logging> logging_cfg = std::nullopt,
|
||||
bool hot_reload = true,
|
||||
bool quiet_console = false);
|
||||
~SparkLibInit();
|
||||
|
||||
Reference in new issue
Block a user