]> git.itanic.dy.fi Git - rrdd/blob - debug.h
process: Remove get_sibling_count()
[rrdd] / debug.h
1 #ifndef __DEBUG_H
2 #define __DEBUG_H
3
4 #include <time.h>
5 #include <unistd.h>
6 #include "process.h"
7
8 extern const char red_color[];
9 extern const char green_color[];
10 extern const char normal_color[];
11
12 #define pr_info(fmt, arg...)                                            \
13         do {                                                            \
14                 time_t t = time(0);                                     \
15                 char indent[16] = { "               " };                \
16                 char time[32];                                          \
17                                                                         \
18                 strftime(time, sizeof(time), "%d.%m.%Y %T ",            \
19                         localtime(&t));                                 \
20                 indent[get_parent_count()] = 0;                         \
21                                                                         \
22                 fprintf(stderr, "%s%s %s[%5d.%d] %s:%d %s"              \
23                         fmt, green_color, time, indent,                 \
24                         getpid(), get_parent_count(),                   \
25                         __FILE__, __LINE__, normal_color, ##arg);       \
26         } while (0)
27
28
29 #define pr_err(fmt, arg...)                                             \
30         do {                                                            \
31                 time_t t = time(0);                                     \
32                 char indent[16] = { "               " };                \
33                 char time[32];                                          \
34                                                                         \
35                 strftime(time, sizeof(time), "%d.%m.%Y %T ",            \
36                         localtime(&t));                                 \
37                 indent[get_parent_count()] = 0;                         \
38                                                                         \
39                 fprintf(stderr, "%s%s %s[%5d.%d] %s:%d Error %s"        \
40                         fmt, red_color, time, indent,                   \
41                         getpid(), get_parent_count(),                   \
42                         __FILE__, __LINE__, normal_color, ##arg);       \
43         } while (0)
44
45 #endif