[icinga-checkins] icinga.org: icinga-core/master: value 2 for use_syslog will turn off logfile

git at icinga.org git at icinga.org
Mon Sep 20 09:53:36 CEST 2010


Module: icinga-core
Branch: master
Commit: 5effc34132acd5753d52efe2f5194b7847bfd2b2
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=5effc34132acd5753d52efe2f5194b7847bfd2b2

Author: Christoph Maser <cmr at financial.com>
Date:   Sun Jul 18 22:05:46 2010 +0200

value 2 for use_syslog will turn off logfile
From:     Steven D. Morrey <smorrey at ldschurch.org>

---

 base/config.c    |    4 ++--
 base/logging.c   |   17 ++++++++++++-----
 include/icinga.h |    2 +-
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/base/config.c b/base/config.c
index 104853d..7137458 100644
--- a/base/config.c
+++ b/base/config.c
@@ -516,13 +516,13 @@ int read_main_config_file(char *main_config_file){
 
 		else if(!strcmp(variable,"use_syslog")){
 
-			if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
+			if(strlen(value)!=1||value[0]<'0'||value[0]>'2'){
 				asprintf(&error_message,"Illegal value for use_syslog");
 				error=TRUE;
 				break;
 				}
 
-			use_syslog=(atoi(value)>0)?TRUE:FALSE;
+			use_syslog=atoi(value)
 			}
 
 		else if(!strcmp(variable,"use_syslog_local_facility")){
diff --git a/base/logging.c b/base/logging.c
index dd47419..261e78d 100644
--- a/base/logging.c
+++ b/base/logging.c
@@ -123,11 +123,14 @@ void logit(int data_type, int display, const char *fmt, ...){
 int write_to_all_logs(char *buffer, unsigned long data_type){
 
 	/* write to syslog */
-	write_to_syslog(buffer,data_type);
+        if(use_syslog) {
+		write_to_syslog(buffer,data_type);
+	}
 
 	/* write to main log */
-	write_to_log(buffer,data_type,NULL);
-
+	if(use_syslog != 2) {
+		write_to_log(buffer,data_type,NULL);
+	}
 	return OK;
         }
 
@@ -136,10 +139,14 @@ int write_to_all_logs(char *buffer, unsigned long data_type){
 static void write_to_all_logs_with_timestamp(char *buffer, unsigned long data_type, time_t *timestamp){
 
 	/* write to syslog */
-	write_to_syslog(buffer,data_type);
+	if(use_syslog) {
+		write_to_syslog(buffer,data_type);
+	}
 
 	/* write to main log */
-	write_to_log(buffer,data_type,timestamp);
+	if(use_syslog != 2) {
+		write_to_log(buffer,data_type,timestamp);
+	}
 }
 
 
diff --git a/include/icinga.h b/include/icinga.h
index 7b9d413..d6f3fb5 100644
--- a/include/icinga.h
+++ b/include/icinga.h
@@ -53,7 +53,7 @@ extern "C" {
 /******************* DEFAULT VALUES *******************/
 
 #define DEFAULT_LOG_LEVEL					1	/* log all events to main log file */
-#define DEFAULT_USE_SYSLOG					1	/* log events to syslog? 1=yes, 0=no */
+#define DEFAULT_USE_SYSLOG					1	/* log events to syslog? 0=no 1=yes 2=sylog only */
 #define DEFAULT_USE_SYSLOG_LOCAL_FACILITY			0	/* log events to a local facility instead of the default? 1=yes, 0=no */
 #define DEFAULT_SYSLOG_LOCAL_FACILITY				5	/* log events to the specified loacl facility? 1=yes, 0=no */
 





More information about the icinga-checkins mailing list