mbpfan-josie

Emit version number on startup

Also configure syslog before logging.  References #163.

0ae57217f7b0e449ea029b1fd3c3475075f46178
Andrew Gaul <andrew@gaul.org> · 2019-10-30T21:04 · browse files at this commit

parents: 1243d7d

diff --git a/src/daemon.c b/src/daemon.c
index 7ce03fd..38104ac 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -147,8 +147,6 @@ void go_daemon(void (*fan_control)())
     signal(SIGQUIT, signal_handler);
     signal(SIGINT, signal_handler);
 
-    syslog(LOG_INFO, "%s starting up", PROGRAM_NAME);
-
     // Setup syslog logging - see SETLOGMASK(3)
     if(verbose) {
         setlogmask(LOG_UPTO(LOG_DEBUG));
@@ -159,6 +157,8 @@ void go_daemon(void (*fan_control)())
         openlog(PROGRAM_NAME, LOG_CONS, LOG_USER);
     }
 
+    mbp_log(LOG_INFO, "%s %s starting up", PROGRAM_NAME, PROGRAM_VERSION);
+
     // configure timer slack
     int err = prctl(PR_SET_TIMERSLACK, 1000 * 1000 * 1000, 0, 0, 0);
     if (err == -1) {
diff --git a/src/global.h b/src/global.h
index 5cd41eb..d524407 100644
--- a/src/global.h
+++ b/src/global.h
@@ -5,6 +5,7 @@ extern int daemonize;
 extern int verbose;
 
 extern const char* PROGRAM_NAME;
+extern const char* PROGRAM_VERSION;
 extern const char* PROGRAM_PID;
 
 struct s_sensors {
diff --git a/src/main.c b/src/main.c
index df22318..2b797c9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -37,6 +37,7 @@ int daemonize = 1;
 int verbose = 0;
 
 const char *PROGRAM_NAME = "mbpfan";
+const char *PROGRAM_VERSION = "2.2.0";
 const char *PROGRAM_PID = "/var/run/mbpfan.pid";
 
 const char *CORETEMP_PATH = "/sys/devices/platform/coretemp.0";