simplify log facility handling

This commit is contained in:
John
2024-02-24 13:25:07 +01:00
parent 3d623659b1
commit d6ea68db94
3 changed files with 4 additions and 11 deletions
+1 -1
View File
@@ -256,7 +256,7 @@ int main(int argc, char* argv[], char* envp[]) {
}
if (s_opt.logAreas != -1 || s_opt.logLevel != ll_COUNT) {
setFacilitiesLogLevel(LF_ALL, ll_none);
setFacilitiesLogLevel(1<<ll_COUNT, ll_none);
setFacilitiesLogLevel(s_opt.logAreas, s_opt.logLevel);
}
+2 -6
View File
@@ -103,11 +103,7 @@ int parseLogFacilities(const char* facilities) {
free(input);
return -1;
}
if (val == lf_COUNT) {
newFacilites = LF_ALL;
} else {
newFacilites |= 1 << val;
}
newFacilites |= 1 << val;
}
free(input);
return newFacilites;
@@ -139,7 +135,7 @@ const char* getLogLevelStr(LogLevel level) {
bool setFacilitiesLogLevel(int facilities, LogLevel level) {
bool changed = false;
for (int val = 0; val < lf_COUNT && facilities != 0; val++) {
if ((facilities & (1 << val)) != 0 && s_facilityLogLevel[(LogFacility)val] != level) {
if ((facilities & ((1 << val)|(1 << lf_COUNT))) != 0 && s_facilityLogLevel[(LogFacility)val] != level) {
s_facilityLogLevel[(LogFacility)val] = level;
changed = true;
}
+1 -4
View File
@@ -30,12 +30,9 @@ enum LogFacility {
lf_bus, //!< eBUS related
lf_update, //!< updates found while listening to the bus
lf_other, //!< all other log facilities
lf_COUNT = 5 //!< number of available log facilities
lf_COUNT = 5 //!< number of available log facilities and flag for setting all
};
/** macro for all log facilities. */
#define LF_ALL ((1 << lf_main) | (1 << lf_network) | (1 << lf_bus) | (1 << lf_update) | (1 << lf_other))
/** the available log levels. */
enum LogLevel {
ll_none = 0, //!< no level at all