State machine logging only when debug is active.

Tue, 02 Apr 2024 15:29:16 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 02 Apr 2024 15:29:16 +0200
changeset 655
780cc08df263
parent 654
e981d0185485
child 656
ca47c742a25d

State machine logging only when debug is active.

thermferm/one-wire.c file | annotate | diff | comparison | revisions
thermferm/statetbl.h file | annotate | diff | comparison | revisions
--- a/thermferm/one-wire.c	Tue Apr 02 15:03:12 2024 +0200
+++ b/thermferm/one-wire.c	Tue Apr 02 15:29:16 2024 +0200
@@ -18,6 +18,8 @@
  * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
+extern int		debug;
+
 #include "thermferm.h"
 #include "statetbl.h"
 #include "one-wire.h"
--- a/thermferm/statetbl.h	Tue Apr 02 15:03:12 2024 +0200
+++ b/thermferm/statetbl.h	Tue Apr 02 15:29:16 2024 +0200
@@ -23,7 +23,8 @@
 
 #define SM_START(x) \
     sm_state=x;\
-    syslog(LOG_NOTICE, "SM (%s): Start => %s", sm_name, sm_sname[sm_state]); \
+    if (debug)\
+	syslog(LOG_NOTICE, "SM (%s): Start => %s", sm_name, sm_sname[sm_state]); \
     while (!sm_success) switch (sm_state)\
     {\
     default: syslog(LOG_WARNING, "Statemachine %s error: state=%d",sm_name,sm_state);\
@@ -41,13 +42,14 @@
 }
 
 #define SM_PROCEED(x) \
-    if (x != sm_state) {\
+    if (x != sm_state && debug) {\
 	syslog(LOG_NOTICE, "SM (%s): %s => %s", sm_name, sm_sname[sm_state], sm_sname[x]);\
     }\
     sm_state=x; break;
 
 #define SM_SUCCESS \
-    syslog(LOG_NOTICE, "SM (%s): %s => Success", sm_name, sm_sname[sm_state]);\
+    if (debug)\
+	syslog(LOG_NOTICE, "SM (%s): %s => Success", sm_name, sm_sname[sm_state]);\
     sm_success=1; break;
 
 #define SM_ERROR \

mercurial