aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Knitt <andyknitt@gmail.com>2022-12-23 11:48:30 -0600
committerGitHub <noreply@github.com>2022-12-23 11:48:30 -0600
commit968979243d5d6683b8d293c3c34f7acaf46a997a (patch)
treeba8e86be2bb6e85796a2cc7d345f6ded188d4d51
parent3f036e0c6f69bd883a54a8cb96f07257602a07c2 (diff)
Create log file earlier
Create log file earlier so that config and source creation info is logged to the file in addition to the console output.
-rwxr-xr-xtrunk-recorder/main.cc17
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);