diff options
author | Luke Berndt <lukekb@gmail.com> | 2023-01-14 16:07:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-14 16:07:56 -0500 |
commit | e3b285e51983ae892824e04f997c6e164d9224b9 (patch) | |
tree | 1e139b9dc47ae847c378f6096e9bda3f928c6f58 | |
parent | 4c84e250c06f0f6cdfb04145767e3dc32c26f07b (diff) | |
parent | 968979243d5d6683b8d293c3c34f7acaf46a997a (diff) |
Merge pull request #754 from aaknitt/earlier_log_file_creation
Create log file earlier
-rwxr-xr-x | trunk-recorder/main.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index a99891b4..2fbd6dc0 100755 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -149,7 +149,18 @@ bool load_config(string config_file) { BOOST_LOG_TRIVIAL(info) << "After you have made these updates, make sure you add \"ver\": 2, to the top.\n\n"; return false; } - + config.log_file = pt.get<bool>("logFile", false); + BOOST_LOG_TRIVIAL(info) << "Log to File: " << config.log_file; + config.log_dir = pt.get<std::string>("logDir", "logs"); + BOOST_LOG_TRIVIAL(info) << "Log Directory: " << config.log_dir; + if (config.log_file) { + logging::add_file_log( + keywords::file_name = config.log_dir + "/%m-%d-%Y_%H%M_%2N.log", + keywords::format = "[%TimeStamp%] (%Severity%) %Message%", + keywords::rotation_size = 100 * 1024 * 1024, + keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0), + keywords::auto_flush = true); + } BOOST_LOG_TRIVIAL(info) << "\n-------------------------------------\n Trunk Recorder\n-------------------------------------\n"; BOOST_LOG_TRIVIAL(info) << "\n\n-------------------------------------\nINSTANCE\n-------------------------------------\n"; @@ -177,10 +188,6 @@ bool load_config(string config_file) { BOOST_LOG_TRIVIAL(info) << "Default Mode: " << default_mode; config.call_timeout = pt.get<int>("callTimeout", 3); BOOST_LOG_TRIVIAL(info) << "Call Timeout (seconds): " << config.call_timeout; - config.log_file = pt.get<bool>("logFile", false); - BOOST_LOG_TRIVIAL(info) << "Log to File: " << config.log_file; - config.log_dir = pt.get<std::string>("logDir", "logs"); - BOOST_LOG_TRIVIAL(info) << "Log Directory: " << config.log_dir; config.control_message_warn_rate = pt.get<int>("controlWarnRate", 10); BOOST_LOG_TRIVIAL(info) << "Control channel warning rate: " << config.control_message_warn_rate; config.control_retune_limit = pt.get<int>("controlRetuneLimit", 0); |