GroupKV:Make LDBUG macros conditional, avoid condition at usage site
Also change LWARN to LDBUG wrt previously GKV_DEBUG conditional code
This commit is contained in:
parent
7f03dd0d4b
commit
fdefb39518
1 changed files with 13 additions and 13 deletions
|
@ -25,15 +25,25 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <format>
|
#include <format>
|
||||||
#define LINFO_LN(FMT, ...) fprintf(stdout, FMT"\n", ##__VA_ARGS__)
|
#define LINFO_LN(FMT, ...) fprintf(stdout, FMT"\n", ##__VA_ARGS__)
|
||||||
|
#ifdef GKV_DEBUG
|
||||||
#define LDBUG(FMT, ...) fprintf(stderr, FMT, ##__VA_ARGS__)
|
#define LDBUG(FMT, ...) fprintf(stderr, FMT, ##__VA_ARGS__)
|
||||||
#define LDBUG_LN(FMT, ...) fprintf(stderr, FMT"\n", ##__VA_ARGS__)
|
#define LDBUG_LN(FMT, ...) fprintf(stderr, FMT"\n", ##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define LDBUG_LN(...)
|
||||||
|
#define LDBUG(...)
|
||||||
|
#endif
|
||||||
#define LERRR_LN(FMT, ...) fprintf(stderr, FMT"\n", ##__VA_ARGS__)
|
#define LERRR_LN(FMT, ...) fprintf(stderr, FMT"\n", ##__VA_ARGS__)
|
||||||
#define LWARN_LN(FMT, ...) fprintf(stderr, FMT"\n", ##__VA_ARGS__)
|
#define LWARN_LN(FMT, ...) fprintf(stderr, FMT"\n", ##__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#define LINFO_LN LOG_TEELN
|
#define LINFO_LN LOG_TEELN
|
||||||
|
#ifdef GKV_DEBUG
|
||||||
#define LDBUG LOG
|
#define LDBUG LOG
|
||||||
#define LDBUG_LN LOGLN
|
#define LDBUG_LN LOGLN
|
||||||
|
#else
|
||||||
|
#define LDBUG_LN(...)
|
||||||
|
#define LDBUG(...)
|
||||||
|
#endif
|
||||||
#define LERRR_LN LOG_TEELN
|
#define LERRR_LN LOG_TEELN
|
||||||
#define LWARN_LN LOG_TEELN
|
#define LWARN_LN LOG_TEELN
|
||||||
#endif
|
#endif
|
||||||
|
@ -95,9 +105,7 @@ public:
|
||||||
auto key = joiner(keyParts);
|
auto key = joiner(keyParts);
|
||||||
auto &gm = mapV[group];
|
auto &gm = mapV[group];
|
||||||
gm[key] = value;
|
gm[key] = value;
|
||||||
#ifdef GKV_DEBUG
|
|
||||||
LDBUG_LN("DBUG:GKV:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(value).c_str());
|
LDBUG_LN("DBUG:GKV:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(value).c_str());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump info about the specified group.
|
// Dump info about the specified group.
|
||||||
|
@ -119,15 +127,11 @@ public:
|
||||||
auto key = joiner(keyParts);
|
auto key = joiner(keyParts);
|
||||||
auto gm = mapV[group];
|
auto gm = mapV[group];
|
||||||
if (gm.find(key) == gm.end()) {
|
if (gm.find(key) == gm.end()) {
|
||||||
#ifdef GKV_DEBUG
|
LDBUG_LN("WARN:GKV:%s_%s:%s:%s:%s[default]", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(defaultValue).c_str());
|
||||||
LWARN_LN("WARN:GKV:%s_%s:%s:%s:%s[default]", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(defaultValue).c_str());
|
|
||||||
#endif
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
auto value = gm[key];
|
auto value = gm[key];
|
||||||
#ifdef GKV_DEBUG
|
|
||||||
LDBUG_LN("DBUG:GKV:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(value).c_str());
|
LDBUG_LN("DBUG:GKV:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(value).c_str());
|
||||||
#endif
|
|
||||||
return std::get<SupportedDataType>(value);
|
return std::get<SupportedDataType>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,14 +152,10 @@ public:
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
if (array.empty()) {
|
if (array.empty()) {
|
||||||
#ifdef GKV_DEBUG
|
LDBUG_LN("WARN:GKV:%s_%s:%s:%s:%s[default]", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(defaultValue).c_str());
|
||||||
LWARN_LN("DBUG:GKV:%s_%s:%s:%s:%s[default]", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(defaultValue).c_str());
|
|
||||||
#endif
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
#ifdef GKV_DEBUG
|
LDBUG_LN("DBUG:GKV:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(array).c_str());
|
||||||
LDBUG_LN("DBUG:SC:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(array).c_str());
|
|
||||||
#endif
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue