記錄操作數據


寫了一個記錄操作數據的類,用來抓at指令來着。沒有效率和其他的考慮,在這記錄下。

CDebugTools.h

#ifndef CDEBUGTOOLS_H_H
#define CDEBUGTOOLS_H_H
#include <string>
#include <fstream>
#include <iosfwd>


class CDebugTools{
public:
static CDebugTools& GetInstance();
void AddToLog(std::string str);
private:
CDebugTools(){m_log.open(m_strLogName.c_str());};
CDebugTools(const CDebugTools&){};
CDebugTools& operator=(const CDebugTools&){return *this;};


private:
std::ofstream m_log;
// 日誌名稱
static const std::wstring m_strLogName;
};


#endif



CDebugTools.cpp

#include "stdafx.h"
#include "CDebugTools.h"
using namespace std;


const wstring CDebugTools::m_strLogName = L"./deto.log";
CDebugTools& CDebugTools::GetInstance()
{
static CDebugTools s_DebugTools;
return s_DebugTools;
}


void CDebugTools::AddToLog( std::string str )
{
m_log.write(str.c_str(),str.length());
m_log.flush();
}


發佈了28 篇原創文章 · 獲贊 1 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章