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

[lvm-devel] [PATCH] In dmeventd, bridge LVM error log output to syslog.



Hi,

as discussed, this is the first part of dmeventd logging. I am not
touching any options related to debugging, that will come as a separate
patch later. This patch provides the necessary minimum for any useful
diagnostics of dmeventd/lvconvert --repair issues.

(I have tested this and it works for me.)

Yours,
   Petr.

Thu May  6 19:37:47 CEST 2010  Petr Rockai <me mornfall net>
  * In dmeventd, bridge LVM error log output to syslog.
diff -rN -u -p old-upstream/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c new-upstream/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
--- old-upstream/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c	2010-05-06 20:49:55.000000000 +0200
+++ new-upstream/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c	2010-05-06 20:49:55.000000000 +0200
@@ -13,6 +13,7 @@
  */
 
 #include "lib.h"
+#include "log.h"
 
 #include "lvm2cmd.h"
 #include "errors.h"
@@ -40,19 +41,31 @@ static void *_lvm_handle = NULL;
  */
 static pthread_mutex_t _event_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-/* FIXME Remove this: Pass messages back to dmeventd core for processing. */
-static void _temporary_log_fn(int level,
-			      const char *file __attribute((unused)),
-			      int line __attribute((unused)),
-			      int dm_errno __attribute((unused)),
-			      const char *format)
-{
-	level &= ~_LOG_STDERR;
-
-	if (!strncmp(format, "WARNING: ", 9) && (level < 5))
-		syslog(LOG_CRIT, "%s", format);
-	else
-		syslog(LOG_DEBUG, "%s", format);
+/*
+ * FIXME Do not pass things directly to syslog, rather use the existing logging
+ * facilities to sort logging ... however that mechanism needs to be somehow
+ * configurable and we don't have that option yet
+ */
+static void _log_fn(int level,
+		    const char *file __attribute((unused)),
+		    int line __attribute((unused)),
+		    int dm_errno __attribute((unused)),
+		    const char *message)
+{
+	switch (level) {
+	case _LOG_DEBUG:
+	case _LOG_INFO:
+	case _LOG_NOTICE:
+		break; /* TODO */
+	case _LOG_WARN:
+		syslog(LOG_WARNING, "%s", message);
+		break;
+	case _LOG_ERR:
+		syslog(LOG_ERR, "%s", message);
+		break;
+	default:
+		syslog(LOG_CRIT, "%s", message);
+	}
 }
 
 void dmeventd_lvm2_lock(void)
@@ -82,7 +95,7 @@ int dmeventd_lvm2_init(void)
 		goto out;
 
 	if (!_lvm_handle) {
-		lvm2_log_fn(_temporary_log_fn);
+		lvm2_log_fn(_log_fn);
 		if (!(_lvm_handle = lvm2_init())) {
 			dm_pool_destroy(_mem_pool);
 			_mem_pool = NULL;

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