GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||
GeezerVison is showing lirc.org — LIRC libraries: /home/columbus/software/lirc-doc/lib/lirc_log.h (6bfe0ff 2016-04-26 15:59:19 +0200) Source File
AllClassesFilesFunctionsVariablesTypedefsEnumerationsMacrosModulesPages
lirc_log.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** lirc_log.h **************************************************************
3 ****************************************************************************
4 *
5 */
6
15 #ifndef _LIRC_LOG_H
16 #define _LIRC_LOG_H
17
18 #include <syslog.h>
19 #include <sys/time.h>
20 #include <stdio.h>
21 #include <unistd.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
37 LIRC_TRACE2 = 10,
38 LIRC_TRACE1 = 9,
39 LIRC_TRACE = 8,
40 LIRC_DEBUG = LOG_DEBUG,
41 LIRC_INFO = LOG_INFO,
42 LIRC_NOTICE = LOG_NOTICE,
43 LIRC_WARNING = LOG_WARNING,
44 LIRC_ERROR = LOG_ERR,
45 LIRC_NOLOG = 0,
46 LIRC_BADLEVEL = -1
47 } loglevel_t;
48
54 LOG_DRIVER = 1,
55 LOG_LIB = 4,
56 LOG_APP = 8,
57 LOG_ALL = 255
58 } logchannel_t;
59
61 #define LIRC_MAX_LOGLEVEL LIRC_TRACE2
62
64 #define LIRC_MIN_LOGLEVEL LIRC_ERROR
65
68
71
74
75 /* Set by lirc_log_open, convenience copy for clients. */
76 extern char progname[128];
77
79 #define DEFAULT_LOGLEVEL LIRC_INFO
80
82 #ifdef __cplusplus
83 #define logmax(l) (l > LIRC_DEBUG ? LIRC_DEBUG : static_cast <loglevel_t>(l))
84 #else
85 #define logmax(l) (l > LIRC_DEBUG ? LIRC_DEBUG : l)
86 #endif
87
89 #define log_perror_err(fmt, ...) \
90 { if ((logchannel & logged_channels) && LIRC_ERROR <= loglevel) \
91 { logperror(LIRC_ERROR, fmt, ##__VA_ARGS__); } }
92
94 #define log_perror_warn(fmt, ...) \
95 { if ((logchannel & logged_channels) && LIRC_WARNING <= loglevel) \
96 { logperror(LIRC_WARNING, fmt, ##__VA_ARGS__); } }
97
99 #define log_perror_debug(fmt, ...) \
100 { if ((logchannel & logged_channels) && LIRC_DEBUG <= loglevel) \
101 { logperror(LIRC_WARNING, fmt, ##__VA_ARGS__); } }
102
104 #define log_error(fmt, ...) \
105 { if ((logchannel & logged_channels) && LIRC_ERROR <= loglevel) \
106 { logprintf(LIRC_ERROR, fmt, ##__VA_ARGS__); } }
107
109 #define log_warn(fmt, ...) \
110 { if ((logchannel & logged_channels) && LIRC_WARNING <= loglevel) \
111 { logprintf(LIRC_WARNING, fmt, ##__VA_ARGS__); } }
112
114 #define log_info(fmt, ...) \
115 { if ((logchannel & logged_channels) && LIRC_INFO <= loglevel) \
116 { logprintf(LIRC_INFO, fmt, ##__VA_ARGS__); } }
117
119 #define log_notice(fmt, ...) \
120 { if ((logchannel & logged_channels) && LIRC_NOTICE <= loglevel) \
121 { logprintf(LIRC_NOTICE, fmt, ##__VA_ARGS__); } }
122
124 #define log_debug(fmt, ...) \
125 { if ((logchannel & logged_channels) && LIRC_DEBUG <= loglevel) \
126 { logprintf(LIRC_DEBUG, fmt, ##__VA_ARGS__); } }
127
129 #define log_trace(fmt, ...) \
130 { if ((logchannel & logged_channels) && LIRC_TRACE <= loglevel) \
131 { logprintf(LIRC_TRACE, fmt, ##__VA_ARGS__); } }
132
134 #define log_trace1(fmt, ...) \
135 { if ((logchannel & logged_channels) && LIRC_TRACE1 <= loglevel) \
136 { logprintf(LIRC_TRACE1, fmt, ##__VA_ARGS__); } }
137
139 #define log_trace2(fmt, ...) \
140 { if ((logchannel & logged_channels) && LIRC_TRACE2 <= loglevel) \
141 { logprintf(LIRC_TRACE2, fmt, ##__VA_ARGS__); } }
142
143
149
152
155
157 #define lirc_log_is_enabled_for(level) (level <= loglevel)
158
161
170
173 int lirc_log_reopen(void);
174
185
188
194
204
207
209 #define STRINGIFY(x) #x
210
212 #define STR(x) STRINGIFY(x)
213
215 #define chk_write(fd, buf, count) \
216 do_chk_write(fd, buf, count, STR(__FILE__) ":" STR(__LINE__))
217
218
220 #define chk_read(fd, buf, count) \
221 do_chk_read(fd, buf, count, STR(__FILE__) ":" STR(__LINE__))
222
223
225 static inline void
226 do_chk_write(int fd, const void* buf, size_t count, const char* msg)
227 {
228 if (write(fd, buf, count) == -1)
229 logperror(LIRC_WARNING, msg);
230 }
231
232
234 static inline void
235 do_chk_read(int fd, void* buf, size_t count, const char* msg)
236 {
237 if (read(fd, buf, count) == -1)
238 logperror(LIRC_WARNING, msg);
239 }
240
241
242
245 #ifdef __cplusplus
246 }
247 #endif
248
249 #endif /* _LIRC_LOG_H */
loglevel_t string2loglevel(const char *level) Convert a string, either a number or 'info', 'trace1', error etc. Definition: lirc_log.c:234 void hexdump(char *prefix, unsigned char *buf, int len) Print prefix + a hex dump of len bytes starting at *buf. Definition: lirc_log.c:369 void logprintf(loglevel_t prio, const char *format_str,...) Write a message to the log. Definition: lirc_log.c:273 void perrorf(const char *format,...) Adds printf-style arguments to perror(3). Definition: lirc_log.c:254 int lirc_log_open(const char *progname, int _nodaemon, loglevel_t level) Open the log for upcoming logging. Definition: lirc_log.c:95 loglevel_t lirc_log_defaultlevel(void) Get the default level, from environment or hardcoded. Definition: lirc_log.c:219 int lirc_log_get_clientlog(const char *basename, char *buffer, ssize_t size) Retrieve a client path for logging according to freedesktop specs. Definition: lirc_log.c:332 void logperror(loglevel_t prio, const char *format,...) Log current kernel error with a given level. Definition: lirc_log.c:310 int lirc_log_close(void) Close the log previosly opened with lirc_log_open(). Definition: lirc_log.c:137
| ||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |