From 045d495c34f57a3b998a1ce8d34a7da2b9eb4e6d Mon Sep 17 00:00:00 2001 From: juho Date: Mon, 10 Dec 2012 22:51:29 +0900 Subject: [PATCH] platformloggingmode set default on, and fix dlog to systemd journal support platformloggingmode set default on, and fix dlog to systemd journal support check platform logging mode on is file in /opt/etc/dlog/.platformloggingmode fix tizen_platform_env script and added syslog.h and fix write_to_log_kernel from dlog to systemd journal code --- Makefile.am | 6 +++++- configure.ac | 2 +- log.c | 34 +++++++++++++--------------------- packaging/dlog.spec | 2 +- tizen_platform_env.sh | 2 +- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/Makefile.am b/Makefile.am index 737ed21..c16223f 100755 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,12 @@ +if SD_JOURNAL_SUPPORT +AM_CFLAGS = @CFLAGS@ -I$(srcdir)/include \ + -I$(srcdir)/include/internal -DSD_JOURNAL_SUPPORT +else AM_CFLAGS = @CFLAGS@ -I$(srcdir)/include \ -I$(srcdir)/include/internal - +endif dlog_includedir = $(includedir)/dlog dlog_include_HEADERS = \ diff --git a/configure.ac b/configure.ac index 66c40f2..6123fe1 100755 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ AM_CONDITIONAL(DEVELOP_VER, test $DEVELOP_VER = yes) SD_JOURNAL_SUPPORT=no -AC_DEFINE([SD_JOURNAL_SUPPORT], [], [Description]) +#AC_DEFINE([SD_JOURNAL_SUPPORT], [], [Description]) AM_CONDITIONAL(SD_JOURNAL_SUPPORT, test $SD_JOURNAL_SUPPORT = yes) diff --git a/log.c b/log.c index 4abdcf9..42cf02e 100755 --- a/log.c +++ b/log.c @@ -13,9 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifdef HAVE_PTHREADS #include -#endif #include #include #include @@ -41,9 +39,7 @@ static int g_dlog_level = DLOG_SILENT; static int __dlog_init(log_id_t, log_priority, const char *tag, const char *msg); static int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg) = __dlog_init; -#ifdef HAVE_PTHREADS static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER; -#endif static int __write_to_log_null(log_id_t log_id, log_priority prio, const char *tag, const char *msg) { return -1; @@ -81,7 +77,7 @@ static int dlog_pri_to_journal_pri(log_priority prio) } return journal_prio; } -static int __write_to_log_kernel(log_id_t log_id, log_priority prio, const char *tag, const char *msg) +static int __write_to_log_sd_journal_print(log_id_t log_id, log_priority prio, const char *tag, const char *msg) { sd_journal_print(dlog_pri_to_journal_pri(prio), "%s %s", tag, msg); return 1; @@ -122,36 +118,34 @@ static int __write_to_log_kernel(log_id_t log_id, log_priority prio, const char #endif void init_dlog_level(void) { - char *dlog_level; - char *logging_mode; + char *dlog_level_env; + char *logging_mode_env; if (g_logging_on) { - logging_mode = getenv("TIZEN_PLATFORMLOGGING_MODE"); - if (!logging_mode) + logging_mode_env = getenv("TIZEN_PLATFORMLOGGING_MODE"); + if (!logging_mode_env) g_logging_on = 0; else - g_logging_on = atoi(logging_mode); + g_logging_on = atoi(logging_mode_env); } if (g_logging_on) { - dlog_level = getenv("TIZEN_DLOG_LEVEL"); - if (!dlog_level) { + dlog_level_env = getenv("TIZEN_DLOG_LEVEL"); + if (!dlog_level_env) { g_dlog_level = 8; } else { - g_dlog_level = atoi(dlog_level); + g_dlog_level = atoi(dlog_level_env); } } else g_dlog_level = 8; } static int __dlog_init(log_id_t log_id, log_priority prio, const char *tag, const char *msg) { -#ifdef HAVE_PTHREADS pthread_mutex_lock(&log_init_lock); -#endif +#ifdef SD_JOURNAL_SUPPORT + write_to_log = __write_to_log_sd_journal_print; +#else // get filtering info // open device if (write_to_log == __dlog_init) { -#ifdef SD_JOURNAL_SUPPORT - write_to_log = __write_to_log_sd_journal_print; -#else init_dlog_level(); log_fds[LOG_ID_MAIN] = open("/dev/"LOG_MAIN, O_WRONLY); @@ -170,11 +164,9 @@ static int __dlog_init(log_id_t log_id, log_priority prio, const char *tag, cons if (log_fds[LOG_ID_APPS] < 0) log_fds[LOG_ID_APPS] = log_fds[LOG_ID_MAIN]; -#endif } -#ifdef HAVE_PTHREADS - pthread_mutex_unlock(&log_init_lock); #endif + pthread_mutex_unlock(&log_init_lock); return write_to_log(log_id, prio, tag, msg); } diff --git a/packaging/dlog.spec b/packaging/dlog.spec index 5b5d4db..6dc6245 100755 --- a/packaging/dlog.spec +++ b/packaging/dlog.spec @@ -1,7 +1,7 @@ Name: dlog Summary: Logging service Version: 0.4.1 -Release: 0.0 +Release: 1 Group: System/Libraries License: Apache License Source0: %{name}-%{version}.tar.gz diff --git a/tizen_platform_env.sh b/tizen_platform_env.sh index 1335e28..f8f0fe0 100755 --- a/tizen_platform_env.sh +++ b/tizen_platform_env.sh @@ -1,6 +1,6 @@ #!/bin/sh -if [ -e "/opt/etc/dlog/.platformloggingon" ]; then +if [ -e "/opt/etc/dlog/.platformloggingmode" ]; then export TIZEN_PLATFORMLOGGING_MODE=1 fi -- 2.7.4