summaryrefslogtreecommitdiff
path: root/lirc/20150110013032-39d7085-log-priority-labels.patch
blob: 14d70145072bb8724fcd9fa944d695627af59025 (plain)
    1 commit 39d70855945ad1cb14fd865ebe581081ca8f2a27
    2 Author: Alec Leamas <leamas.alec@gmail.com>
    3 Date:   Sat Jan 10 01:30:32 2015 +0100
    4 
    5     lib/lirc_log: Add priority labels (info, error...) to syslog msg (#89).
    6 
    7 diff --git a/lib/lirc_log.c b/lib/lirc_log.c
    8 index 307fb77..cf37e6d 100644
    9 --- a/lib/lirc_log.c
   10 +++ b/lib/lirc_log.c
   11 @@ -2,22 +2,8 @@
   12   ** lircd.c *****************************************************************
   13   ****************************************************************************
   14   *
   15 - * lircd - LIRC Decoder Daemon
   16 + * lirc_log - simple logging module.
   17   *
   18 - * Copyright (C) 1996,97 Ralph Metzler <rjkm@thp.uni-koeln.de>
   19 - * Copyright (C) 1998,99 Christoph Bartelmus <lirc@bartelmus.de>
   20 - *
   21 - *  =======
   22 - *  HISTORY
   23 - *  =======
   24 - *
   25 - * 0.1:  03/27/96  decode SONY infra-red signals
   26 - *                 create mousesystems mouse signals on pipe /dev/lircm
   27 - *       04/07/96  send ir-codes to clients via socket (see irpty)
   28 - *       05/16/96  now using ir_remotes for decoding
   29 - *                 much easier now to describe new remotes
   30 - *
   31 - * 0.5:  09/02/98 finished (nearly) complete rewrite (Christoph)
   32   *
   33   */
   34  
   35 @@ -59,6 +45,8 @@ const char *logfile = "syslog";
   36  char progname[128] = {'?','\0'};
   37  static int nodaemon = 0;
   38  
   39 +static const int PRIO_LEN = 16; /**< Longest priority label, some margin. */
   40 +
   41  
   42  static const char* prio2text(int prio)
   43  {
   44 @@ -246,6 +234,7 @@ void logprintf(loglevel_t prio, const char *format_str, ...)
   45  {
   46  	int save_errno = errno;
   47  	va_list ap;
   48 +	char buff[PRIO_LEN + strlen(format_str)];
   49  
   50  #ifdef SYSTEMD_LOGPERROR_FIX
   51  	if (nodaemon && prio <= loglevel) {
   52 @@ -258,8 +247,10 @@ void logprintf(loglevel_t prio, const char *format_str, ...)
   53  	}
   54  #endif
   55  	if (use_syslog) {
   56 +		snprintf(buff, sizeof(buff),
   57 +			 "%s: %s", prio2text(prio), format_str);
   58  		va_start(ap, format_str);
   59 -		vsyslog(prio, format_str, ap);
   60 +		vsyslog(prio, buff, ap);
   61  		va_end(ap);
   62  	} else if (lf && prio <= loglevel) {
   63  		time_t current;

Generated by cgit