forked from kronosnet/kronosnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
32 lines (26 loc) · 782 Bytes
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef __UTILS_H__
#define __UTILS_H__
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <syslog.h>
extern int utils_debug;
extern int utils_syslog;
#define log_debug(fmt, args...) \
do { \
if (utils_debug) { \
printf("DEBUG(%s:%i|%s): " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##args); \
if (utils_syslog) syslog(LOG_DEBUG, "DEBUG(%s:%i|%s): " fmt, __FILE__, __LINE__, __FUNCTION__, ##args); \
} \
} while (0);
#define log_info(fmt, args...) \
do { \
fprintf(stderr, "Notice: " fmt "\n", ##args); \
if (utils_syslog) syslog(LOG_INFO, fmt, ##args); \
} while (0);
#define log_error(fmt, args...) \
do { \
fprintf(stderr, "Error: " fmt " (%s)\n", ##args, strerror(errno)); \
if (utils_syslog) syslog(LOG_ERR, fmt, ##args); \
} while (0);
#endif