diff -r 2bb96f4ecad8 -r 8e7494275d3a omads/omadsextensions/adapters/mms/inc/logger.h --- a/omads/omadsextensions/adapters/mms/inc/logger.h Thu Aug 19 09:41:17 2010 +0300 +++ b/omads/omadsextensions/adapters/mms/inc/logger.h Tue Aug 31 15:05:37 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-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" @@ -20,74 +20,109 @@ #define __LOGGER_H__ #ifdef _DEBUG - #ifdef __WINS__ - // File logging for WINS - #define __FLOGGING__ - #else - // Logging with RDebug for target HW - #define __CLOGGING__ - //#define __FLOGGING__ // enable to log file on target HW - #endif //__WINS__ + + // Define this to enable file logging + #define __FLOGGING__ #include #include #include #include + + NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { + public: + void Overflow(TDes16& /*aDes*/) {} + }; + + NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { + public: + void Overflow(TDes8& /*aDes*/) {} + }; _LIT(KLogDir,"MMS"); _LIT(KLogFile,"MMSDataproviderLog.txt"); _LIT( KLogFormat, "[MMSDS] %S"); - _LIT(KLogEnterFn, "%S : Begin"); - _LIT(KLogLeaveFn, "%S : End"); + _LIT(KTracePrefix16, "[MMSDS] "); + _LIT8(KTracePrefix8, "[MMSDS] "); + _LIT8(KFuncEntryFormat8, "%S : Begin"); + _LIT8(KFuncExitFormat8, "%S : End"); + _LIT8(KFuncFormat8, "><%S"); + + const TInt KMaxLogLineLength = 512; /** - * Old logging macros, for public use + * Old logging macros */ #ifdef __FLOGGING__ #define LOG( AAA ) RFileLogger::Write( KLogDir,KLogFile,EFileLoggingModeAppend,AAA ) #else #define LOG( AAA ) #endif - #define LOG2( text, par1 ) { FPrint( text, par1 ); } - /** - * new logging macros, for public use - */ - #define LOGGER_ENTERFN( name ) {_LIT( temp, name ); FPrint( KLogEnterFn, &temp );} - #define LOGGER_LEAVEFN( name ) {_LIT( temp, name ); FPrint( KLogLeaveFn, &temp );} + // old function loggin macros + #define LOGGER_ENTERFN( name ) {TRACE_FUNC_ENTRY;} + #define LOGGER_LEAVEFN( name ) {TRACE_FUNC_EXIT;} - #define LOGGER_WRITE( text ) {_LIT( KTemp, text ); FPrint( KTemp );} - #define LOGGER_WRITE_1( text,par1 ) {_LIT( KTemp, text ); FPrint( KTemp, par1 );} - #define LOGGER_MSG_EC( text,par1 ) {_LIT( KTemp, text ); FPrint( KTemp, par1 );} + #define LOGGER_WRITE( text ) {_LIT( KTemp, text ); FPrint( KTemp );} + #define LOGGER_WRITE_1( text,par1 ) {_LIT( KTemp, text ); FPrint( KTemp, par1 );} + #define LOGGER_WRITE_2( text,par1,par2 ) {_LIT( KTemp, text ); FPrint( KTemp, par1, par2 );} + + // 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);} // Declare the FPrint function - inline void FPrint( TRefByValue aFmt, ...) + inline void FPrint( TRefByValue aFmt, ...) { VA_LIST list; VA_START(list,aFmt); - #if defined ( __FLOGGING__ ) + #if defined ( __FLOGGING__ ) RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list ); - #endif - #if defined ( __CLOGGING__ ) - const TInt KMaxLogData = 0x200; - TBuf< KMaxLogData > buf; - buf.FormatList( aFmt, list ); - - RDebug::Print( KLogFormat, &buf ); - #endif + #endif + + TBuf16 theFinalString; + theFinalString.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); + } + + 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 - #define LOG( AAA ) + #define LOG( A ) #define LOGGER_ENTERFN( name ) #define LOGGER_LEAVEFN( name ) #define LOGGER_WRITE( text ) #define LOGGER_WRITE_1( text,par1 ) - #define LOGGER_MSG_EC( text,par1 ) + #define LOGGER_WRITE_2( text,par1,par2 ) + + #define TRACE_FUNC_ENTRY + #define TRACE_FUNC_EXIT + #define TRACE_FUNC + #endif // _DEBUG