From: Michal Bloch Date: Tue, 4 Feb 2020 11:51:43 +0000 (+0100) Subject: Critical logs: move path default to autoconf X-Git-Tag: accepted/tizen/unified/20200214.120111~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=333f1fc501dd4b0cc4eba9aee0d1b2a143d0a4d2;p=platform%2Fcore%2Fsystem%2Fdlog.git Critical logs: move path default to autoconf Change-Id: Ifc7b88efb4ef764a20e47b0e36e1c634de34e4c0 Signed-off-by: Michal Bloch --- diff --git a/configure.ac b/configure.ac index faeee2c..724452e 100644 --- a/configure.ac +++ b/configure.ac @@ -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], diff --git a/packaging/dlog.spec b/packaging/dlog.spec index 1a019bc..93b95ff 100644 --- a/packaging/dlog.spec +++ b/packaging/dlog.spec @@ -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 diff --git a/src/log-critical/log-critical.cpp b/src/log-critical/log-critical.cpp index 8b127aa..05cec47 100644 --- a/src/log-critical/log-critical.cpp +++ b/src/log-critical/log-critical.cpp @@ -21,10 +21,6 @@ #include #include -#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;