[Title]set log path
authormunkyu.im <munkyu.im@samsung.com>
Fri, 16 Mar 2012 04:36:41 +0000 (13:36 +0900)
committermunkyu.im <munkyu.im@samsung.com>
Fri, 16 Mar 2012 04:36:41 +0000 (13:36 +0900)
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/debug_ch.c
tizen/src/debug_ch.h
tizen/src/emulator.c
tizen/src/emulator.h
tizen/src/process.c

index b8767efef6eee71fd6d1a6a8aad4aa20927e9f78..43bd74d916182d5f4629b7ff0e717caecb73a7ee 100644 (file)
 extern STARTUP_OPTION startup_option;
 #endif
 
-static char logfile[256] = { 0, };
+static char logfile[512] = {0,};
 static char debugchfile[256] = {0, };
+
+void set_log_path(char *path)
+{
+    strcpy(logfile, path);
+}
+
 static inline int interlocked_xchg_add( int *dest, int incr )
 {
        int ret;
@@ -301,7 +307,6 @@ static void debug_init(void)
        strcpy(logfile, get_virtual_target_abs_path(startup_option.vtm));
        strcat(logfile, "logs/emulator.log");
 #endif
-       strcpy(logfile, "emulator.log");
 
        if(access(logfile, F_OK | R_OK) == 0)
                remove(logfile);
index c50023374a99093f98548db91a405293620cb6a3..08c9c35732de2184e5d2f5455278dd2d2341cd82 100644 (file)
@@ -57,6 +57,8 @@ struct _debug_channel
        char multiname[15];
 };
 
+void set_log_path(char *path);
+
 #ifndef NO_DEBUG
 #define MSGSIZE_MAX 2048
 #define __GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __DBCL_FIXME))
index 55d73c707cb836980b1173583fbbb2dea8711a5d..9b9e551ad3cf7a2de1858afa62cf8e8efa585409 100644 (file)
@@ -58,7 +58,9 @@ MULTI_DEBUG_CHANNEL(qemu, main);
 int tizen_base_port = 0;
 
 int _emulator_condition = 0; //TODO:
-char tizen_target_path[MAXLEN] = {0, };
+static char tizen_target_path[MAXLEN] = {0, };
+static char logfile[MAXLEN] = { 0, };
+
 int get_emulator_condition(void)
 {
     return _emulator_condition;
@@ -120,7 +122,7 @@ static void parse_options(int argc, char* argv[], int* skin_argc, char*** skin_a
     }
 }
 
-void get_image_path(char* qemu_argv)
+void set_image_and_log_path(char* qemu_argv)
 {
     int i;
     int j = 0;
@@ -139,6 +141,9 @@ void get_image_path(char* qemu_argv)
     }
     path[j] = '\0';
     strcpy(tizen_target_path, path);
+    strcpy(logfile, g_path_get_dirname(tizen_target_path));
+       strcat(logfile, "/logs/emulator.log");
+
 }
 
 void get_tizen_port(char* option)
@@ -157,20 +162,17 @@ void get_tizen_port(char* option)
     }
     path[j] = '\0';
     tizen_base_port = strtol(path, &ptr, 0);
   INFO( "tizen_base_port: %d\n", tizen_base_port);
// INFO( "tizen_base_port: %d\n", tizen_base_port);
 }
 
 void redir_output(void)
 {
        FILE *fp;
-// FIXME !!
-//     strcpy(logfile, get_virtual_target_log_path(startup_option.vtm));
-//     strcat(logfile, "/emulator.log");
 
-       fp = freopen("emulator.log", "a+", stdout);
+       fp = freopen(logfile, "a+", stdout);
        if(fp ==NULL)
                fprintf(stderr, "log file open error\n");
-       fp = freopen("emulator.log", "a+", stderr);
+       fp = freopen(logfile, "a+", stderr);
        if(fp ==NULL)
                fprintf(stderr, "log file open error\n");
 
@@ -186,7 +188,7 @@ void extract_info(int qemu_argc, char** qemu_argv)
     for(i = 0; i < qemu_argc; ++i)
     {
         if(strstr(qemu_argv[i], IMAGE_PATH_PREFIX) != NULL) {
-            get_image_path(qemu_argv[i]);
+            set_image_and_log_path(qemu_argv[i]);
         }
         if((option = strstr(qemu_argv[i], SDB_PORT_PREFIX)) != NULL) {
             get_tizen_port(option);
@@ -205,22 +207,24 @@ int main(int argc, char* argv[])
 
     int qemu_argc = 0;
     char** qemu_argv = NULL;
-    char proxy[MIDBUF] ={0}, dns1[MIDBUF] = {0}, dns2[MIDBUF] = {0};
 
-    INFO("Emulator start !!!\n");
     // redir_output after debug_ch is initialized...
-    redir_output();
 
 #ifdef _WIN32
     WSADATA wsadata;
     if(WSAStartup(MAKEWORD(2,0), &wsadata) == SOCKET_ERROR) {
-        ERR("Error creating socket.\n");
+      //  ERR("Error creating socket.\n");
         return NULL;
     }
 #endif
        
     parse_options(argc, argv, &skin_argc, &skin_argv, &qemu_argc, &qemu_argv);
     extract_info(qemu_argc, qemu_argv);
+    set_log_path(logfile);
+    INFO("Emulator start !!!\n");
+    
+    redir_output();
+       
 
     int i;
 
index 5bdd1e7d8243e500f044ee8ae7d0c325115891d8..3347ac5910f02a15bc39b4dd56abfeb1b1528d1e 100644 (file)
@@ -40,7 +40,7 @@
 int get_emulator_condition(void);
 void set_emulator_condition(int state);
 void exit_emulator(void);
-void get_image_path(char *qemu_argv);
+void set_image_and_log_path(char *qemu_argv);
 void get_tizen_port(char* option);
 
 #endif
index 31108e4da4e466aee5895c3b8e1b475b94375183..45aba74615c2b6e073ac13d2f13c705cb4d3cdcd 100644 (file)
@@ -169,8 +169,8 @@ int write_portfile(char *path)
 #else
        if ((fd = open(portfname, O_RDWR | O_CREAT, 0666)) < 0) {
 #endif
-               ERR("Failed to create .port file\n");
-               ERR("%s at %s(%d)\n", strerror(errno), __FILE__, __LINE__);
+//             ERR("Failed to create .port file\n");
+//             ERR("%s at %s(%d)\n", strerror(errno), __FILE__, __LINE__);
            return -1;
        }