Prejmenovani TRACE_SYSVARS na DEBUG_SYSVARS (kompatibilita)

This commit is contained in:
Pavel Brychta 2024-07-29 16:14:38 +02:00
parent 1bf6581faa
commit 2ce7cbf772

View File

@ -10,8 +10,8 @@
#include <FS.h> #include <FS.h>
#include <trace.h> #include <trace.h>
#ifndef TRACE_SYSVARS #ifndef DEBUG_SYSVARS
# define TRACE_SYSVARS 0 # define DEBUG_SYSVARS 0
#endif #endif
#if not defined(SYSVAR_FILE) #if not defined(SYSVAR_FILE)
@ -26,19 +26,19 @@ T svGetV(const String & name, const T deflt)
File f = USEDFS.open(F(SYSVAR_FILE), "r"); File f = USEDFS.open(F(SYSVAR_FILE), "r");
if (f) { if (f) {
JsonDocument doc; JsonDocument doc;
DeserializationError err = deserializeJson(doc, f); const DeserializationError err = deserializeJson(doc, f);
if (err) { if (err) {
TRACEPLUS(TRACE_SYSVARS, TRACE_ERROR, "SV: Deserialize error '%s'", err.c_str()); // wrong JSON file (malformed) TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: Deserialize error '%s'", err.c_str()); // wrong JSON file (malformed)
} else { } else {
if (!doc.containsKey(name)) { if (!doc.containsKey(name)) {
TRACEPLUS(TRACE_SYSVARS, TRACE_ERROR, "SV: Key '%s' not found", name.c_str()); TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: Key '%s' not found", name.c_str());
} else { } else {
rv = doc[name].as<T>(); rv = doc[name].as<T>();
} }
} }
} else { } else {
TRACEPLUS(TRACE_SYSVARS, TRACE_ERROR, "SV: File not found"); TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: File not found");
} }
return rv; return rv;
} }
@ -51,19 +51,19 @@ T svGetVFile(const String & name, const String & fname, const T deflt)
if (f) { if (f) {
JsonDocument doc; JsonDocument doc;
DeserializationError err = deserializeJson(doc, f); const DeserializationError err = deserializeJson(doc, f);
if (err) { if (err) {
TRACEPLUS(TRACE_SYSVARS, TRACE_ERROR, "SV: Deserialize error '%s'", err.c_str()); // wrong JSON file (malformed) TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: Deserialize error '%s'", err.c_str()); // wrong JSON file (malformed)
} else { } else {
if (!doc.containsKey(name)) { if (!doc.containsKey(name)) {
TRACEPLUS(TRACE_SYSVARS, TRACE_ERROR, "SV: Key '%s' not found", name.c_str()); TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: Key '%s' not found", name.c_str());
} else { } else {
rv = doc[name].as<T>(); rv = doc[name].as<T>();
} }
} }
} else { } else {
TRACEPLUS(TRACE_SYSVARS, TRACE_ERROR, "SV: File not found '%s'", fname.c_str()); TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: File not found '%s'", fname.c_str());
} }
return rv; return rv;
} }
@ -86,7 +86,7 @@ int svSetV(const String & name, T value)
File f = USEDFS.open(F(SYSVAR_FILE), "r"); File f = USEDFS.open(F(SYSVAR_FILE), "r");
if (f) { if (f) {
DeserializationError err = deserializeJson(doc, f); const DeserializationError err = deserializeJson(doc, f);
if (err) { if (err) {
res = SV_DESERIALIZE_ERROR; // wrong (malformed) JSON file res = SV_DESERIALIZE_ERROR; // wrong (malformed) JSON file
} }
@ -123,7 +123,7 @@ int svSetVFile(const String & name, T value, const String & fname)
File f = USEDFS.open(fname, "r"); File f = USEDFS.open(fname, "r");
if (f) { if (f) {
DeserializationError err = deserializeJson(doc, f); const DeserializationError err = deserializeJson(doc, f);
if (err) { if (err) {
res = SV_DESERIALIZE_ERROR; // wrong (malformed) JSON file res = SV_DESERIALIZE_ERROR; // wrong (malformed) JSON file
} }