Add json file rotation option (#9783)
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
co-authored by
GitHub
Ben Meadors
parent
86dad90573
commit
0ed537a336
@@ -630,7 +630,9 @@ void portduinoSetup()
|
||||
}
|
||||
} else if (portduino_config.JSONFilename != "") {
|
||||
try {
|
||||
JSONFile.open(portduino_config.JSONFilename, std::ios::out | std::ios::app);
|
||||
if (portduino_config.JSONFileRotate == 0) {
|
||||
JSONFile.open(portduino_config.JSONFilename, std::ios::out | std::ios::app);
|
||||
}
|
||||
} catch (std::ofstream::failure &e) {
|
||||
std::cout << "*** JSONFile Exception " << e.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -687,6 +689,7 @@ bool loadConfig(const char *configPath)
|
||||
}
|
||||
portduino_config.traceFilename = yamlConfig["Logging"]["TraceFile"].as<std::string>("");
|
||||
portduino_config.JSONFilename = yamlConfig["Logging"]["JSONFile"].as<std::string>("");
|
||||
portduino_config.JSONFileRotate = yamlConfig["Logging"]["JSONFileRotate"].as<int>(0);
|
||||
portduino_config.JSONFilter = (_meshtastic_PortNum)yamlConfig["Logging"]["JSONFilter"].as<int>(0);
|
||||
if (yamlConfig["Logging"]["JSONFilter"].as<std::string>("") == "textmessage")
|
||||
portduino_config.JSONFilter = meshtastic_PortNum_TEXT_MESSAGE_APP;
|
||||
|
||||
@@ -165,6 +165,7 @@ extern struct portduino_config_struct {
|
||||
bool ascii_logs_explicit = false;
|
||||
|
||||
std::string JSONFilename;
|
||||
int JSONFileRotate = 0;
|
||||
meshtastic_PortNum JSONFilter = (_meshtastic_PortNum)0;
|
||||
|
||||
// Webserver
|
||||
@@ -472,6 +473,9 @@ extern struct portduino_config_struct {
|
||||
out << YAML::Key << "TraceFile" << YAML::Value << traceFilename;
|
||||
if (JSONFilename != "") {
|
||||
out << YAML::Key << "JSONFile" << YAML::Value << JSONFilename;
|
||||
if (JSONFileRotate != 0)
|
||||
out << YAML::Key << "JSONFileRotate" << YAML::Value << JSONFileRotate;
|
||||
|
||||
if (JSONFilter == meshtastic_PortNum_TEXT_MESSAGE_APP)
|
||||
out << YAML::Key << "JSONFilter" << YAML::Value << "textmessage";
|
||||
else if (JSONFilter == meshtastic_PortNum_TELEMETRY_APP)
|
||||
|
||||
Reference in New Issue
Block a user