Преглед на файлове

Update utils.c

The NRPE agent and the check_nrpe plugin by default, would log errors to syslog.
Added the ability to turn off logging to syslog and set the default to be off.
tgriep преди 7 години
родител
ревизия
4b7bf485ef
променени са 1 файла, в които са добавени 5 реда и са изтрити 3 реда
  1. 5 3
      src/utils.c

+ 5 - 3
src/utils.c

@@ -58,6 +58,7 @@ char *log_file = NULL;
 FILE *log_fp = NULL;
 
 static int my_create_socket(struct addrinfo *ai, const char *bind_address, int redirect_stderr);
+extern int enable_debug;
 
 
 /* build the crc table - must be called before calculating the crc value */
@@ -537,7 +538,6 @@ void logit(int priority, const char *format, ...)
 
 	if (!format || !*format)
 		return;
-
 	va_start(ap, format);
 	if(vasprintf(&buffer, format, ap) > 0) {
 		if (log_fp) {
@@ -549,8 +549,10 @@ void logit(int priority, const char *format, ...)
 			fprintf(log_fp, "[%llu] %s\n", (unsigned long long)log_time, buffer);
 			fflush(log_fp);
 
-		} else
-			syslog(priority, "%s", buffer);
+		} else {
+		       if ( enable_syslog )
+                       		syslog(priority, "%s", buffer);
+		       }
 
 		free(buffer);
 	}