// testlog4c.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
//#include "Log.h"

//using namespace SToneULog;

#pragma comment(lib,"Log4C.lib")

int _tmain(int argc, _TCHAR* argv[])
{
	//LOG4C_INIT_DEFAULT();
	//LOG_PARAM *pLogParam = new LOG_PARAM[sizeof(LOG_PARAM)];
	//LOG4C((pLogParam, LOG_ERROR, "Hello World!"));

	//if( NULL != pLogParam )
	//{
	//	delete[] pLogParam;
	//	pLogParam = NULL;
	//}
	//char strBuffer[128] = "You are the Best One!\0 Yes.";
	//LOG4C_HEX_DUMP(( LOG_TRACE, strBuffer, sizeof(strBuffer)));

#if 1		// 是否使用默认
	LOG4C_INIT_DEFAULT();
#else
	char szFileName[MAX_PATH];
	sprintf(szFileName, "%s\\log4crc", g_strDirectory); 
	///设置日志配置文件名
	LOG4C_PARAM_CFG_FILE_NAME(szFileName);
	///设置日志级别
	LOG4C_PARAM_LOG_LEVEL("unknown");
	///设置日志文件大小
	LOG4C_PARAM_LOG_FILE_SIZE(10240);
	///设置生成日志文件个数，达到最大个数将自动覆盖最旧的日志
	LOG4C_PARAM_LOG_FILE_NUM(5);
	///设置每次记录日志都重新读取日志配置文件
	LOG4C_PARAM_REREAD_LOG_CFG_FILE(1);
	///带参数日志模块初始化,以上所有设置了的参数都将生效，没有设置的采用缺省值
	LOG4C_INIT_WITH_PARAM();
#endif

	LOG4C_BLOCK_BEGIN(("LOG4C_BLOCK_BEGIN0"));
	LOG4C_BLOCK_BEGIN(("LOG4C_BLOCK_BEGIN1"));
	LOG4C_BLOCK_BEGIN(("LOG4C_BLOCK_BEGIN2"));
	LOG4C_BLOCK_BEGIN(("LOG4C_BLOCK_BEGIN3"));

	LOG4C_BLOCK_END(("LOG4C_BLOCK_BEGIN3"));
	LOG4C_BLOCK_END(("LOG4C_BLOCK_BEGIN2"));
	LOG4C_BLOCK_END(("LOG4C_BLOCK_BEGIN1"));
	LOG4C_BLOCK_END(("LOG4C_BLOCK_BEGIN0"));

	char strBuffer[128] = "You are the Best One!\0 Yes.";
	LOG4C_HEX_DUMP((LOG_INFO, strBuffer, sizeof(strBuffer)));


	LOG4C_ORIGIN ((LOG_ERROR,"LOG4C_ORIGIN"));

	LOG4C_NO_FILENUM((LOG_ERROR, "LOG4C_NO_FILENUM"));

	//LOG4C_RETURN_WITH_VALUE(( LOG4C_PRIORITY_TRACE, "message"), 1);

	LOG4C_FUN(("Hello World!"));
	LOG4C((LOG_ERROR, "Hello World!"));

	LOG4C_IF((4>3, LOG_ERROR, "LOG4C_IF:4>3"));
	LOG4C_IF((2>3, LOG_ERROR, "LOG4C_IF:2>3"));

	LOG4C_LINE();

	LOG4C_FINI();
#if 0
	int rc = 0;

	if (log4c_init())
	{
		//printf("log4c_init() failed");
		rc = 1;  
	}
	else
	{
		g_pRoot = log4c_category_get("root");

		//log4c_category_log(mycat, LOG4C_PRIORITY_ERROR, "Hello World!");

		//log4c_category_error(mycat, "you know error!");

		LOG4C("Hello World!");
		LOG4C("%s", "you know error!");

		/* Explicitly call the log4c cleanup routine */
		if ( log4c_fini())
		{
			printf("log4c_fini() failed");
		}
	}
#endif
	return 0;

}

