Critical logs: move path default to autoconf 87/223887/10
authorMichal Bloch <m.bloch@samsung.com>
Tue, 4 Feb 2020 11:51:43 +0000 (12:51 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 13 Feb 2020 13:35:35 +0000 (14:35 +0100)
Change-Id: Ifc7b88efb4ef764a20e47b0e36e1c634de34e4c0
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
configure.ac
packaging/dlog.spec
src/log-critical/log-critical.cpp

index faeee2c..724452e 100644 (file)
@@ -51,6 +51,14 @@ AC_ARG_ENABLE([server-group],
 AC_DEFINE_UNQUOTED([DLOG_SERVER_GROUP], "$dlog_server_group")
 AC_SUBST([DLOG_SERVER_GROUP], "$dlog_server_group")
 
+critical_logfile_path_default=${localstatedir}/log/dlog/critical
+AC_ARG_ENABLE([critical-logfile],
+       AS_HELP_STRING([--critical-log-path=PATH], [path of the critical log file (default: $critical_logfile_path_default)]),
+       [critical_logfile=$enableval],
+       [critical_logfile=$critical_logfile_path_default])
+AC_DEFINE_UNQUOTED([DLOG_CRITICAL_LOGFILE_PATH], "$critical_logfile")
+AC_SUBST([DLOG_CRITICAL_LOGFILE_PATH], "$critical_logfile")
+
 AC_ARG_ENABLE([android-monotonic],
         AS_HELP_STRING([--enable-android-monotonic], [use monotonic send timestamp with log message when using android backend (EXPERIMENTAL)]),
         [android_monotonic=true],
index 1a019bc..93b95ff 100644 (file)
@@ -154,7 +154,7 @@ cp %{SOURCE101} .
 --enable-dynamic-filters
 %endif
 
-make %{?jobs:-j%jobs} CFLAGS+='-D__DLOG_VERSION=\"%{version}\" -D__DLOG_RELEASE=\"%{release}\" -DDLOG_CRITICAL_LOGFILE=\"/var/log/dlog/critical\"'
+make %{?jobs:-j%jobs} CFLAGS+='-D__DLOG_VERSION=\"%{version}\" -D__DLOG_RELEASE=\"%{release}\"'
 
 # autoconf adds a bunch of flags, including -O2.
 # Clear those so that test coverage can be measured properly
index 8b127aa..05cec47 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#ifndef DLOG_CRITICAL_LOGFILE
-       #define DLOG_CRITICAL_LOGFILE "/var/log/dlog/critical"
-#endif
-
 inline void close_fd(const int *fd) { if (*fd >= 0) close(*fd); }
 
 int main (int argc, char **argv)
@@ -32,7 +28,7 @@ int main (int argc, char **argv)
        if (argc != 2) // Usage: ./dlog-log-critical "formatted message"
                return EXIT_FAILURE;
 
-       __attribute__((cleanup(close_fd))) const int fd = open(DLOG_CRITICAL_LOGFILE, O_WRONLY | O_APPEND | O_SYNC);
+       __attribute__((cleanup(close_fd))) const int fd = open(DLOG_CRITICAL_LOGFILE_PATH, O_WRONLY | O_APPEND | O_SYNC);
        if (fd < 0)
                return EXIT_FAILURE;