/***************************************************************************
                LoggerTest.cpp
                -----------------------------------------
    begin      : 2011/10/27
    copyright  : (C) 2005 SolutionBox Inc.
    author     : Service 1 Team
    email      : svc1@solbox.com
    version    : 1.0
    
    CopyRight(C) 2005 SolutionBox Inc. All Rights reserved.
    Redistribution and use in source and binary forms, with or with out
    modification, are not permitted in outside of SolutionBox Inc.
***************************************************************************/
#include "LoggerTest.h"
#include "Logger.h"
#include <iostream>

using namespace std;

CLoggerTest::CLoggerTest()
{
}

CLoggerTest::~CLoggerTest()
{
}

void CLoggerTest::Run()
{
	cout << "begin CLoggerTest::Run()." << endl;

	if( TestLoggerInit() == false )
	{
		return;
	}

	TestLogging();

	CLogger::Exit();

	cout << "end CLoggerTest::Run()." << endl;
}

bool CLoggerTest::TestLoggerInit()
{
	if( CLogger::Init( "test_util", "/user/service/logs", LDEV1 ) == false )
	{
		cout << "CLogger::Init( test_util, /user/service/log, LDEV1 ) failed." << endl;
		return false;
	}

	return true;
}

void CLoggerTest::TestLogging()
{
	FUNC_BEGIN();

	LOG( LEMR, "log level emergency" );
	LOG( LALT,     "log level alert" );
	LOG( LCRT,  "log level critical" );
	LOG( LERR,     "log level error" );
	LOG( LWAR,   "log level warning" );
	LOG( LNOT,    "log level notice" );
	LOG( LINF,      "log level info" );
	LOG( LDBG,     "log level debug" );
	LOG( LDEV,       "log level dev" );
	LOG( LDEV1,      "log level dev1" );

	_LOG_( LEMR, "-------------------------------------------------------------" );

	_LOG( LEMR,    "log level emergency" );
	_LOG( LALT,        "log level alert" );
	_LOG( LCRT,     "log level critical" );
	_LOG( LERR,        "log level error" );
	_LOG( LWAR,      "log level warning" );
	_LOG( LNOT,       "log level notice" );
	_LOG( LINF,         "log level info" );
	_LOG( LDBG,        "log level debug" );
	_LOG( LDEV,          "log level dev" );
	_LOG( LDEV1,         "log level dev1" );

	_LOG_( LEMR, "-------------------------------------------------------------" );

	_LOG_( LEMR,   "log level emergency" );
	_LOG_( LALT,       "log level alert" );
	_LOG_( LCRT,    "log level critical" );
	_LOG_( LERR,       "log level error" );
	_LOG_( LWAR, "log level warning" );
	_LOG_( LNOT,  "log level notice" );
	_LOG_( LINF,        "log level info" );
	_LOG_( LDBG,       "log level debug" );
	_LOG_( LDEV,     "log level dev" );
	_LOG_( LDEV1,        "log level dev1" );

	_LOG_( LEMR, "-------------------------------------------------------------" );

	unsigned char hexData[48] =
	{
		0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
		0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
		0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F
	};

	_LOG_HEX_( LDBG, hexData, 48 );

	FUNC_END();
}
