From bd51c1ef596616fa19f807bad61eceee800eb528 Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Thu, 31 Jul 2014 16:49:00 +0900 Subject: [PATCH] log: modify some emulator.log formats. add the microsecond time to output format. add the thread id to output format. Change-Id: I23247dfdd76481b9f8bd21a6000aa835459ed8ad Signed-off-by: Sooyoung Ha --- tizen/src/util/new_debug_ch.c | 5 +++-- tizen/src/util/osutil-darwin.c | 17 ----------------- tizen/src/util/osutil-linux.c | 18 ------------------ tizen/src/util/osutil-win32.c | 16 ---------------- tizen/src/util/osutil.h | 21 ++++++++++++++++++++- 5 files changed, 23 insertions(+), 54 deletions(-) diff --git a/tizen/src/util/new_debug_ch.c b/tizen/src/util/new_debug_ch.c index b871522..c0f98ef 100644 --- a/tizen/src/util/new_debug_ch.c +++ b/tizen/src/util/new_debug_ch.c @@ -297,8 +297,9 @@ int dbg_log(enum _debug_class cls, struct _debug_channel *channel, return -1; } - ret = g_snprintf(buf_msg, sizeof(buf_msg), "%s [%s:%s] ", - get_timeofday(), debug_classes[cls], channel->name); + ret += get_timeofday(buf_msg, sizeof(buf_msg)); + ret += g_snprintf(buf_msg + ret, sizeof(buf_msg) - ret, "(%5d) [%s:%s] ", + qemu_get_thread_id(), debug_classes[cls], channel->name); va_start(valist, format); ret += g_vsnprintf(buf_msg + ret, sizeof(buf_msg) - ret, format, valist); diff --git a/tizen/src/util/osutil-darwin.c b/tizen/src/util/osutil-darwin.c index feedd7f..56913ae 100644 --- a/tizen/src/util/osutil-darwin.c +++ b/tizen/src/util/osutil-darwin.c @@ -54,10 +54,6 @@ MULTI_DEBUG_CHANNEL(qemu, osutil); - -static qemu_timeval tv = { 0, 0 }; -static time_t ti; -static char buf_time[64]; static int g_shmid; static CFDictionaryRef proxySettings; @@ -238,19 +234,6 @@ void print_system_info_os(void) } } -char *get_timeofday(void) -{ - qemu_gettimeofday(&tv); - ti = tv.tv_sec; - - struct tm tm; - localtime_r(&ti, &tm); - strftime(buf_time, sizeof(buf_time), - "%H:%M:%S", &tm); - - return buf_time; -} - static int get_auto_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) { char type[DEFAULTBUFLEN]; diff --git a/tizen/src/util/osutil-linux.c b/tizen/src/util/osutil-linux.c index 4e89894..53c5882 100644 --- a/tizen/src/util/osutil-linux.c +++ b/tizen/src/util/osutil-linux.c @@ -56,11 +56,6 @@ MULTI_DEBUG_CHANNEL(emulator, osutil); - -static qemu_timeval tv = { 0, 0 }; -static time_t ti; -static char buf_time[64]; - static int g_shmid; static char *g_shared_memory; static int gproxytool = GSETTINGS; @@ -254,19 +249,6 @@ void print_system_info_os(void) g_free(buffer); } -char *get_timeofday(void) -{ - qemu_gettimeofday(&tv); - ti = tv.tv_sec; - - struct tm tm; - localtime_r(&ti, &tm); - strftime(buf_time, sizeof(buf_time), - "%H:%M:%S", &tm); - - return buf_time; -} - static void process_string(char *buf) { char tmp_buf[DEFAULTBUFLEN]; diff --git a/tizen/src/util/osutil-win32.c b/tizen/src/util/osutil-win32.c index 05771cb..eea34dc 100644 --- a/tizen/src/util/osutil-win32.c +++ b/tizen/src/util/osutil-win32.c @@ -51,10 +51,6 @@ MULTI_DEBUG_CHANNEL (emulator, osutil); - -static qemu_timeval tv = { 0, 0 }; -static time_t ti; -static char buf_time[64]; static HANDLE g_hMapFile; static char *g_pBuf; @@ -212,18 +208,6 @@ void print_system_info_os(void) memInfo.ullTotalPhys / 1024, memInfo.ullAvailPhys / 1024); } -char *get_timeofday(void) -{ - qemu_gettimeofday(&tv); - ti = tv.tv_sec; - - struct tm *ptm = localtime(&ti); - strftime(buf_time, sizeof(buf_time), - "%H:%M:%S", ptm); - - return buf_time; -} - static int get_auto_proxy(BYTE *url, char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) { char type[DEFAULTBUFLEN]; diff --git a/tizen/src/util/osutil.h b/tizen/src/util/osutil.h index 926f3a0..f24a6b5 100644 --- a/tizen/src/util/osutil.h +++ b/tizen/src/util/osutil.h @@ -73,7 +73,26 @@ void get_host_proxy_os(char *, char *, char *, char *); void download_url(char *); size_t write_data(void *, size_t, size_t, FILE *); void remove_string(char *, char *, const char *); -char *get_timeofday(void); + +static inline int get_timeofday(char *buf, size_t size) +{ + qemu_timeval tv; + time_t ti; + struct tm *ptm = NULL; + int ret; + + qemu_gettimeofday(&tv); + ti = tv.tv_sec; + +#ifndef CONFIG_WIN32 + localtime_r(&ti, ptm); +#else + ptm = localtime(&ti); +#endif + ret = strftime(buf, size, "%H:%M:%S", ptm); + + return ret + g_snprintf(buf + ret, size - ret, ".%06ld", tv.tv_usec); +} int get_number_of_processors(void); -- 2.7.4