secureswitools/swisistools/source/interpretsislib/logger.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 17 Dec 2009 08:51:10 +0200
changeset 0 ba25891c3a9e
permissions -rw-r--r--
Revision: 200949 Kit: 200951

/*
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


#include "logger.h"
#include <iostream>


struct LoggerImpl
{
	bool SetLevel(WarnLevel aLev) {  iLev = aLev; return true; }
	bool SetStream(std::wostream& aOs) { iWos = &aOs; return true; }

	std::wostream& Stream() { return *iWos; } 
	bool ShouldPrint(WarnLevel aLev) { return iLev >= aLev; } 

	WarnLevel iLev;
	std::wostream *iWos;
};


LoggerImpl* Logger::iLogger = 0;

LoggerImpl& Logger::Impl()	
{
	if (!iLogger)
	{
		iLogger = new LoggerImpl();
		iLogger->SetStream(std::wcout);
		iLogger->SetLevel(WARN_WARN);
	} 
	return *iLogger;
}


bool Logger::SetLevel(WarnLevel aLev) 
{
	return Impl().SetLevel(aLev);
}
bool Logger::SetStream(std::wostream& aOs)
{
	return Impl().SetStream(aOs);
}

std::wostream& Logger::Stream()
{
	return Impl().Stream();
}

bool Logger::ShouldPrint(WarnLevel aLev)
{
	return Impl().ShouldPrint(aLev);
}