]> git.itanic.dy.fi Git - rrdd/blobdiff - debug.h
onewire_parser.c: Fix compiler warnings about string lengths
[rrdd] / debug.h
diff --git a/debug.h b/debug.h
index 34e448f83727205d41d45a960d2c94f789079347..882c6db5538273621cfec8390864a96ae2a694d0 100644 (file)
--- a/debug.h
+++ b/debug.h
@@ -1,32 +1,29 @@
 #ifndef __DEBUG_H
 #define __DEBUG_H
 
-#include <unistd.h>
-#include "process.h"
-
 extern const char red_color[];
 extern const char green_color[];
 extern const char normal_color[];
 
-#define pr_info(fmt, arg...)                                           \
-       do {                                                            \
-               char indent[16] = { "               " };                \
-               indent[get_parent_count()] = 0;                         \
-               fprintf(stderr, "%s%s[%5d.%d] %s:%d %s"                 \
-                       fmt, indent, green_color,                       \
-                       getpid(), get_sibling_count(),                  \
-                       __FILE__, __LINE__, normal_color, ##arg);       \
-       } while (0)
+extern int trace_level;
+
+enum {
+       TRACE_ERR,
+       TRACE_WARN,
+       TRACE_INFO,
+       TRACE_DEBUG,
+       TRACE_MAX,
+};
+
+void  __attribute__ ((__format__ (__printf__, 5, 6)))
+print_trace(const char *file, int line, int color, int l,
+               const char *fmt, ...);
 
+#define pr_err(arg...)   print_trace(__FILE__, __LINE__, 1, TRACE_ERR, arg)
+#define pr_warn(arg...)  print_trace(__FILE__, __LINE__, 2, TRACE_WARN, arg)
+#define pr_info(arg...)  print_trace(__FILE__, __LINE__, 2, TRACE_INFO, arg)
+#define pr_debug(arg...) print_trace(__FILE__, __LINE__, 2, TRACE_DEBUG, arg)
 
-#define pr_err(fmt, arg...)                                            \
-       do {                                                            \
-               char indent[16] = { "               " };                \
-               indent[get_parent_count()] = 0;                         \
-               fprintf(stderr, "%s%s[%5d.%d] %s:%d Error %s"           \
-                       fmt, indent, red_color,                         \
-                       getpid(), get_sibling_count(),                  \
-                       __FILE__, __LINE__, normal_color, ##arg);       \
-       } while (0)
+int open_log_file(const char *logfile);
 
 #endif