Forráskód Böngészése

Add dynamic timestamp on/off

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1827 fd59a12c-fef9-0310-b244-a6a79926bd2f
Fabio M. Di Nitto 17 éve
szülő
commit
10fa45db6c
1 módosított fájl, 11 hozzáadás és 2 törlés
  1. 11 2
      exec/mainconfig.c

+ 11 - 2
exec/mainconfig.c

@@ -42,6 +42,7 @@
 #include <arpa/inet.h>
 #include <pwd.h>
 #include <grp.h>
+#include <limits.h>
 
 #include <corosync/corotypes.h>
 #include <corosync/list.h>
@@ -155,11 +156,19 @@ int corosync_main_config_read_logging (
 			}
 		}
 		if (!objdb_get_string (objdb,object_service_handle, "timestamp", &value)) {
+			char new_format_buffer[PATH_MAX];
+
+			memset(&new_format_buffer, 0, sizeof(new_format_buffer));
+
 			if (strcmp (value, "on") == 0) {
-				logsys_format_set("%t [%6s] %b");
+				snprintf(new_format_buffer, PATH_MAX-1, "%%t %s", logsys_format_get());
+				logsys_format_set(new_format_buffer);
 			} else
 			if (strcmp (value, "off") == 0) {
-				logsys_format_set(NULL);
+				if (!strncmp("%t ", logsys_format_get(), 3)) {
+					snprintf(new_format_buffer, PATH_MAX-1, "%s", logsys_format_get() + 3);
+					logsys_format_set(new_format_buffer);
+				}
 			} else {
 				goto parse_error;
 			}