logcontrol.cpp

来自「C++ patterns设计模式」· C++ 代码 · 共 56 行

CPP
56
字号
#include "stdafx.h"
#include "logcontrol.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

namespace stk
{
	LogControl::LogControl()
		: m_logger(0)
	{
	}
	LogControl::~LogControl()
	{
		disableTrace();
	}
	// switch low level debug trace
	void LogControl::enableTrace(const char *traceFile)
	{
		assert(traceFile);
		delete m_logger;
		m_logger = new TLog(traceFile, "");
		m_logger->open();
	}
	void LogControl::disableTrace()
	{
		delete m_logger;
		m_logger = 0;
	}
	void LogControl::trace(int id, const char *fmt, ...)
	{
		if(m_logger)
		{
			va_list arg;
			va_start(arg, fmt);
			m_logger->vprint(id, fmt, arg);
			va_end(arg);
		}
	}
	void LogControl::traceBinary(int id, const char *title, const char *binary, int length)
	{
		if(m_logger)
		{
			m_logger->printb((unsigned int)id, title, (const unsigned char *)binary, length);
		}
	}

	void LogControl::flush()
	{
		if(m_logger)
			m_logger->flush();
	}

}

⌨️ 快捷键说明

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