commit 39d70855945ad1cb14fd865ebe581081ca8f2a27 Author: Alec Leamas Date: Sat Jan 10 01:30:32 2015 +0100 lib/lirc_log: Add priority labels (info, error...) to syslog msg (#89). diff --git a/lib/lirc_log.c b/lib/lirc_log.c index 307fb77..cf37e6d 100644 --- a/lib/lirc_log.c +++ b/lib/lirc_log.c @@ -2,22 +2,8 @@ ** lircd.c ***************************************************************** **************************************************************************** * - * lircd - LIRC Decoder Daemon + * lirc_log - simple logging module. * - * Copyright (C) 1996,97 Ralph Metzler - * Copyright (C) 1998,99 Christoph Bartelmus - * - * ======= - * HISTORY - * ======= - * - * 0.1: 03/27/96 decode SONY infra-red signals - * create mousesystems mouse signals on pipe /dev/lircm - * 04/07/96 send ir-codes to clients via socket (see irpty) - * 05/16/96 now using ir_remotes for decoding - * much easier now to describe new remotes - * - * 0.5: 09/02/98 finished (nearly) complete rewrite (Christoph) * */ @@ -59,6 +45,8 @@ const char *logfile = "syslog"; char progname[128] = {'?','\0'}; static int nodaemon = 0; +static const int PRIO_LEN = 16; /**< Longest priority label, some margin. */ + static const char* prio2text(int prio) { @@ -246,6 +234,7 @@ void logprintf(loglevel_t prio, const char *format_str, ...) { int save_errno = errno; va_list ap; + char buff[PRIO_LEN + strlen(format_str)]; #ifdef SYSTEMD_LOGPERROR_FIX if (nodaemon && prio <= loglevel) { @@ -258,8 +247,10 @@ void logprintf(loglevel_t prio, const char *format_str, ...) } #endif if (use_syslog) { + snprintf(buff, sizeof(buff), + "%s: %s", prio2text(prio), format_str); va_start(ap, format_str); - vsyslog(prio, format_str, ap); + vsyslog(prio, buff, ap); va_end(ap); } else if (lf && prio <= loglevel) { time_t current;