13,822
社区成员
发帖
与我相关
我的任务
分享
//---------------------------------------------------------------------------
// 把消息写入日志文件
//---------------------------------------------------------------------------
void __fastcall WriteLog(const String &from, const String &msg)
{
const String fn = _T("debug_log.txt");
const String nl = _T("\r\n"); // new line
int fileH = FileOpen(GetAppPath() + fn,fmOpenWrite);
if (fileH == -1)
fileH = FileCreate(GetAppPath() + fn);
FileSeek(fileH, 0, 2);
AnsiString str;
str = nl + _T("time: ") + Date().DateString() +
_T(" ") + Time().TimeString();
str += nl + _T("from: ") + from;
str += nl + _T("message: ") + msg + nl;
FileWrite(fileH, str.data(), str.Length());
FileClose(fileH);
}