From: munkyu.im Date: Fri, 16 Mar 2012 04:36:41 +0000 (+0900) Subject: [Title]set log path X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1773^2~87^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6ff30538bb7802f77f050ed4bc19091458820c17;p=sdk%2Femulator%2Fqemu.git [Title]set log path [Type] [Module] [Priority] [CQ#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/tizen/src/debug_ch.c b/tizen/src/debug_ch.c index b8767efef6..43bd74d916 100644 --- a/tizen/src/debug_ch.c +++ b/tizen/src/debug_ch.c @@ -40,8 +40,14 @@ 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); diff --git a/tizen/src/debug_ch.h b/tizen/src/debug_ch.h index c50023374a..08c9c35732 100644 --- a/tizen/src/debug_ch.h +++ b/tizen/src/debug_ch.h @@ -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)) diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 55d73c707c..9b9e551ad3 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -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; diff --git a/tizen/src/emulator.h b/tizen/src/emulator.h index 5bdd1e7d82..3347ac5910 100644 --- a/tizen/src/emulator.h +++ b/tizen/src/emulator.h @@ -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 diff --git a/tizen/src/process.c b/tizen/src/process.c index 31108e4da4..45aba74615 100644 --- a/tizen/src/process.c +++ b/tizen/src/process.c @@ -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; }