#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[%d.%5d] %s:%d %s" \
- fmt, indent, green_color, get_process_count(), \
- getpid(), \
- __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[%d.%5d] %s:%d Error %s" \
- fmt, indent, red_color, get_process_count(), \
- getpid(), \
- __FILE__, __LINE__, normal_color, ##arg); \
- } while (0)
+int open_log_file(const char *logfile);
#endif