[Debug] Make CommandArgParser debug logs better readable

This commit is contained in:
TD-er committed 2026-09-10 23:58:30 +02:00
1 parent a850597aca
commit f6bd2ea643
2 files changed
+18 -3

No files matched your search

+3 -3
View File
@@ -639,12 +639,12 @@ String ValueStruct::debug() const
const String normalStr = toString();
const String unformattedStr = toString(true);
String logstr = strformat(
F("t:%d,'%s'"),
static_cast<int>(getValueType()),
F("%s:'%s'"),
toShortStr(getValueType()),
normalStr.c_str());
if (!normalStr.equals(unformattedStr)) {
logstr += strformat(F("u:'%s'"), unformattedStr.c_str());
logstr += strformat(F("/u:'%s'"), unformattedStr.c_str());
}
if (!operator bool()) {
+15
View File
@@ -12,6 +12,9 @@ class ValueStruct
{
public:
// Don't just extend these enums as they are part of very tightly packed struct.
// For example if 1 extra bit is needed, the start and length of the SSO must be adjusted.
enum class ValueType : uint8_t {
Unset = 0,
String,
@@ -24,6 +27,18 @@ public:
};
#ifndef BUILD_NO_DEBUG
static const char* toShortStr(ValueType valueType)
{
static const char* shortStrings = "---\0Str\0Fla\0flt\0dbl\0int\0uin\0boo\0";
constexpr uint8_t index_modulo = static_cast<uint8_t>(ValueType::Bool) + 1;
const uint8_t index = static_cast<uint8_t>(valueType) % index_modulo;
return shortStrings + 4*index;
}
#endif
enum class PreferredFormat : uint8_t {
Default = 0,
Dec,