简单C++ log 类
2016-04-21 19:10
197 查看
class CSimpleLog
{
public:
CSimpleLog( char * strLogFileName )
{
if ( strLogFileName && strlen(m_strLogFileName) )
{
strcpy( m_strLogFileName, strLogFileName );
}
m_fLog = fopen( strLogFileName, "w+b" );
}
~CSimpleLog()
{
if (m_fLog)
{
fclose(m_fLog);
m_fLog=NULL;
}
}
private:
char m_strLogFileName[200];
FILE * m_fLog;
public:
void writeLog( char * pstrLog )
{
if (m_fLog)
{
fwrite( pstrLog, 1, strlen(pstrLog), m_fLog );
fwrite("\r\n",1,2,m_fLog);
fflush( m_fLog );
}
}
};
{
public:
CSimpleLog( char * strLogFileName )
{
if ( strLogFileName && strlen(m_strLogFileName) )
{
strcpy( m_strLogFileName, strLogFileName );
}
m_fLog = fopen( strLogFileName, "w+b" );
}
~CSimpleLog()
{
if (m_fLog)
{
fclose(m_fLog);
m_fLog=NULL;
}
}
private:
char m_strLogFileName[200];
FILE * m_fLog;
public:
void writeLog( char * pstrLog )
{
if (m_fLog)
{
fwrite( pstrLog, 1, strlen(pstrLog), m_fLog );
fwrite("\r\n",1,2,m_fLog);
fflush( m_fLog );
}
}
};
相关文章推荐
- C#项目调用C++的DLL程序
- C/C++宏定义的可变参数
- C语言qsort的三种使用
- 学生成绩管理系统(c++)控制台应用程序
- C语言问卷调查
- 链队列的综合操作(详解、演示)C语言实现
- 快速排序的递归形式与非递归形式(C++版)
- 栈的应用--括号匹配的检验(C++)
- 【转载】c++ API 在屏幕上(或窗口中)的(x,y)坐标绘制一个点
- C语言宏定义和宏定义函数
- C++中的类的继承和组合
- C++ 中 cin cin.get() cin.getline()的用法
- 倒三角形代码C++
- c语言产生随机数的方法
- C++对象和类
- C语言中结构体指针的定义和引用
- C++练习题
- C++中测数组的长度
- C语言里的指针
- 数字图像处理,相位相关图像配准算法的C++实现