From 240710fbbe5888da9be342142d0c9689d7b4e32e Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 8 Nov 2020 20:23:01 +0100 Subject: [PATCH] add syslog enabled - it was causing mem issues with esp32 --- .../src/project/EMSESPSettingsController.tsx | 17 +++++++--- interface/src/project/EMSESPtypes.ts | 1 + lib_standalone/ESP8266React.h | 3 +- src/WebSettingsService.cpp | 2 ++ src/WebSettingsService.h | 4 ++- src/system.cpp | 33 ++++++++++++++----- src/system.h | 1 + 7 files changed, 46 insertions(+), 15 deletions(-) diff --git a/interface/src/project/EMSESPSettingsController.tsx b/interface/src/project/EMSESPSettingsController.tsx index 24871b020..46060536e 100644 --- a/interface/src/project/EMSESPSettingsController.tsx +++ b/interface/src/project/EMSESPSettingsController.tsx @@ -209,11 +209,21 @@ function EMSESPSettingsControllerForm(props: EMSESPSettingsControllerFormProps) Syslog + + } + label="Enable Syslog" + /> - OFF ERR INFO DEBUG read([&](WiFiSettings & settings) { hostname(settings.hostname.c_str()); }); @@ -207,8 +212,11 @@ void System::upload_status(bool in_progress) { // checks system health and handles LED flashing wizardry void System::loop() { #ifndef EMSESP_STANDALONE - syslog_.loop(); + if (syslog_enabled_) { + syslog_.loop(); + } #endif + led_monitor(); // check status and report back using the LED system_check(); // check system health if (analog_enabled_) { @@ -481,13 +489,18 @@ void System::show_system(uuid::console::Shell & shell) { EMSESP::webSettingsService.read([&](WebSettings & settings) { shell.println(); - shell.printfln(F("Syslog:")); - shell.print(F_(1space)); - shell.printfln(F_(host_fmt), !settings.syslog_host.isEmpty() ? settings.syslog_host.c_str() : uuid::read_flash_string(F_(unset)).c_str()); - shell.print(F_(1space)); - shell.printfln(F_(log_level_fmt), uuid::log::format_level_lowercase(static_cast(settings.syslog_level))); - shell.print(F_(1space)); - shell.printfln(F_(mark_interval_fmt), settings.syslog_mark_interval); + + if (!settings.syslog_enabled) { + shell.printfln(F("Syslog: disabled")); + } else { + shell.printfln(F("Syslog:")); + shell.print(F_(1space)); + shell.printfln(F_(host_fmt), !settings.syslog_host.isEmpty() ? settings.syslog_host.c_str() : uuid::read_flash_string(F_(unset)).c_str()); + shell.print(F_(1space)); + shell.printfln(F_(log_level_fmt), uuid::log::format_level_lowercase(static_cast(settings.syslog_level))); + shell.print(F_(1space)); + shell.printfln(F_(mark_interval_fmt), settings.syslog_mark_interval); + } }); #endif @@ -803,6 +816,7 @@ bool System::check_upgrade() { settings.shower_timer = custom_settings["shower_timer"] | EMSESP_DEFAULT_SHOWER_TIMER; settings.master_thermostat = custom_settings["master_thermostat"] | EMSESP_DEFAULT_MASTER_THERMOSTAT; settings.ems_bus_id = custom_settings["bus_id"] | EMSESP_DEFAULT_EMS_BUS_ID; + settings.syslog_enabled = false; settings.syslog_host = EMSESP_DEFAULT_SYSLOG_HOST; settings.syslog_level = EMSESP_DEFAULT_SYSLOG_LEVEL; settings.syslog_mark_interval = EMSESP_DEFAULT_SYSLOG_MARK_INTERVAL; @@ -918,6 +932,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & json JsonObject node = json.createNestedObject("Settings"); node["tx_mode"] = settings.tx_mode; node["ems_bus_id"] = settings.ems_bus_id; + node["syslog_enabled"] = settings.syslog_enabled; node["syslog_level"] = settings.syslog_level; node["syslog_mark_interval"] = settings.syslog_mark_interval; node["syslog_host"] = settings.syslog_host; diff --git a/src/system.h b/src/system.h index 78f73f01a..32b6a8fae 100644 --- a/src/system.h +++ b/src/system.h @@ -109,6 +109,7 @@ class System { // settings static bool hide_led_; + static bool syslog_enabled_; uint8_t syslog_level_; uint32_t syslog_mark_interval_; String syslog_host_;