40 LIRC_DEBUG = LOG_DEBUG,
42 LIRC_NOTICE = LOG_NOTICE,
43 LIRC_WARNING = LOG_WARNING,
61 #define LIRC_MAX_LOGLEVEL LIRC_TRACE2
64 #define LIRC_MIN_LOGLEVEL LIRC_ERROR
67 void perrorf(
const char* format, ...);
76 extern char progname[128];
79 #define DEFAULT_LOGLEVEL LIRC_INFO
83 #define logmax(l) (l > LIRC_DEBUG ? LIRC_DEBUG : static_cast <loglevel_t>(l))
85 #define logmax(l) (l > LIRC_DEBUG ? LIRC_DEBUG : l)
89 #define log_perror_err(fmt, ...) \
90 { if ((logchannel & logged_channels) && LIRC_ERROR <= loglevel) \
91 { logperror(LIRC_ERROR, fmt, ##__VA_ARGS__); } }
94 #define log_perror_warn(fmt, ...) \
95 { if ((logchannel & logged_channels) && LIRC_WARNING <= loglevel) \
96 { logperror(LIRC_WARNING, fmt, ##__VA_ARGS__); } }
99 #define log_perror_debug(fmt, ...) \
100 { if ((logchannel & logged_channels) && LIRC_DEBUG <= loglevel) \
101 { logperror(LIRC_WARNING, fmt, ##__VA_ARGS__); } }
104 #define log_error(fmt, ...) \
105 { if ((logchannel & logged_channels) && LIRC_ERROR <= loglevel) \
106 { logprintf(LIRC_ERROR, fmt, ##__VA_ARGS__); } }
109 #define log_warn(fmt, ...) \
110 { if ((logchannel & logged_channels) && LIRC_WARNING <= loglevel) \
111 { logprintf(LIRC_WARNING, fmt, ##__VA_ARGS__); } }
114 #define log_info(fmt, ...) \
115 { if ((logchannel & logged_channels) && LIRC_INFO <= loglevel) \
116 { logprintf(LIRC_INFO, fmt, ##__VA_ARGS__); } }
119 #define log_notice(fmt, ...) \
120 { if ((logchannel & logged_channels) && LIRC_NOTICE <= loglevel) \
121 { logprintf(LIRC_NOTICE, fmt, ##__VA_ARGS__); } }
124 #define log_debug(fmt, ...) \
125 { if ((logchannel & logged_channels) && LIRC_DEBUG <= loglevel) \
126 { logprintf(LIRC_DEBUG, fmt, ##__VA_ARGS__); } }
129 #define log_trace(fmt, ...) \
130 { if ((logchannel & logged_channels) && LIRC_TRACE <= loglevel) \
131 { logprintf(LIRC_TRACE, fmt, ##__VA_ARGS__); } }
134 #define log_trace1(fmt, ...) \
135 { if ((logchannel & logged_channels) && LIRC_TRACE1 <= loglevel) \
136 { logprintf(LIRC_TRACE1, fmt, ##__VA_ARGS__); } }
139 #define log_trace2(fmt, ...) \
140 { if ((logchannel & logged_channels) && LIRC_TRACE2 <= loglevel) \
141 { logprintf(LIRC_TRACE2, fmt, ##__VA_ARGS__); } }
157 #define lirc_log_is_enabled_for(level) (level <= loglevel)
173 int lirc_log_reopen(
void);
206 void hexdump(
char* prefix,
unsigned char* buf,
int len);
209 #define STRINGIFY(x) #x
212 #define STR(x) STRINGIFY(x)
215 #define chk_write(fd, buf, count) \
216 do_chk_write(fd, buf, count, STR(__FILE__) ":" STR(__LINE__))
220 #define chk_read(fd, buf, count) \
221 do_chk_read(fd, buf, count, STR(__FILE__) ":" STR(__LINE__))
226 do_chk_write(
int fd,
const void* buf,
size_t count,
const char* msg)
228 if (write(fd, buf, count) == -1)
235 do_chk_read(
int fd,
void* buf,
size_t count,
const char* msg)
237 if (read(fd, buf, count) == -1)
loglevel_t string2loglevel(const char *level)
Convert a string, either a number or 'info', 'trace1', error etc.
loglevel_t loglevel
The actual loglevel.
void lirc_log_set_file(const char *s)
Set logfile.
int lirc_log_use_syslog(void)
Check if log is set up to use syslog or not.
logchannel_t
Log channels used to filter messages.
loglevel_t
The defined loglevels.
void hexdump(char *prefix, unsigned char *buf, int len)
Print prefix + a hex dump of len bytes starting at *buf.
void logprintf(loglevel_t prio, const char *format_str,...)
Write a message to the log.
void perrorf(const char *format,...)
Adds printf-style arguments to perror(3).
int lirc_log_open(const char *progname, int _nodaemon, loglevel_t level)
Open the log for upcoming logging.
loglevel_t lirc_log_defaultlevel(void)
Get the default level, from environment or hardcoded.
int lirc_log_get_clientlog(const char *basename, char *buffer, ssize_t size)
Retrieve a client path for logging according to freedesktop specs.
void logperror(loglevel_t prio, const char *format,...)
Log current kernel error with a given level.
int lirc_log_close(void)
Close the log previosly opened with lirc_log_open().
int lirc_log_setlevel(loglevel_t level)
Set the level.
logchannel_t logged_channels
The actual logchannel.