From 1a8de228d5fb0ebc2084cc6a757608d51d88ca2f Mon Sep 17 00:00:00 2001 From: John Date: Tue, 1 Oct 2024 07:10:35 +0200 Subject: [PATCH] add dedicated log level for device (closes #1280) --- src/ebusd/main_args.cpp | 4 ++-- src/lib/ebus/protocol.cpp | 4 ++-- src/lib/utils/log.cpp | 3 ++- src/lib/utils/log.h | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ebusd/main_args.cpp b/src/ebusd/main_args.cpp index 29e555db..12bb2646 100755 --- a/src/ebusd/main_args.cpp +++ b/src/ebusd/main_args.cpp @@ -203,8 +203,8 @@ static const argDef argDefs[] = { PACKAGE_LOGFILE "]"}, {"log", O_LOG, "AREAS:LEVEL", 0, "Only write log for matching AREA(S) up to LEVEL" " (alternative to --logareas/--logevel, may be used multiple times) [all:notice]"}, - {"logareas", O_LOGARE, "AREAS", 0, "Only write log for matching AREA(S): main|network|bus|update|other" - "|all [all]"}, + {"logareas", O_LOGARE, "AREAS", 0, "Only write log for matching AREA(S): main|network|bus|device|update" + "|other|all [all]"}, {"loglevel", O_LOGLEV, "LEVEL", 0, "Only write log up to LEVEL: error|notice|info|debug" " [notice]"}, diff --git a/src/lib/ebus/protocol.cpp b/src/lib/ebus/protocol.cpp index 1d80aee4..f74450a9 100644 --- a/src/lib/ebus/protocol.cpp +++ b/src/lib/ebus/protocol.cpp @@ -184,9 +184,9 @@ void ProtocolHandler::notifyDeviceData(const symbol_t* data, size_t len, bool re void ProtocolHandler::notifyDeviceStatus(bool error, const char* message) { if (error) { - logError(lf_bus, "device status: %s", message); + logError(lf_device, message); } else { - logNotice(lf_bus, "device status: %s", message); + logNotice(lf_device, message); } } diff --git a/src/lib/utils/log.cpp b/src/lib/utils/log.cpp index 5e04099c..89273c31 100755 --- a/src/lib/utils/log.cpp +++ b/src/lib/utils/log.cpp @@ -39,6 +39,7 @@ static const char *s_facilityNames[] = { "main", "network", "bus", + "device", "update", "other", "all", @@ -68,7 +69,7 @@ static const int s_syslogLevels[] = { #endif /** the current log level by log facility. */ -static LogLevel s_facilityLogLevel[] = { ll_notice, ll_notice, ll_notice, ll_notice, ll_notice, }; +static LogLevel s_facilityLogLevel[] = { ll_notice, ll_notice, ll_notice, ll_notice, ll_notice, ll_notice, }; /** the current log FILE, or nullptr if closed or syslog is used. */ static FILE* s_logFile = stdout; diff --git a/src/lib/utils/log.h b/src/lib/utils/log.h index 221fc114..d011e477 100755 --- a/src/lib/utils/log.h +++ b/src/lib/utils/log.h @@ -28,6 +28,7 @@ enum LogFacility { lf_main = 0, //!< main loop lf_network, //!< network related lf_bus, //!< eBUS related + lf_device, //!< device related lf_update, //!< updates found while listening to the bus lf_other, //!< all other log facilities lf_COUNT = 5 //!< number of available log facilities and flag for setting all