程序调试过程中输出Log

本文介绍了在C++编程中如何有效地使用日志输出(Log)进行程序调试,探讨了不同级别的日志信息,如错误、警告、信息和调试,以及如何通过日志定位和解决问题。
摘要由CSDN通过智能技术生成

C++ 输出Log

C++ MFC
void CTest::WriteLog(CString strLog)
{
	
	CString str;
	CTime nowTime = CTime::GetCurrentTime();
	CString strTime = nowTime.Format(L"%Y/%m/%d %H:%M:%S");
	
	str = strTime + L" " + strLog + L"\r\n" ;
	CStdioFile file;
	file.Open(L"d:\\1\\log.txt", CFile::modeCreate | CFile::modeNoTruncate | CFile::modeReadWrite);
	file.SeekToEnd();

	file.WriteString(str);
	file.Close();
}
应用:
Void CTest::Fuction()
{
//writelog
	long t1 = GetTickCount();
	long t2;
	CString strLog;
……
//writelog
	t2=GetTickCount();
	strLog.Format(L"%2d",t2-t1);
	strLog = L"Function Name "+ strLog;
	WriteLog(strLog);
}


C#输出Log

string strLogPath;
   //write log
            string strLog = string.Empty;
            System.Diagnostics.Stopwatch s
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值