os/ossrv/lowlevellibsandfws/apputils/src/stringlogger.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/apputils/src/stringlogger.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,88 @@
     1.4 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <e32base.h>
    1.20 +#include <e32svr.h>
    1.21 +#include "StringPoolImplementation.h"
    1.22 +
    1.23 +//#define BAFL_SHOW_TRACE		
    1.24 +
    1.25 +#ifdef BAFL_SHOW_TRACE
    1.26 +void BaflShowTrace(TRefByValue<const TDesC> aFmt,...)
    1.27 +	{
    1.28 +	RDebug::Print(aFmt);
    1.29 +	}
    1.30 +#else
    1.31 +void BaflShowTrace(TRefByValue<const TDesC> /*aFmt*/,...)
    1.32 +	{
    1.33 +	}
    1.34 +#endif
    1.35 +
    1.36 +#ifdef _DEBUG
    1.37 +
    1.38 +_LIT8(KLogPrefix, "StringPool: ");
    1.39 +_LIT8(KTooLong, "(Value Too Long to print)");
    1.40 +
    1.41 +NONSHARABLE_CLASS(TStringLogOverflow) : public TDes8Overflow
    1.42 +	{
    1.43 +public:
    1.44 +	virtual void Overflow(TDes8& aDes);
    1.45 +	};
    1.46 +
    1.47 +void TStringLogOverflow::Overflow(TDes8& /* aDes*/)
    1.48 +	{
    1.49 +	}
    1.50 +
    1.51 +void StringUtils::LogIt(TRefByValue<const TDesC8> aFmt, ...)
    1.52 +//
    1.53 +//	Messages to the front end emulator and to the WAP log
    1.54 +	{
    1.55 +	VA_LIST list;
    1.56 +	VA_START(list,aFmt);
    1.57 +
    1.58 +	_LIT8(KLogPrefix, "StringPool: ");
    1.59 +
    1.60 +	TStringLogOverflow overflow;
    1.61 +
    1.62 +	TBuf8<KMaxFileName - 1> buf;
    1.63 +	buf.Copy(KLogPrefix);
    1.64 +	buf.AppendFormatList(aFmt, list, &overflow);
    1.65 +	VA_END(list);
    1.66 +
    1.67 +	TBuf<KMaxFileName> buf16;
    1.68 +	buf16.Copy(buf);
    1.69 +	BaflShowTrace(buf16);
    1.70 +	BaflShowTrace(_L("\n"));
    1.71 +	}
    1.72 +void StringUtils::LogIt1(TRefByValue<const TDesC8> aFmt)
    1.73 +//
    1.74 +//	Messages to the front end emulator and to the WAP log
    1.75 +	{
    1.76 +	const TDesC8& format = aFmt;
    1.77 +
    1.78 +	TBuf8<KMaxFileName - 1> buf;
    1.79 +	buf.Copy(KLogPrefix);
    1.80 +	if (buf.Length() + format.Length() > KMaxFileName - 1)
    1.81 +		buf.Append(KTooLong);
    1.82 +	else
    1.83 +		buf.Append(aFmt);
    1.84 +
    1.85 +	TBuf<KMaxFileName> buf16;
    1.86 +	buf16.Copy(buf);
    1.87 +	BaflShowTrace(_L("%S"), &buf16);
    1.88 +	BaflShowTrace(_L("\n"));
    1.89 +	}
    1.90 +
    1.91 +#endif // _DEBUG