diff --git a/client/tp_assist/tp_assist.cpp b/client/tp_assist/tp_assist.cpp index 94f2b47..239ac61 100644 --- a/client/tp_assist/tp_assist.cpp +++ b/client/tp_assist/tp_assist.cpp @@ -9,6 +9,8 @@ #define WMU_INSTANCE_EXIT (WM_USER + 2) #define WMU_SHOW_EXIST_DLGUI (WM_USER + 3) +static ExLogger g_ex_logger; + static ATOM MyRegisterClass(); static BOOL InitInstance(); static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); @@ -38,6 +40,7 @@ DWORD WINAPI ThreadProc(LPVOID lpParam) int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd) { + EXLOG_USE_LOGGER(&g_ex_logger); WORD wVersionRequested; WSADATA wsaData; @@ -64,7 +67,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmd EXLOG_LEVEL(EX_LOG_LEVEL_INFO); #endif - EXLOG_FILE(L"tp_assist.log", g_env.m_log_path.c_str(), 1024, 2); + EXLOG_FILE(L"tp_assist.log", g_env.m_log_path.c_str(), EX_LOG_FILE_MAX_SIZE, EX_LOG_FILE_MAX_COUNT); g_cfgSSH.init(); g_cfgScp.init(); diff --git a/common/libex/src/ex_log.cpp b/common/libex/src/ex_log.cpp index 2b10fb7..42ea2f3 100644 --- a/common/libex/src/ex_log.cpp +++ b/common/libex/src/ex_log.cpp @@ -325,6 +325,8 @@ bool ExLogger::set_log_file(const ex_wstr& log_path, const ex_wstr& log_name, ex m_path = log_path; ex_abspath(m_path); + ex_mkdirs(m_path); + m_fullname = m_path; ex_path_join(m_fullname, false, log_name.c_str(), NULL); @@ -549,6 +551,7 @@ bool ExLogger::write(const char* buf) m_filesize += lenTime; WriteFile(m_file, buf, len, &dwWritten, NULL); m_filesize += len; + FlushFileBuffers(m_file); #else time_t timep; struct tm *p; diff --git a/server/tp_core/common/base_record.cpp b/server/tp_core/common/base_record.cpp index 2f8f52c..38ae8e3 100644 --- a/server/tp_core/common/base_record.cpp +++ b/server/tp_core/common/base_record.cpp @@ -146,17 +146,17 @@ void base_record::record(unsigned char* buf, int len, int cmd) bool bRet = cached_buffer(&replay_header, buf, len); if (!bRet) { - //�����������ѻ�����ļ���������ջ��� + //»º´æÒÑÂú£¬°Ñ»º´æ´æÎļþ£¬²¢ÇÒÇå¿Õ»º´æ save_buffer_to_file(int(internal_time)); - //���¸��ļ� + //´ò¿ªÏ¸öÎļþ open_next_file(); bRet = cached_buffer(&replay_header, buf, len); if (!bRet) { - //�������̫�󣬲��ܻ��棬ֱ�Ӵ��ļ� + //Èç¹û»¹ÊÇÌ«´ó£¬²»ÄÜ»º´æ£¬Ö±½Ó´æÎļþ save_to_file(ex_u32(internal_time), &replay_header, buf, len); open_next_file(); } @@ -171,7 +171,7 @@ bool base_record::cached_buffer(ts_replay_data_header* header, unsigned char* bu return false; } - //���ȹ���ֱ�Ӵ滺�� + //³¤¶È¹»³¤Ö±½Ó´æ»º´æ memcpy(m_buf + m_buf_offset, header, header_len); m_buf_offset += header_len; @@ -208,7 +208,7 @@ bool base_record::save_buffer_to_file(int internal_time) if(NULL == m_current_file) return false; - int ret = fwrite(m_buf, m_buf_offset, 1, m_current_file); /* �struct�ļ�*/ + int ret = fwrite(m_buf, m_buf_offset, 1, m_current_file); /* дµÄstructÎļþ*/ m_totol_size += m_buf_offset; m_buf_offset = 0; diff --git a/server/tp_core/core/ts_env.cpp b/server/tp_core/core/ts_env.cpp index 26194a7..6fcb50f 100644 --- a/server/tp_core/core/ts_env.cpp +++ b/server/tp_core/core/ts_env.cpp @@ -19,9 +19,9 @@ bool TsEnv::init(void) ex_dirname(m_exec_path); - // ��λ log, etc ·�� - // Ĭ������£���������Ŀ¼��λ�ڱ���ִ�г���� ../ ���λ�ã� - // ��������ڣ�������ǿ�������ģʽ�����Դ�Դ����ֿ��Ŀ¼�µ�shareĿ¼�в��ҡ� + // ¶¨Î» log, etc ·¾¶ + // ĬÈÏÇé¿öÏ£¬ÒÔÉÏÈý¸öĿ¼¾ùλÓÚ±¾¿ÉÖ´ÐгÌÐòµÄ ../ Ïà¶ÔλÖ㬠+ // Èç¹û²»´æÔÚ£¬Ôò¿ÉÄÜÊÇ¿ª·¢µ÷ÊÔģʽ£¬Ôò³¢ÊÔ´ÓÔ´´úÂë²Ö¿â¸ùĿ¼ÏµÄshareĿ¼ÖвéÕÒ¡£ ex_wstr base_path = m_exec_path; ex_path_join(base_path, true, L"..", NULL);