]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change debug symboles to define
authorBastian Dehn <hhaalo@arcor.de>
Tue, 5 May 2026 14:24:12 +0000 (16:24 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 5 May 2026 14:24:12 +0000 (16:24 +0200)
src/kds_s2000w_debug.c

index 2adef04226d881f1932b4067c986997e0689929a..b5529bc202397b638e7b02837a8f90c8742f6691 100644 (file)
@@ -5,32 +5,43 @@
 
 #define STDOUT_LEVEL 3
 
+#define OFF_STR "OFF"
+#define FATAL_STR "FATAL"
+#define ERROR_STR "ERROR"
+#define WARN_STR "WARN"
+#define INFO_STR "INFO"
+#define DEBUG_STR "DEBUG"
+#define ALL_STR "ALL"
+#define UNKNOWN_STR "unknown"
+
+#define DEBUG_ENV_VAR "KDS_S2000W_NET_DEBUG"
+
 uint8_t kds_s2000w_log_level = 0;
 
 const char* _kds_s2000w_debug_string(uint8_t level)
 {
        switch(level) {
-       case 0:
-               return "OFF";
-       case 1:
-               return "FATAL";
-       case 2:
-               return "ERROR";
-       case 3:
-               return "WARN";
-       case 4:
-               return "INFO";
-       case 5:
-               return "DEBUG";
-       case 6:
-               return "ALL";
+       case OFF:
+               return OFF_STR;
+       case FATAL:
+               return FATAL_STR;
+       case ERROR:
+               return ERROR_STR;
+       case WARN:
+               return WARN_STR;
+       case INFO:
+               return INFO_STR;
+       case DEBUG:
+               return DEBUG_STR;
+       case ALL:
+               return ALL_STR;
        default:
-               return "unknown";
+               return UNKNOWN_STR;
        }
 }
 
 uint8_t kds_s2000w_debug_get_log_level() {
-       const char* log_level = getenv("KDS_S2000W_NET_DEBUG");
+       const char* log_level = getenv(DEBUG_ENV_VAR);
 
        if (log_level == NULL)
                return kds_s2000w_log_level;