log: a "debug_ch" can use stdout now 23/21723/1
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 23 Apr 2014 06:44:28 +0000 (15:44 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 27 May 2014 02:09:28 +0000 (19:09 -0700)
If "log_path" is not set, "debug_ch" use stdout.
It is only for arguments renewal.
A "debug_ch" should be refactored.

Change-Id: Iaa0d102800ac480e12106ef3d11282d50f20edd8
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
tizen/src/debug_ch.c

index 2451993..ea43d45 100644 (file)
@@ -280,8 +280,6 @@ static void debug_init(void)
     char *debug = NULL;
     FILE *fp = NULL;
     char *tmp = NULL;
-    int open_flags;
-    int fd;
 
     if (nb_debug_options != -1) {
         return;  /* already initialized */
@@ -338,15 +336,6 @@ static void debug_init(void)
     if (tmp != NULL) {
         free(tmp);
     }
-
-    open_flags = O_BINARY | O_RDWR | O_CREAT | O_TRUNC;
-    fd = qemu_open(log_path, open_flags, 0666);
-    if (fd < 0) {
-        fprintf(stderr, "Can't open logfile: %s\n", log_path);
-        exit(1);
-    }
-
-    close(fd);
 }
 
 /* allocate some tmp string space */
@@ -477,6 +466,12 @@ int dbg_log(enum _debug_class cls, struct _debug_channel *channel,
     ret += vsnprintf(buf_msg + ret, sizeof(buf_msg) - ret, format, valist);
     va_end(valist);
 
+    // If "log_path" is not set, we use "stdout".
+    if (log_path[0] == '\0') {
+        fprintf(stdout, "%s", buf_msg);
+        return ret;
+    }
+
     open_flags = O_RDWR | O_APPEND | O_BINARY | O_CREAT;
 
     fd = qemu_open(log_path, open_flags, 0666);