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

Add a startup message and print priority to log file.

Doug Nazar 1 год назад
Родитель
Сommit
61e8a9b577
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      src/utils.c

+ 4 - 1
src/utils.c

@@ -532,8 +532,11 @@ void open_log_file(void)
 	}
 
 	(void)fcntl(fileno(log_fp), F_SETFD, FD_CLOEXEC);
+	fprintf(log_fp, "\n[%llu]        --------------- Startup ---------------\n", (unsigned long long)time(NULL));
 }
 
+static const char* log_priority_names[] = {" EMERG", " ALERT", "  CRIT", " ERROR", "  WARN", "NOTICE", "  INFO", " DEBUG"};
+
 void logit(int priority, const char *format, ...)
 {
 	time_t	log_time = 0L;
@@ -550,7 +553,7 @@ void logit(int priority, const char *format, ...)
 			strip(buffer);
 
 			/* write the buffer to the log file */
-			fprintf(log_fp, "[%llu] %s\n", (unsigned long long)log_time, buffer);
+			fprintf(log_fp, "[%llu] %s %s\n", (unsigned long long)log_time, log_priority_names[priority & 0x07], buffer);
 			fflush(log_fp);
 
 		} else if (!disable_syslog) {