From e008eaf39cf68332ace77519262e86e8ecfb1d20 Mon Sep 17 00:00:00 2001 From: Tyler Lentz Date: Wed, 17 Apr 2024 20:36:49 +0000 Subject: [PATCH] add logging dir to config --- configs/config.json | 3 +++ configs/default-config.json | 3 +++ configs/dev-config.json | 3 +++ include/utilities/obc_config.hpp | 2 ++ src/main.cpp | 2 +- src/utilities/obc_config.cpp | 3 +++ 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/configs/config.json b/configs/config.json index 807186fa..580a3dd7 100644 --- a/configs/config.json +++ b/configs/config.json @@ -1,4 +1,7 @@ { + "logging": { + "dir": "/workspaces/obcpp/logs" + }, "network": { "mavlink": { "connect": "serial:///dev/ttyACM0" diff --git a/configs/default-config.json b/configs/default-config.json index 80553017..e3432da6 100644 --- a/configs/default-config.json +++ b/configs/default-config.json @@ -1,4 +1,7 @@ { + "logging": { + "dir": "/workspaces/obcpp/logs" + }, "network": { "gcs": { "port": 5010 diff --git a/configs/dev-config.json b/configs/dev-config.json index a33eeb84..b42bfa47 100644 --- a/configs/dev-config.json +++ b/configs/dev-config.json @@ -1,4 +1,7 @@ { + "logging": { + "dir": "/workspaces/obcpp/logs" + }, "network": { "mavlink": { "connect": "tcp://172.17.0.1:5760" diff --git a/include/utilities/obc_config.hpp b/include/utilities/obc_config.hpp index a42e813f..152d5a6d 100644 --- a/include/utilities/obc_config.hpp +++ b/include/utilities/obc_config.hpp @@ -4,6 +4,8 @@ #include struct OBCConfig { + std::string logging_dir; + std::string network_mavlink_connect; int network_gcs_port; diff --git a/src/main.cpp b/src/main.cpp index 4f8519ac..8905e2c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char* argv[]) { OBCConfig config(argc, argv); // TODO: pull logging folder from config - initLogging("/workspaces/obcpp/logs", true, argc, argv); + initLogging(config.logging_dir, true, argc, argv); OBC obc(config); obc.run(); diff --git a/src/utilities/obc_config.cpp b/src/utilities/obc_config.cpp index c1c9180f..c90a7415 100644 --- a/src/utilities/obc_config.cpp +++ b/src/utilities/obc_config.cpp @@ -20,6 +20,7 @@ OBCConfig::OBCConfig(int argc, char* argv[]) { json configs = json::parse(configStream); // Set configs + this->logging_dir = configs["logging"]["dir"]; this->network_mavlink_connect = configs["network"]["mavlink"]["connect"]; this->network_gcs_port = configs["network"]["gcs"]["port"]; } else { @@ -29,11 +30,13 @@ OBCConfig::OBCConfig(int argc, char* argv[]) { void OBCConfig::makeDefault() { // Set configs + this->logging_dir = "/workspaces/obcpp/logs"; this->network_mavlink_connect = "tcp://172.17.0.1:5760"; this->network_gcs_port = 5010; // Create default configs json configs; + configs["logging"]["dir"] = this->logging_dir; configs["network"]["mavlink"]["connect"] = this->network_mavlink_connect; configs["network"]["gcs"]["port"] = this->network_gcs_port; std::ofstream configFile(configsPath + "default-config.json");