diff --git a/include/dap_common.h b/include/dap_common.h index b88fdcada06b8e424f5f453f298e9dce8abb2437..a441852a28a8b7bce7509bf5e862a04eef4e10e6 100755 --- a/include/dap_common.h +++ b/include/dap_common.h @@ -335,6 +335,7 @@ extern size_t g_sys_dir_path_len; //int dap_common_init( const char * a_log_file ); int dap_common_init( const char *console_title, const char *a_log_file ); +int wdap_common_init( const char *console_title, const wchar_t *a_wlog_file); void dap_common_deinit(void); diff --git a/src/dap_common.c b/src/dap_common.c index f8272157fe5fd0c1b4ccda2f0db304daf229f695..0f7704e363cdc6b3668acefbca2b27de1a55ec55 100755 --- a/src/dap_common.c +++ b/src/dap_common.c @@ -243,6 +243,28 @@ int dap_common_init( const char *a_console_title, const char *a_log_filename ) { return 0; } +int wdap_common_init( const char *a_console_title, const wchar_t *a_log_filename ) { + + // init randomer + srand( (unsigned int)time(NULL) ); + (void) a_console_title; + strncpy( s_log_tag_fmt_str, "[%s]\t",sizeof (s_log_tag_fmt_str)); + for (int i = 0; i < 16; ++i) + s_ansi_seq_color_len[i] =(unsigned int) strlen(s_ansi_seq_color[i]); + if ( a_log_filename ) { + s_log_file = _wfopen( a_log_filename , L"a" ); + if( s_log_file == NULL) + s_log_file = _wfopen( a_log_filename , L"w" ); + if ( s_log_file == NULL ) { + dap_fprintf( stderr, "Can't open log file %s to append\n", a_log_filename ); + return -1; + } + //dap_stpcpy(s_log_file_path, a_log_filename); + } + pthread_create( &s_log_thread, NULL, s_log_thread_proc, NULL ); + return 0; +} + /** * @brief dap_common_deinit Deinitialise */