⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.cpp

📁 这个程序包含了wince串口、GPS信号处理
💻 CPP
字号:
// Log.cpp: implementation of the CLog class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "gmark.h"
#include "Log.h"
#include "stdio.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CLog::CLog()
{
	fp = NULL;
}

CLog::~CLog()
{

}

void CLog::Open(LPCSTR filename)
{
	fp = fopen( filename, "wtc");

	InitializeCriticalSection( &m_CriticalSection );
}

void CLog::Write(LPCSTR message)
{
	EnterCriticalSection(&m_CriticalSection);

	SYSTEMTIME systime;

	GetLocalTime(&systime);

	DWORD dwTickCount = GetTickCount();
	
	if( fp && message )
	{
		fprintf( fp, "%d-%d-%d %d-%d-%d-%d ",
				systime.wYear, systime.wMonth, systime.wDay, 
				systime.wHour, systime.wMinute, systime.wSecond, dwTickCount/*systime.wMilliseconds*/ );
		fwrite( message, sizeof(char), strlen(message), fp );
		fputs("\n", fp);
		
		fflush(fp);
	}

	LeaveCriticalSection(&m_CriticalSection);
}

void CLog::Close()
{
	if(fp)
	{
		fclose(fp);
		fp = NULL;
	}

	DeleteCriticalSection( &m_CriticalSection );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -