]> git.itanic.dy.fi Git - rrdd/blob - debug.h
Change debug message output
[rrdd] / debug.h
1 #ifndef __DEBUG_H
2 #define __DEBUG_H
3
4 #include <unistd.h>
5 #include "process.h"
6
7 extern const char red_color[];
8 extern const char green_color[];
9 extern const char normal_color[];
10
11 #define pr_info(fmt, arg...)                                            \
12         do {                                                            \
13                 char indent[16] = { "               " };                \
14                 indent[get_parent_count()] = 0;                         \
15                 fprintf(stderr, "%s%s[%5d.%d] %s:%d %s"                 \
16                         fmt, indent, green_color,                       \
17                         getpid(), get_sibling_count(),                  \
18                         __FILE__, __LINE__, normal_color, ##arg);       \
19         } while (0)
20
21
22 #define pr_err(fmt, arg...)                                             \
23         do {                                                            \
24                 char indent[16] = { "               " };                \
25                 indent[get_parent_count()] = 0;                         \
26                 fprintf(stderr, "%s%s[%5d.%d] %s:%d Error %s"           \
27                         fmt, indent, red_color,                         \
28                         getpid(), get_sibling_count(),                  \
29                         __FILE__, __LINE__, normal_color, ##arg);       \
30         } while (0)
31
32 #endif