diff -r 0ca79e3612d9 -r 9ba7f05d28a5 omads/omadsextensions/adapters/mediads/inc/logger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/omads/omadsextensions/adapters/mediads/inc/logger.h Tue Jul 06 14:06:02 2010 +0300 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "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: Logging macros used by Media DS Plugin +* +*/ + + +#ifndef __LOGGER_H__ +#define __LOGGER_H__ + +#ifdef _DEBUG + #ifdef __WINS__ + // File logging for WINS + #define __FLOGGING__ + #else + #define __FLOGGING__ // enable to log file on target HW + #endif //__WINS__ + + #include + #ifdef __FLOGGING__ + #include + #include + #endif + + NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { + public: + void Overflow(TDes16& /*aDes*/) {} + }; + + NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { + public: + void Overflow(TDes8& /*aDes*/) {} + }; + + _LIT( KLogDir, "MediaDS" ); + _LIT( KLogFile, "MediaDS.txt" ); + + _LIT(KTracePrefix16, "[MediaDs] "); + _LIT8(KTracePrefix8, "[MediaDs] "); + _LIT8(KFuncEntryFormat8, "%S : Begin"); + _LIT8(KFuncExitFormat8, "%S : End"); + _LIT8(KFuncReturnFormat8, "%S : End, return: %d"); + _LIT8(KFuncFormat8, "><%S"); + + const TInt KMaxLogLineLength = 512; + + /** + * logging macros, for public use + */ + + #define LOGGER_WRITE( text ) {_LIT( KTemp, text ); FPrint( KTemp );} + #define LOGGER_WRITE_1( text,par1 ) {_LIT( KTemp, text ); FPrint( KTemp, par1 );} + #define LOGGER_WRITE8_1( text,par1 ) {_LIT8( KTemp, text ); FPrint( KTemp, par1 );} + #define LOGGER_WRITE_2( text,par1,par2 ) {_LIT( KTemp, text ); FPrint( KTemp, par1, par2 );} + #define LOGGER_WRITE_3( text,par1,par2,par3 ) {_LIT( KTemp, text ); FPrint( KTemp, par1, par2, par3 );} + + // New function logging macros + #define TRACE_FUNC_ENTRY {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncEntryFormat8, &ptr8);} + #define TRACE_FUNC_EXIT {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncExitFormat8, &ptr8);} + #define TRACE_FUNC {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncFormat8, &ptr8);} + + #define TRACE_FUNC_RET( number ) {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncReturnFormat8, &ptr8, number);} + // Declare the FPrint function + inline void FPrint( TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + #ifdef __FLOGGING__ + RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list ); + #endif + TBuf16 theFinalString; + theFinalString.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); + } + + // Declare the FPrint function + inline void FPrint(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); + #ifdef __FLOGGING__ + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); + #endif + TOverflowTruncate8 overflow; + TBuf8 buf8; + buf8.Append(KTracePrefix8); + buf8.AppendFormatList(aFmt, list, &overflow); + TBuf16 buf16(buf8.Length()); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); + } +#else // no _DEBUG defined + + // No loggings --> reduced code size + #define LOGGER_WRITE( text ) + #define LOGGER_WRITE_1( text, par1 ) + #define LOGGER_WRITE8_1( text, par1 ) + #define LOGGER_WRITE_2( text, par1, par2 ) + #define LOGGER_WRITE_3( text, par1, par2, par3 ) + #define TRACE_FUNC_ENTRY + #define TRACE_FUNC_EXIT + #define TRACE_FUNC + #define TRACE_FUNC_RET( number ) + +#endif // _DEBUG + +#endif // __LOGGER_H__ +