LIRC libraries
Linux Infrared Remote Control
|
Logging functionality. More...
#include <syslog.h>
#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
Go to the source code of this file.
Macros | |
#define | LIRC_MAX_LOGLEVEL LIRC_TRACE2 |
Max loglevel (for validation). | |
#define | LIRC_MIN_LOGLEVEL LIRC_ERROR |
Mix loglevel (for validation). | |
#define | DEFAULT_LOGLEVEL LIRC_INFO |
Default loglevel (last resort). | |
#define | logmax(l) |
Max level logged in actual logfile. | |
#define | log_perror_err(fmt, ...) |
perror wrapper logging with level LIRC_ERROR. | |
#define | log_perror_warn(fmt, ...) |
perror wrapper logging with level LIRC_WARNING. | |
#define | log_perror_debug(fmt, ...) |
perror wrapper logging with level LIRC_DEBUG. | |
#define | log_error(fmt, ...) |
Log an error message. | |
#define | log_warn(fmt, ...) |
Log a warning message. | |
#define | log_info(fmt, ...) |
Log an info message. | |
#define | log_notice(fmt, ...) |
Log a notice message. | |
#define | log_debug(fmt, ...) |
Log a debug message. | |
#define | log_trace(fmt, ...) |
Log a trace message. | |
#define | log_trace1(fmt, ...) |
Log a trace1 message. | |
#define | log_trace2(fmt, ...) |
Log a trace2 message. | |
#define | lirc_log_is_enabled_for(level) |
Check if a given, standard loglevel should be printed. | |
#define | STRINGIFY(x) |
Helper macro for STR(). | |
#define | STR(x) |
Return x in (double) quotes. | |
#define | chk_write(fd, buf, count) |
Wrapper for write(2) which logs errors. | |
#define | chk_read(fd, buf, count) |
Wrapper for read(2) which logs errors. | |
Enumerations | |
enum | loglevel_t { LIRC_TRACE2 = 10 , LIRC_TRACE1 = 9 , LIRC_TRACE = 8 , LIRC_DEBUG = LOG_DEBUG , LIRC_INFO = LOG_INFO , LIRC_NOTICE = LOG_NOTICE , LIRC_WARNING = LOG_WARNING , LIRC_ERROR = LOG_ERR , LIRC_NOLOG = 0 , LIRC_BADLEVEL = -1 } |
The defined loglevels. More... | |
enum | logchannel_t { LOG_DRIVER = 1 , LOG_LIB = 4 , LOG_APP = 8 , LOG_ALL = 255 } |
Log channels used to filter messages. More... | |
Functions | |
void | perrorf (const char *format,...) |
Adds printf-style arguments to perror(3). | |
loglevel_t | string2loglevel (const char *level) |
Convert a string, either a number or 'info', 'trace1', error etc. | |
int | lirc_log_setlevel (loglevel_t level) |
Set the level. | |
loglevel_t | lirc_log_defaultlevel (void) |
Get the default level, from environment or hardcoded. | |
int | lirc_log_use_syslog (void) |
Check if log is set up to use syslog or not. | |
void | logprintf (loglevel_t prio, const char *format_str,...) |
Write a message to the log. | |
void | logperror (loglevel_t prio, const char *format,...) |
Log current kernel error with a given level. | |
int | lirc_log_reopen (void) |
int | lirc_log_open (const char *progname, int _nodaemon, loglevel_t level) |
Open the log for upcoming logging. | |
int | lirc_log_close (void) |
Close the log previosly opened with lirc_log_open(). | |
void | lirc_log_set_file (const char *s) |
Set logfile. | |
int | lirc_log_get_clientlog (const char *basename, char *buffer, ssize_t size) |
Retrieve a client path for logging according to freedesktop specs. | |
void | hexdump (char *prefix, unsigned char *buf, int len) |
Print prefix + a hex dump of len bytes starting at *buf. | |
Variables | |
loglevel_t | loglevel |
The actual loglevel. | |
logchannel_t | logged_channels |
The actual logchannel. | |
char | progname [128] |
Logging functionality.
Definition in file lirc_log.h.
#define chk_read | ( | fd, | |
buf, | |||
count ) |
#define chk_write | ( | fd, | |
buf, | |||
count ) |
Wrapper for write(2) which logs errors.
Definition at line 215 of file lirc_log.h.
#define DEFAULT_LOGLEVEL LIRC_INFO |
Default loglevel (last resort).
Definition at line 79 of file lirc_log.h.
#define lirc_log_is_enabled_for | ( | level | ) |
Check if a given, standard loglevel should be printed.
Definition at line 157 of file lirc_log.h.
#define LIRC_MAX_LOGLEVEL LIRC_TRACE2 |
Max loglevel (for validation).
Definition at line 61 of file lirc_log.h.
#define LIRC_MIN_LOGLEVEL LIRC_ERROR |
Mix loglevel (for validation).
Definition at line 64 of file lirc_log.h.
#define log_debug | ( | fmt, | |
... ) |
Log a debug message.
Definition at line 124 of file lirc_log.h.
#define log_error | ( | fmt, | |
... ) |
Log an error message.
Definition at line 104 of file lirc_log.h.
#define log_info | ( | fmt, | |
... ) |
Log an info message.
Definition at line 114 of file lirc_log.h.
#define log_notice | ( | fmt, | |
... ) |
Log a notice message.
Definition at line 119 of file lirc_log.h.
#define log_perror_debug | ( | fmt, | |
... ) |
perror wrapper logging with level LIRC_DEBUG.
Definition at line 99 of file lirc_log.h.
#define log_perror_err | ( | fmt, | |
... ) |
perror wrapper logging with level LIRC_ERROR.
Definition at line 89 of file lirc_log.h.
#define log_perror_warn | ( | fmt, | |
... ) |
perror wrapper logging with level LIRC_WARNING.
Definition at line 94 of file lirc_log.h.
#define log_trace | ( | fmt, | |
... ) |
Log a trace message.
Definition at line 129 of file lirc_log.h.
#define log_trace1 | ( | fmt, | |
... ) |
Log a trace1 message.
Definition at line 134 of file lirc_log.h.
#define log_trace2 | ( | fmt, | |
... ) |
Log a trace2 message.
Definition at line 139 of file lirc_log.h.
#define log_warn | ( | fmt, | |
... ) |
Log a warning message.
Definition at line 109 of file lirc_log.h.
#define logmax | ( | l | ) |
Max level logged in actual logfile.
Definition at line 85 of file lirc_log.h.
#define STR | ( | x | ) |
#define STRINGIFY | ( | x | ) |
enum logchannel_t |
Log channels used to filter messages.
Definition at line 53 of file lirc_log.h.
enum loglevel_t |
The defined loglevels.
LIRC_TRACE..LIRC_TRACE2 is mapped to LIRC_DEBUG in outputted messages, but generates more messages than DEBUG.
Definition at line 36 of file lirc_log.h.
void hexdump | ( | char * | prefix, |
unsigned char * | buf, | ||
int | len ) |
Print prefix + a hex dump of len bytes starting at *buf.
Definition at line 369 of file lirc_log.c.
int lirc_log_close | ( | void | ) |
Close the log previosly opened with lirc_log_open().
Definition at line 137 of file lirc_log.c.
loglevel_t lirc_log_defaultlevel | ( | void | ) |
Get the default level, from environment or hardcoded.
Definition at line 219 of file lirc_log.c.
int lirc_log_get_clientlog | ( | const char * | basename, |
char * | buffer, | ||
ssize_t | size ) |
Retrieve a client path for logging according to freedesktop specs.
basename | Basename for the logfile. |
buff | Buffer to store result in. |
size | Size of buffer |
Definition at line 332 of file lirc_log.c.
int lirc_log_open | ( | const char * | progname, |
int | _nodaemon, | ||
loglevel_t | level ) |
Open the log for upcoming logging.
progname | Name of application, made available in global progname |
nodaemon | If true, program runs in foreground and logging is on also on stdout. |
level | The lowest level of messages to actually be logged. |
Definition at line 95 of file lirc_log.c.
int lirc_log_reopen | ( | void | ) |
Definition at line 150 of file lirc_log.c.
void lirc_log_set_file | ( | const char * | s | ) |
Set logfile.
Either a regular path or the string 'syslog'; the latter does indeed use syslog(1) instead. Must be called before lirc_log_open().
Definition at line 84 of file lirc_log.c.
int lirc_log_setlevel | ( | loglevel_t | level | ) |
int lirc_log_use_syslog | ( | void | ) |
Check if log is set up to use syslog or not.
Definition at line 78 of file lirc_log.c.
void logperror | ( | loglevel_t | prio, |
const char * | fmt, | ||
... ) |
Log current kernel error with a given level.
Log current kernel error with a given level.
prio | Priority of log request. |
fmt | printf-style format string |
Definition at line 310 of file lirc_log.c.
void logprintf | ( | loglevel_t | prio, |
const char * | format_str, | ||
... ) |
Write a message to the log.
Caller should use the log_ macros and not call this directly.
prio | Level of message |
format_str,... | printf-style string. |
Caller should use the log_ macros and not call this directly.
prio | Priority of log request |
format_str | Format string in the usual C sense. |
... | Additional vararg parameters. |
Definition at line 273 of file lirc_log.c.
void perrorf | ( | const char * | format, |
... ) |
Adds printf-style arguments to perror(3).
Definition at line 254 of file lirc_log.c.
loglevel_t string2loglevel | ( | const char * | level | ) |
Convert a string, either a number or 'info', 'trace1', error etc.
to a loglevel.
Definition at line 234 of file lirc_log.c.
|
extern |
The actual logchannel.
Should not be changed directly by external code.
Definition at line 49 of file lirc_log.c.
|
extern |
The actual loglevel.
Should not be changed directly by external code.
Definition at line 47 of file lirc_log.c.
|
extern |
Definition at line 56 of file lirc_log.c.