summaryrefslogtreecommitdiffstats
path: root/abs/core/lirc/0009-lib-lirc_log-Add-priority-labels-info-error.-to-sysl.patch
blob: c18605409a9adba77763776f3dcc9a0a4fb21b7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From dfe0f3c3170a029a47edd9adf2a1b9a975d496ae Mon Sep 17 00:00:00 2001
From: Alec Leamas <leamas.alec@gmail.com>
Date: Sat, 10 Jan 2015 01:30:32 +0100
Subject: [PATCH 09/13] lib/lirc_log: Add priority labels (info, error...) to
 syslog msg (#89).

---
 lib/lirc_log.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

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 <rjkm@thp.uni-koeln.de>
- * Copyright (C) 1998,99 Christoph Bartelmus <lirc@bartelmus.de>
- *
- *  =======
- *  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;
-- 
2.2.2