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 <trace.h>
#ifndef TRACE_SYSVARS
# define TRACE_SYSVARS 0
#ifndef DEBUG_SYSVARS
# define DEBUG_SYSVARS 0
#endif
#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");
if (f) {
JsonDocument doc;
DeserializationError err = deserializeJson(doc, f);
const DeserializationError err = deserializeJson(doc, f);
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 {
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 {
rv = doc[name].as<T>();
}
}
} else {
TRACEPLUS(TRACE_SYSVARS, TRACE_ERROR, "SV: File not found");
TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: File not found");
}
return rv;
}
@ -51,19 +51,19 @@ T svGetVFile(const String & name, const String & fname, const T deflt)
if (f) {
JsonDocument doc;
DeserializationError err = deserializeJson(doc, f);
const DeserializationError err = deserializeJson(doc, f);
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 {
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 {
rv = doc[name].as<T>();
}
}
} 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;
}
@ -86,7 +86,7 @@ int svSetV(const String & name, T value)
File f = USEDFS.open(F(SYSVAR_FILE), "r");
if (f) {
DeserializationError err = deserializeJson(doc, f);
const DeserializationError err = deserializeJson(doc, f);
if (err) {
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");
if (f) {
DeserializationError err = deserializeJson(doc, f);
const DeserializationError err = deserializeJson(doc, f);
if (err) {
res = SV_DESERIALIZE_ERROR; // wrong (malformed) JSON file
}