From 3ec1bea6ea99249925bf86bf6ed58625a8346828 Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Wed, 11 Jan 2017 23:50:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E9=80=82=E9=85=8D=E8=B7=A8=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81=E3=80=82=E6=AD=A4?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=AF=E4=BB=A5=E5=9C=A8Windows=E5=92=8CLi?= =?UTF-8?q?nux=E5=B9=B3=E5=8F=B0=E7=BC=96=E8=AF=91=E9=80=9A=E8=BF=87?= =?UTF-8?q?=EF=BC=8C=E4=BD=86=E5=B0=9A=E6=9C=AA=E8=BF=9B=E8=A1=8C=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/tp_assist/tp_assist.cpp | 5 ++++- common/libex/src/ex_log.cpp | 3 +++ server/tp_core/common/base_record.cpp | 10 +++++----- server/tp_core/core/ts_env.cpp | 6 +++--- 4 files changed, 15 insertions(+), 9 deletions(-) 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);