From a991d5530ac9cbdfbcced44f085f31bd7153e95a Mon Sep 17 00:00:00 2001 From: fvanroie Date: Wed, 25 Mar 2020 17:59:54 +0100 Subject: [PATCH] Switch to ArduinoLog library --- src/hasp_attr_get.cpp | 9 +++++---- src/hasp_attr_set.cpp | 14 +++++++------- src/hasp_button.cpp | 5 +++-- src/hasp_dispatch.cpp | 7 ++----- src/hasp_http.cpp | 3 ++- src/hasp_mdns.cpp | 10 +++++----- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/hasp_attr_get.cpp b/src/hasp_attr_get.cpp index 27eb47ac..2a1d6595 100644 --- a/src/hasp_attr_get.cpp +++ b/src/hasp_attr_get.cpp @@ -1,7 +1,8 @@ #include "Arduino.h" +#include "ArduinoLog.h" + #include "lvgl.h" #include "hasp.h" -#include "hasp_log.h" #include "hasp_attr_get.h" #define LVGL7 1 @@ -25,7 +26,7 @@ uint32_t get_cpicker_value(lv_obj_t * obj) bool haspGetLabelText(lv_obj_t * obj, std::string & strPayload) { if(!obj) { - errorPrintln(F("HASP: %sButton not defined")); + Log.warning(F("HASP: Button not defined")); return false; } @@ -40,7 +41,7 @@ bool haspGetLabelText(lv_obj_t * obj, std::string & strPayload) } } else { - warningPrintln(F("HASP: %shaspGetLabelText NULL Pointer encountered")); + Log.warning(F("HASP: haspGetLabelText NULL Pointer encountered")); } return false; @@ -211,7 +212,7 @@ bool haspGetObjAttribute(lv_obj_t * obj, String strAttr, std::string & strPayloa } break; default: - errorPrintln(F("HASP: %sUnknown property")); + Log.warning(F("HASP: Unknown property %s"), strAttr.c_str()); return false; } return false; diff --git a/src/hasp_attr_set.cpp b/src/hasp_attr_set.cpp index ee3370a8..4a4f401e 100644 --- a/src/hasp_attr_set.cpp +++ b/src/hasp_attr_set.cpp @@ -1,8 +1,8 @@ -#include "Arduino.h" +#include "ArduinoLog.h" + #include "lvgl.h" #include "lv_conf.h" #include "hasp.h" -#include "hasp_log.h" #include "hasp_attr_set.h" #define LVGL7 1 @@ -11,7 +11,7 @@ LV_FONT_DECLARE(unscii_8_icon); void haspAttributeNotFound(String & strAttr) { - errorPrintln(String(F("HASP: %sUnknown property ")) + strAttr); + Log.warning(F("HASP: Unknown property %s"), strAttr.c_str()); } void set_cpicker_value(lv_obj_t * obj, uint32_t color) @@ -22,7 +22,7 @@ void set_cpicker_value(lv_obj_t * obj, uint32_t color) void haspSetLabelText(lv_obj_t * obj, const char * value) { if(!obj) { - errorPrintln(F("HASP: %sButton not defined")); + Log.warning(F("HASP: Button not defined")); return; } @@ -32,12 +32,12 @@ void haspSetLabelText(lv_obj_t * obj, const char * value) lv_obj_get_type(label, &list); if(check_obj_type(list.type[0], LV_HASP_LABEL)) { - debugPrintln(String(F("HASP: Setting value to ")) + String(value)); + Log.verbose(F("HASP: Setting value to %s"), value); lv_label_set_text(label, value); } } else { - warningPrintln(F("HASP: %shaspSetLabelText NULL Pointer encountered")); + Log.error(F("HASP: haspSetLabelText NULL Pointer encountered")); } } @@ -507,7 +507,7 @@ void haspSetObjAttribute7(lv_obj_t * obj, String & strAttr, String & strPayload) void haspSetObjAttribute(lv_obj_t * obj, String strAttr, String strPayload) { if(!obj) { - errorPrintln(F("HASP: %sUnknown object")); + Log.warning(F("HASP: Unknown object")); return; } diff --git a/src/hasp_button.cpp b/src/hasp_button.cpp index 56f4a774..798da6bb 100644 --- a/src/hasp_button.cpp +++ b/src/hasp_button.cpp @@ -1,3 +1,5 @@ +#include "Arduino.h" +#include "ArduinoLog.h" #include "AceButton.h" #include "hasp_conf.h" @@ -5,7 +7,6 @@ #include "hasp_button.h" #include "hasp_dispatch.h" -#include "hasp_log.h" using namespace ace_button; AceButton * button[HASP_NUM_INPUTS]; // Connect your button between pin 2 and GND @@ -35,7 +36,7 @@ void buttonSetup(void) buttonConfig->setRepeatPressDelay(LV_INDEV_DEF_LONG_PRESS_TIME); buttonConfig->setRepeatPressInterval(LV_INDEV_DEF_LONG_PRESS_REP_TIME); - debugPrintln(F("BTNS: setup(): ready")); + Log.verbose(F("BTNS: setup(): ready")); } void buttonLoop(void) diff --git a/src/hasp_dispatch.cpp b/src/hasp_dispatch.cpp index 57793a12..7e6c147e 100644 --- a/src/hasp_dispatch.cpp +++ b/src/hasp_dispatch.cpp @@ -1,6 +1,6 @@ -#include "StringStream.h" #include "ArduinoJson.h" #include "ArduinoLog.h" +#include "StringStream.h" #include "hasp_dispatch.h" #include "hasp_config.h" @@ -8,7 +8,6 @@ #include "hasp_http.h" #include "hasp_mdns.h" #include "hasp_wifi.h" -#include "hasp_log.h" #include "hasp_gui.h" #include "hasp.h" @@ -241,8 +240,7 @@ void dispatchJson(char * payload) haspCommands.shrinkToFit(); if(jsonError) { // Couldn't parse incoming JSON command - errorPrintln(String(F("JSON: %sFailed to parse incoming JSON command with error: ")) + - String(jsonError.c_str())); + Log.warning(F("JSON: Failed to parse incoming JSON command with error: "), jsonError.c_str()); return; } @@ -254,7 +252,6 @@ void dispatchJson(char * payload) void dispatchJsonl(char * strPayload) { - Serial.println("JSONL\n"); DynamicJsonDocument config(256); String output((char *)0); diff --git a/src/hasp_http.cpp b/src/hasp_http.cpp index 62d9aaf9..f17847e6 100644 --- a/src/hasp_http.cpp +++ b/src/hasp_http.cpp @@ -2,12 +2,13 @@ #include "Arduino.h" #include "ArduinoJson.h" +#include "ArduinoLog.h" //#include "Update.h" #include "lvgl.h" #include "hasp_conf.h" -#include "hasp_log.h" +// #include "hasp_log.h" #include "hasp_gui.h" #include "hasp_hal.h" #include "hasp_debug.h" diff --git a/src/hasp_mdns.cpp b/src/hasp_mdns.cpp index 943caaf8..ac3d901f 100644 --- a/src/hasp_mdns.cpp +++ b/src/hasp_mdns.cpp @@ -1,5 +1,5 @@ -#include "Arduino.h" #include "ArduinoJson.h" +#include "ArduinoLog.h" #if defined(ARDUINO_ARCH_ESP32) #include @@ -10,7 +10,7 @@ #include "hasp_conf.h" -#include "hasp_log.h" +// #include "hasp_log.h" #include "hasp_mdns.h" #include "hasp_config.h" @@ -24,7 +24,7 @@ uint8_t mdnsEnabled = true; void mdnsSetup(const JsonObject & settings) { mdnsSetConfig(settings); - debugPrintln(F("MDNS: Setup Complete")); + Log.verbose(F("MDNS: Setup Complete")); } void mdnsStart() @@ -44,7 +44,7 @@ void mdnsStart() HASP_VERSION_REVISION); MDNS.addServiceTxt(hasp2Node, "tcp", "app_version", buffer); */ if(MDNS.begin(hasp2Node.c_str())) { - debugPrintln(F("MDNS: Responder started")); + Log.notice(F("MDNS: Responder started")); MDNS.addService(F("http"), F("tcp"), 80); MDNS.addService(F("telnet"), F("tcp"), 23); MDNS.addServiceTxt(hasp2Node, F("tcp"), F("app_name"), F("HASP-lvgl")); @@ -55,7 +55,7 @@ void mdnsStart() addServiceTxt("arduino", "tcp", "board", ARDUINO_BOARD); addServiceTxt("arduino", "tcp", "auth_upload", (auth) ? "yes" : "no");*/ } else { - errorPrintln(String(F("MDNS: %sResponder failed to start ")) + hasp2Node); + Log.error(F("MDNS: Responder failed to start %s"), hasp2Node.c_str()); }; } }