记录操作数据


写了一个记录操作数据的类,用来抓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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章