Просмотр исходного кода

Allow the syslog facility type to be set in the configuration file.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1029 fd59a12c-fef9-0310-b244-a6a79926bd2f
Patrick Caulfield 20 лет назад
Родитель
Сommit
1948867924
4 измененных файлов с 49 добавлено и 0 удалено
  1. 36 0
      exec/mainconfig.c
  2. 1 0
      exec/mainconfig.h
  3. 4 0
      exec/print.c
  4. 8 0
      man/openais.conf.5

+ 36 - 0
exec/mainconfig.c

@@ -167,6 +167,39 @@ int openais_main_config_read (
 			}
 		}
 
+		if (!objdb_get_string (objdb,object_service_handle, "syslog_facility", &value)) {
+			if (strcmp (value, "daemon") == 0) {
+				main_config->syslog_facility = LOG_DAEMON;
+			} else
+			if (strcmp (value, "local0") == 0) {
+				main_config->syslog_facility = LOG_LOCAL0;
+			} else
+			if (strcmp (value, "local1") == 0) {
+				main_config->syslog_facility = LOG_LOCAL1;
+			} else
+			if (strcmp (value, "local2") == 0) {
+				main_config->syslog_facility = LOG_LOCAL2;
+			} else
+			if (strcmp (value, "local3") == 0) {
+				main_config->syslog_facility = LOG_LOCAL3;
+			} else
+			if (strcmp (value, "local4") == 0) {
+				main_config->syslog_facility = LOG_LOCAL4;
+			} else
+			if (strcmp (value, "local5") == 0) {
+				main_config->syslog_facility = LOG_LOCAL5;
+			} else
+			if (strcmp (value, "local6") == 0) {
+				main_config->syslog_facility = LOG_LOCAL6;
+			} else
+			if (strcmp (value, "local7") == 0) {
+				main_config->syslog_facility = LOG_LOCAL7;
+			} else {
+				error_reason = "unknown syslog facility specified";
+				goto parse_error;
+			}
+		}
+
 		while (	objdb->object_find (object_service_handle,
 									"logger",
 									strlen ("logger"),
@@ -258,6 +291,9 @@ int openais_main_config_read (
 		goto parse_error;
 	}
 
+	if (!main_config->syslog_facility)
+		main_config->syslog_facility = LOG_DAEMON;
+
 	return 0;
 
 parse_error:

+ 1 - 0
exec/mainconfig.h

@@ -66,6 +66,7 @@ struct main_config {
 	 */
 	int logmode;
 	char *logfile;
+	int syslog_facility;
 
 	/* user/group to run as */
 	char *user;

+ 4 - 0
exec/print.c

@@ -224,6 +224,10 @@ int log_setup (char **error_string, struct main_config *config)
 		}
 	}
 
+	if (config->logmode & LOG_MODE_SYSLOG) {
+		openlog("openais", LOG_CONS|LOG_PID, config->syslog_facility);
+	}
+
 	/*
 	** reinit all loggers that has initialised before log_setup() was called.
 	*/

+ 8 - 0
man/openais.conf.5

@@ -381,6 +381,14 @@ This specifies that file and line should be printed instead of logger name.
 
 The default is off.
 
+.TP 
+syslog_facility
+This specifies the syslog facility type that will be used for any messages
+sent to syslog. options are daemon, local0, local1, local2, local3, local4, 
+local5, local6 & local7. 
+
+The default is daemon.
+
 .PP
 .PP
 Within the