您的位置:首页 > 编程语言 > C语言/C++

简单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 );

}

}

};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: