Click here to Skip to main content
15,881,559 members
Articles / Programming Languages / C++

3G Modem Internet Dialer

Rate me:
Please Sign up or sign in to vote.
4.90/5 (88 votes)
13 Jul 2011CPOL7 min read 772.3K   65.9K   192  
3G Modem Internet Dialer
#include "StdAfx.h"
#include "Log.h"

CLog* CLog::m_pInstance = 0;
CCriticalSection CLog::m_csinit;

CLog::CLog(void)
{
	m_LogFile.open("Log.txt", std::ios::out | std::ios::app);
	m_LogFile << "---------------------------------- Application Starting ----------------------------------";
	m_LogFile << std::endl;
}

CLog* CLog::Instance() 
{
	if (m_pInstance == 0) 
	{
		CLog::m_csinit.Lock();
		if (m_pInstance == 0) 
		{
			m_pInstance = new CLog;
		}
		CLog::m_csinit.Unlock();
	}
	return m_pInstance;
}

void CLog::LogToFile(CString sMsg)
{
	ASSERT(sMsg);
	TRACE("TRACE : %S\n", sMsg.GetString());
	m_cs.Lock();
	char szLine[2048]; //Max Read Buffer for COM port
	sprintf_s(szLine, 2048, "%S", sMsg.GetString());
	m_LogFile << szLine;
	//m_LogFile << std::endl;
	m_cs.Unlock();
}

void CLog::ShutDown()
{
	CLog::m_csinit.Lock();
	CLog::Instance()->m_LogFile.close();
	if (m_pInstance)
	{
		delete m_pInstance;
		m_pInstance = NULL;
	}
	CLog::m_csinit.Unlock();
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I love coding with C++. I always split my free time between coding and gaming Smile | :)

Comments and Discussions