no-OS
print_log.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef PRINT_LOG_H_
41 #define PRINT_LOG_H_
42 
43 #include <stdio.h>
44 
45 #define LOG_EMERG 0x0
46 #define LOG_ALERT 0x1
47 #define LOG_CRIT 0x2
48 #define LOG_ERR 0x3
49 #define LOG_WARNING 0x4
50 #define LOG_NOTICE 0x5
51 #define LOG_INFO 0x6
52 #define LOG_DEBUG 0x7
53 
54 #ifndef LOG_LEVEL
55 #define LOG_LEVEL LOG_INFO
56 #endif
57 
58 #if defined(LOG_LEVEL) && LOG_LEVEL >= LOG_EMERG && LOG_LEVEL <= LOG_DEBUG
59 #define pr_emerg(fmt, args...) printf("EMERG: %s:%d:%s(): " \
60 fmt, __FILE__, __LINE__, __func__, ##args)
61 #else
62 #define pr_emerg(fmt, args...)
63 #endif
64 
65 #if defined(LOG_LEVEL) && LOG_LEVEL >= LOG_ALERT && LOG_LEVEL <= LOG_DEBUG
66 #define pr_alert(fmt, args...) printf("ALERT: %s:%d:%s(): " \
67 fmt, __FILE__, __LINE__, __func__, ##args)
68 #else
69 #define pr_alert(fmt, args...)
70 #endif
71 
72 #if defined(LOG_LEVEL) && LOG_LEVEL >= LOG_CRIT && LOG_LEVEL <= LOG_DEBUG
73 #define pr_crit(fmt, args...) printf("CRIT: %s:%d:%s(): " \
74 fmt, __FILE__, __LINE__, __func__, ##args)
75 #else
76 #define pr_crit(fmt, args...)
77 #endif
78 
79 #if defined(LOG_LEVEL) && LOG_LEVEL >= LOG_ERR && LOG_LEVEL <= LOG_DEBUG
80 #define pr_err(fmt, args...) printf("ERR: %s:%d:%s(): " \
81 fmt, __FILE__, __LINE__, __func__, ##args)
82 #else
83 #define pr_err(fmt, args...)
84 #endif
85 
86 #if defined(LOG_LEVEL) && LOG_LEVEL >= LOG_WARNING && LOG_LEVEL <= LOG_DEBUG
87 #define pr_warning(fmt, args...) printf("WARNING: " fmt, ##args)
88 #else
89 #define pr_warning(fmt, args...)
90 #endif
91 
92 #if defined(LOG_LEVEL) && LOG_LEVEL >= LOG_NOTICE && LOG_LEVEL <= LOG_DEBUG
93 #define pr_notice(fmt, args...) printf("NOTICE: " fmt, ##args)
94 #else
95 #define pr_notice(fmt, args...)
96 #endif
97 
98 #if defined(LOG_LEVEL) && LOG_LEVEL >= LOG_INFO && LOG_LEVEL <= LOG_DEBUG
99 #define pr_info(fmt, args...) printf(fmt, ##args)
100 #else
101 #define pr_info(fmt, args...)
102 #endif
103 
104 #if defined(LOG_LEVEL) && LOG_LEVEL == LOG_DEBUG
105 #define pr_debug(fmt, args...) printf("DEBUG: " fmt, ##args)
106 #else
107 #define pr_debug(fmt, args...)
108 #endif
109 
110 #endif /* PRINT_LOG_H_ */