[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Remove extraneous newlines from libevent log messages. Back...



Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv16688/src/common

Modified Files:
	log.c 
Log Message:
Remove extraneous newlines from libevent log messages. Backport candidate?

Index: log.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/log.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- log.c	8 Apr 2005 03:47:18 -0000	1.93
+++ log.c	8 Jun 2005 17:41:32 -0000	1.94
@@ -499,23 +499,29 @@
 static void
 libevent_logging_callback(int severity, const char *msg)
 {
+  char buf[1024];
+  size_t n;
   if (suppress_msg && strstr(msg, suppress_msg))
     return;
+  n = strlcpy(buf, msg, sizeof(buf));
+  if (n && n < sizeof(buf) && buf[n-1] == '\n') {
+    buf[n-1] = '\0';
+  }
   switch (severity) {
     case _EVENT_LOG_DEBUG:
-      log(LOG_DEBUG, "Message from libevent: %s", msg);
+      log(LOG_DEBUG, "Message from libevent: %s", buf);
       break;
     case _EVENT_LOG_MSG:
-      log(LOG_INFO, "Message from libevent: %s", msg);
+      log(LOG_INFO, "Message from libevent: %s", buf);
       break;
     case _EVENT_LOG_WARN:
-      log(LOG_WARN, "Warning from libevent: %s", msg);
+      log(LOG_WARN, "Warning from libevent: %s", buf);
       break;
     case _EVENT_LOG_ERR:
-      log(LOG_ERR, "Error from libevent: %s", msg);
+      log(LOG_ERR, "Error from libevent: %s", buf);
       break;
     default:
-      log(LOG_WARN, "Message [%d] from libevent: %s", severity, msg);
+      log(LOG_WARN, "Message [%d] from libevent: %s", severity, buf);
       break;
   }
 }