hwrmhaptics/tsrc/haptics_stif/inc/trace.h
changeset 76 cb32bcc88bad
equal deleted inserted replaced
73:d38941471f1c 76:cb32bcc88bad
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Trace macro definitions.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef TRACE_H
       
    20 #define TRACE_H
       
    21 
       
    22 #include <e32base.h> // TCleanupItem
       
    23 #include "traceconfiguration.hrh"
       
    24 
       
    25 #ifdef TRACE_INTO_FILE
       
    26 #include <flogger.h> // RFileLogger
       
    27 #else
       
    28 #include <e32debug.h> // RDebug
       
    29 #endif
       
    30 
       
    31 //-----------------------------------------------------------------------------
       
    32 // Constants
       
    33 //-----------------------------------------------------------------------------
       
    34 //
       
    35 
       
    36 // NOTE!
       
    37 // Replace all COMPONENT_NAME occurnaces with your own component / module name.
       
    38 
       
    39 /**
       
    40 * Prefix trace macro to complete tracing with component name.
       
    41 * Returns TDesC which can be used directly with RDebug or RFileLogger.
       
    42 */
       
    43 #define _PREFIX_TRACE( aMsg ) TPtrC( (const TText*)L"[HapticsClientTest]: " L##aMsg )
       
    44 
       
    45 /**
       
    46 * Prefix error trace
       
    47 */
       
    48 #define _PREFIX_ERROR( aMsg ) _PREFIX_TRACE( "[ERROR: %d]: " L##aMsg )
       
    49 
       
    50 /**
       
    51 * Prefix info trace.
       
    52 */
       
    53 #define _PREFIX_INFO( aMsg ) _PREFIX_TRACE( "[INFO]: " L##aMsg )
       
    54 
       
    55 /**
       
    56 * Prefix macro for strings
       
    57 */
       
    58 #define _PREFIX_CHAR( aMsg ) (const char*)"[HapticsClientTest]: " ##aMsg
       
    59 
       
    60 /**
       
    61 * Define needed directories if TRACE_INTO_FILE macro in use
       
    62 */
       
    63 #ifdef TRACE_INTO_FILE
       
    64 
       
    65     _LIT( KDir, "HapticsClientTest" );
       
    66     _LIT( KFile, "HapticsClientTest.txt" );
       
    67     _LIT( KFullPath, "c:\\logs\\HapticsClientTest\\" );
       
    68 
       
    69 #endif
       
    70 
       
    71 //-----------------------------------------------------------------------------
       
    72 // Error trace macros
       
    73 //-----------------------------------------------------------------------------
       
    74 //
       
    75 #ifdef ERROR_TRACE
       
    76 
       
    77     /**
       
    78     * Error trace definitions.
       
    79     */
       
    80     #ifdef TRACE_INTO_FILE
       
    81 
       
    82         #define ERROR( aErr, aMsg )\
       
    83             {\
       
    84             if( aErr < KErrNone )\
       
    85                 {\
       
    86                 RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr );\
       
    87                 }\
       
    88             }
       
    89         #define ERROR_1( aErr, aMsg, aP1 )\
       
    90             {\
       
    91             if( aErr < KErrNone )\
       
    92                 {\
       
    93                 RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1 );\
       
    94                 }\
       
    95             }
       
    96         #define ERROR_2( aErr, aMsg, aP1, aP2 )\
       
    97             {\
       
    98             if( aErr < KErrNone )\
       
    99                 {\
       
   100                 RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\
       
   101                 }\
       
   102             }
       
   103         #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\
       
   104             {\
       
   105             if( aErr < KErrNone )\
       
   106                 {\
       
   107                 RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\
       
   108                 }\
       
   109             }
       
   110         #define ERROR_4( aErr, aMsg, aP1, aP2, aP3, aP4 )\
       
   111             {\
       
   112             if( aErr < KErrNone )\
       
   113                 {\
       
   114                 RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4 );\
       
   115                 }\
       
   116             }
       
   117         #define ERROR_5( aErr, aMsg, aP1, aP2, aP3, aP4, aP5 )\
       
   118             {\
       
   119             if( aErr < KErrNone )\
       
   120                 {\
       
   121                 RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4, aP5 );\
       
   122                 }\
       
   123             }
       
   124         #define ERROR_6( aErr, aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\
       
   125             {\
       
   126             if( aErr < KErrNone )\
       
   127                 {\
       
   128                 RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4, aP5 );\
       
   129                 }\
       
   130             }
       
   131 		#define TEST_ASSERT_DESC( aCondition, aDescription ) \
       
   132 			{\
       
   133 			if ( aCondition )\
       
   134 				{\
       
   135 				}\
       
   136 			else\
       
   137 				{\
       
   138 				RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aDescription ) );\
       
   139 				}\
       
   140             }
       
   141     #else//TRACE_INTO_FILE not defined
       
   142     
       
   143         #define ERROR( aErr, aMsg )\
       
   144             {\
       
   145             if( aErr < KErrNone )\
       
   146                 {\
       
   147                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr );\
       
   148                 }\
       
   149             }
       
   150         #define ERROR_1( aErr, aMsg, aP1 )\
       
   151             {\
       
   152             if( aErr < KErrNone )\
       
   153                 {\
       
   154                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1 );\
       
   155                 }\
       
   156             }
       
   157         #define ERROR_2( aErr, aMsg, aP1, aP2 )\
       
   158             {\
       
   159             if( aErr < KErrNone )\
       
   160                 {\
       
   161                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\
       
   162                 }\
       
   163             }
       
   164         #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\
       
   165             {\
       
   166             if( aErr < KErrNone )\
       
   167                 {\
       
   168                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\
       
   169                 }\
       
   170             }
       
   171         #define ERROR_4( aErr, aMsg, aP1, aP2, aP3, aP4 )\
       
   172             {\
       
   173             if( aErr < KErrNone )\
       
   174                 {\
       
   175                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4 );\
       
   176                 }\
       
   177             }
       
   178         #define ERROR_5( aErr, aMsg, aP1, aP2, aP3, aP4, aP5 )\
       
   179             {\
       
   180             if( aErr < KErrNone )\
       
   181                 {\
       
   182                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4, aP5 );\
       
   183                 }\
       
   184             }
       
   185         #define ERROR_6( aErr, aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\
       
   186             {\
       
   187             if( aErr < KErrNone )\
       
   188                 {\
       
   189                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4, aP5, aP6 );\
       
   190                 }\
       
   191             }
       
   192 		#define TEST_ASSERT_DESC( aCondition, aDescription ) \
       
   193 			{\
       
   194 			if ( aCondition )\
       
   195 				{\
       
   196 				}\
       
   197 			else\
       
   198 				{\
       
   199 				RDebug::Print( _PREFIX_INFO( aDescription ) );\
       
   200 				}\
       
   201             }
       
   202     
       
   203     #endif//TRACE_INTO_FILE
       
   204 
       
   205     #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg )
       
   206     #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 )
       
   207     #define ERROR_GEN_2( aMsg, aP1, aP2 ) ERROR_2( KErrGeneral, aMsg, aP1, aP2 )
       
   208     #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 ) ERROR_3( KErrGeneral, aMsg, aP1, aP3 )
       
   209     #define ERROR_GEN_4( aMsg, aP1, aP2, aP3, aP4 ) ERROR_4( KErrGeneral, aMsg, aP1, aP3, aP4 )
       
   210     #define ERROR_GEN_5( aMsg, aP1, aP2, aP3, aP4, aP5 ) ERROR_5( KErrGeneral, aMsg, aP1, aP3, aP4, aP5 )
       
   211     #define ERROR_GEN_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 ) ERROR_6( KErrGeneral, aMsg, aP1, aP3, aP4, aP5, aP6 )
       
   212 
       
   213 #else//ERROR_TRACE not defined
       
   214 
       
   215     #define ERROR( aErr, aMsg )
       
   216     #define ERROR_1( aErr, aMsg, aP1 )
       
   217     #define ERROR_2( aErr, aMsg, aP1, aP2 )
       
   218     #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )
       
   219     #define ERROR_4( aErr, aMsg, aP1, aP2, aP3, aP4 )
       
   220     #define ERROR_5( aErr, aMsg, aP1, aP2, aP3, aP4, aP5 )
       
   221     #define ERROR_6( aErr, aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )
       
   222 	#define TEST_ASSERT_DESC( aCondition, aDescription )
       
   223 
       
   224     #define ERROR_GEN( aMsg )
       
   225     #define ERROR_GEN_1( aMsg, aP1 )
       
   226     #define ERROR_GEN_2( aMsg, aP1, aP2 )
       
   227     #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 )
       
   228     #define ERROR_GEN_4( aMsg, aP1, aP2, aP3, aP4 )
       
   229     #define ERROR_GEN_5( aMsg, aP1, aP2, aP3, aP4, aP5 )
       
   230     #define ERROR_GEN_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )
       
   231 	#define TEST_ASSERT_DESC_GEN( aCondition, aDescription )
       
   232 
       
   233 	#endif//ERROR_TRACE
       
   234 
       
   235 //-----------------------------------------------------------------------------
       
   236 // TRAP and trace with error macro
       
   237 //-----------------------------------------------------------------------------
       
   238 //
       
   239 #define TRAP_ERROR( aErr, aFunction )\
       
   240     {\
       
   241     TRAP( aErr, aFunction );\
       
   242     TPtrC8 file( ( TText8* )__FILE__ );\
       
   243     ERROR_2( aErr, "Trapped leave in '%S' line %d", &file, __LINE__);\
       
   244     }
       
   245 
       
   246 //-----------------------------------------------------------------------------
       
   247 // Info trace macros
       
   248 //-----------------------------------------------------------------------------
       
   249 //
       
   250 #ifdef INFO_TRACE
       
   251 
       
   252     /**
       
   253     * Info log message definitions.
       
   254     */
       
   255     #ifdef TRACE_INTO_FILE
       
   256     
       
   257         #define INFO( aMsg )\
       
   258             {\
       
   259             RFileLogger::Write( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ) );\
       
   260             }
       
   261         #define INFO_1( aMsg, aP1 )\
       
   262             {\
       
   263             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1 );\
       
   264             }
       
   265         #define INFO_2( aMsg, aP1, aP2 )\
       
   266             {\
       
   267             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2 );\
       
   268             }
       
   269         #define INFO_3( aMsg, aP1, aP2, aP3 )\
       
   270             {\
       
   271             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3 );\
       
   272             }
       
   273         #define INFO_4( aMsg, aP1, aP2, aP3, aP4 )\
       
   274             {\
       
   275             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4 );\
       
   276             }
       
   277         #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 )\
       
   278             {\
       
   279             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5 );\
       
   280             }
       
   281         #define INFO_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\
       
   282             {\
       
   283             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5, aP6 );\
       
   284             }
       
   285 
       
   286     #else//TRACE_INTO_FILE not defined
       
   287 
       
   288         #define INFO( aMsg )\
       
   289             {\
       
   290             RDebug::Print( _PREFIX_INFO( aMsg ) );\
       
   291             }
       
   292         #define INFO_1( aMsg, aP1 )\
       
   293             {\
       
   294             RDebug::Print( _PREFIX_INFO( aMsg ), aP1 );\
       
   295             }
       
   296         #define INFO_2( aMsg, aP1, aP2 )\
       
   297             {\
       
   298             RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2 );\
       
   299             }
       
   300         #define INFO_3( aMsg, aP1, aP2, aP3 )\
       
   301             {\
       
   302             RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3 );\
       
   303             }
       
   304         #define INFO_4( aMsg, aP1, aP2, aP3, aP4 )\
       
   305             {\
       
   306             RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4 );\
       
   307             }
       
   308         #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 )\
       
   309             {\
       
   310             RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5 );\
       
   311             }
       
   312         #define INFO_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\
       
   313             {\
       
   314             RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5, aP6 );\
       
   315             }
       
   316 
       
   317     #endif//TRACE_INTO_FILE
       
   318         
       
   319 #else//INFO_TRACE not defined
       
   320 
       
   321     #define INFO( aMsg )
       
   322     #define INFO_1( aMsg, aP1 )
       
   323     #define INFO_2( aMsg, aP1, aP2 )
       
   324     #define INFO_3( aMsg, aP1, aP2, aP3 )
       
   325     #define INFO_4( aMsg, aP1, aP2, aP3, aP4 )
       
   326     #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 )
       
   327     #define INFO_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )
       
   328 
       
   329 #endif//INFO_TRACE
       
   330 
       
   331 //-----------------------------------------------------------------------------
       
   332 // Trace current client thread name and process id
       
   333 //-----------------------------------------------------------------------------
       
   334 //
       
   335 #ifdef CLIENT_TRACE
       
   336 
       
   337     #define CLIENT_PROCESS\
       
   338         {\
       
   339         CLIENT_PROCESS_PREFIX( "" );\
       
   340         }        
       
   341 
       
   342     #define CLIENT_PROCESS_PREFIX( aPrefix )\
       
   343         {\
       
   344         RProcess process;\
       
   345         TPtrC name( process.Name() );\
       
   346         TSecureId sid( process.SecureId() );\
       
   347         TPtrC prefix( _S( aPrefix ) );\
       
   348         if( prefix.Length() )\
       
   349             {\
       
   350             INFO_3( "%S: CLIENT - Name: [%S], Sid: [0x%x]", &prefix, &name, sid.iId );\
       
   351             }\
       
   352         else\
       
   353             {\
       
   354             INFO_2( "CLIENT - Name: [%S], Sid: [0x%x]", &name, sid.iId );\
       
   355             }\
       
   356         process.Close();\
       
   357         }        
       
   358 
       
   359     #define CLIENT_MESSAGE( aMsg )\
       
   360         {\
       
   361         CLIENT_MESSAGE_PREFIX( "", aMsg );\
       
   362         }
       
   363 
       
   364     #define CLIENT_MESSAGE_PREFIX( aPrefix, aMsg )\
       
   365         {\
       
   366         RThread thread;\
       
   367         TInt err = aMsg.Client( thread );\
       
   368         if( err == KErrNone )\
       
   369             {\
       
   370             RProcess process;\
       
   371             err = thread.Process( process );\
       
   372             if( err == KErrNone )\
       
   373                 {\
       
   374                 TPtrC threadName( thread.Name() );\
       
   375                 TUid processUid( process.SecureId() );\
       
   376                 TPtrC prefix( _S( aPrefix ) );\
       
   377                 if( prefix.Length() )\
       
   378                     {\
       
   379                     INFO_4( "%S: MSG - Name: [%S], Sid: [0x%x], Message ID: [%d]",\
       
   380                         &prefix,\
       
   381                         &threadName,\
       
   382                         processUid,\
       
   383                         aMsg.Function() );\
       
   384                     }\
       
   385                 else\
       
   386                     {\
       
   387                     INFO_3( "MSG - Name: [%S], Sid: [0x%x], Message ID: [%d]",\
       
   388                         &threadName,\
       
   389                         processUid,\
       
   390                         aMsg.Function() );\
       
   391                     }\
       
   392                 }\
       
   393             process.Close();\
       
   394             }\
       
   395         thread.Close();\
       
   396         }
       
   397 
       
   398 #else
       
   399 
       
   400     #define CLIENT_PROCESS
       
   401     #define CLIENT_PROCESS_PREFIX( aPrefix )
       
   402     #define CLIENT_MESSAGE( aMsg )
       
   403     #define CLIENT_MESSAGE_PREFIX( aPrefix, aMsg )
       
   404 
       
   405 #endif
       
   406 
       
   407 //-----------------------------------------------------------------------------
       
   408 // Function trace macros
       
   409 //-----------------------------------------------------------------------------
       
   410 //
       
   411 #ifdef FUNC_TRACE
       
   412 
       
   413     /**
       
   414     * Function logging definitions.
       
   415     */
       
   416     #ifdef TRACE_INTO_FILE
       
   417     
       
   418         #define FUNC( aMsg, aP1 )\
       
   419             {\
       
   420             TPtrC8 trace( _S8( aMsg ) );\
       
   421             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, trace, aP1 );\
       
   422             }\
       
   423     
       
   424     #else//TRACE_INTO_FILE not defined
       
   425     
       
   426         #define FUNC( aMsg, aP1 )\
       
   427             {\
       
   428             RDebug::Printf( aMsg, aP1 );\
       
   429             }\
       
   430     
       
   431     #endif//TRACE_INTO_FILE
       
   432         
       
   433     /**
       
   434     * Function trace helper class.
       
   435     * 
       
   436     * NOTE:
       
   437     * LC -methods cannot be trapped. Therefore if LC -method leaves
       
   438     * END trace is used instead of LEAVE trace.
       
   439     * If you have an idea how to round this problem please tell.
       
   440     */
       
   441     _LIT8( KFuncNameTerminator, "(" );
       
   442     _LIT8( KFuncLeavePatternL, "L" );
       
   443     class TFuncLog
       
   444         {
       
   445         public:
       
   446             static void Cleanup( TAny* aPtr )
       
   447                 {
       
   448                 TFuncLog* self = static_cast< TFuncLog* >( aPtr );
       
   449                 self->iLeft = ETrue;
       
   450                 FUNC( _PREFIX_CHAR("%S-LEAVE"), &self->iFunc ); // Leave detected
       
   451                 }
       
   452             inline TFuncLog( const char* aFunc ) :
       
   453                     iFunc( aFunc ? _S8( aFunc ) : _S8("") ),
       
   454                     iLeft( EFalse ),
       
   455                     iCleanupItem( Cleanup, this ),
       
   456                     iCanLeave( EFalse )
       
   457                 {
       
   458                 TInt pos( iFunc.Find( KFuncNameTerminator ) );
       
   459                 if( pos != KErrNotFound )
       
   460                     {
       
   461                     iFunc.Set( iFunc.Left( pos ) );
       
   462                     iCanLeave = !iFunc.Right( KFuncLeavePatternL().Length() ).Compare( KFuncLeavePatternL );
       
   463                     if ( iCanLeave )
       
   464                         {
       
   465                         CleanupStack::PushL( iCleanupItem ); // Ignore warnings
       
   466                         }
       
   467                     }
       
   468                 FUNC( _PREFIX_CHAR("%S-START"), &iFunc );
       
   469                 }
       
   470 
       
   471             inline ~TFuncLog()
       
   472                 {
       
   473                 if ( !iLeft )
       
   474                     {
       
   475                     if ( iCanLeave )
       
   476                         {
       
   477                         CleanupStack::Pop( this ); // Pop the cleanup item
       
   478                         }
       
   479                     FUNC( _PREFIX_CHAR("%S-END"), &iFunc ); // Normally finished
       
   480                     }
       
   481                 }
       
   482 
       
   483         private: // Data
       
   484             TPtrC8 iFunc;
       
   485             TBool iLeft;
       
   486             TCleanupItem iCleanupItem;
       
   487             TBool iCanLeave;
       
   488         };
       
   489     #define FUNC_LOG TFuncLog _fl( __PRETTY_FUNCTION__ );
       
   490     
       
   491 #else//FUNC_TRACE not defined
       
   492 
       
   493     #define FUNC_LOG
       
   494 
       
   495 #endif//FUNC_TRACE
       
   496 
       
   497 //-----------------------------------------------------------------------------
       
   498 // Timestamp trace macros
       
   499 //-----------------------------------------------------------------------------
       
   500 //
       
   501 #ifdef TIMESTAMP_TRACE
       
   502 
       
   503     #ifdef TRACE_INTO_FILE
       
   504     
       
   505         #define TIMESTAMP( aCaption )\
       
   506             {\
       
   507             TTime t;\
       
   508             t.HomeTime();\
       
   509             TDateTime dt = t.DateTime();\
       
   510             _LIT( KCaption, aCaption );\
       
   511             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\
       
   512                 _PREFIX_TRACE("[TIMESTAMP] %S %d:%02d:%02d.%d us"),\
       
   513                     &KCaption, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond() );\
       
   514             }
       
   515 
       
   516     #else//TRACE_INTO_FILE not defined
       
   517     
       
   518         #define TIMESTAMP( aCaption )\
       
   519             {\
       
   520             TTime t;\
       
   521             t.HomeTime();\
       
   522             TDateTime dt = t.DateTime();\
       
   523             _LIT( KCaption, aCaption );\
       
   524             RDebug::Print( _PREFIX_TRACE("[TIMESTAMP] %S %d:%02d:%02d.%d us"),\
       
   525                 &KCaption, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond() );\
       
   526             }
       
   527 
       
   528     #endif//TRACE_INTO_FILE
       
   529 
       
   530 #else//TIMESTAMP_TRACE not defined
       
   531 
       
   532     #define TIMESTAMP( aCaption )
       
   533 
       
   534 #endif//TIMESTAMP_TRACE
       
   535 
       
   536 #ifdef HEAP_TRACE
       
   537 
       
   538     #ifdef TRACE_INTO_FILE
       
   539 
       
   540         #define HEAP( aMsg )\
       
   541             {\
       
   542             TInt totalAllocSpace = 0;\
       
   543             User::AllocSize( totalAllocSpace );\
       
   544             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace );\
       
   545             }
       
   546         #define HEAP_1( aMsg, aP1 )\
       
   547             {\
       
   548             TInt totalAllocSpace = 0;\
       
   549             User::AllocSize( totalAllocSpace );\
       
   550             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1 );\
       
   551             }
       
   552         #define HEAP_2( aMsg, aP1, aP2 )\
       
   553             {\
       
   554             TInt totalAllocSpace = 0;\
       
   555             User::AllocSize( totalAllocSpace );\
       
   556             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2 );\
       
   557             }
       
   558         #define HEAP_3( aMsg, aP1, aP2, aP3 )\
       
   559             {\
       
   560             TInt totalAllocSpace = 0;\
       
   561             User::AllocSize( totalAllocSpace );\
       
   562             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3 );\
       
   563             }
       
   564         #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 )\
       
   565             {\
       
   566             TInt totalAllocSpace = 0;\
       
   567             User::AllocSize( totalAllocSpace );\
       
   568             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3, aP4 );\
       
   569             }
       
   570 
       
   571     #else//TRACE_INTO_FILE not defined
       
   572 
       
   573         #define HEAP( aMsg )\
       
   574             {\
       
   575             TInt totalAllocSpace = 0;\
       
   576             User::AllocSize( totalAllocSpace );\
       
   577             RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace );\
       
   578             }
       
   579         #define HEAP_1( aMsg, aP1 )\
       
   580             {\
       
   581             TInt totalAllocSpace = 0;\
       
   582             User::AllocSize( totalAllocSpace );\
       
   583             RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1 );\
       
   584             }
       
   585         #define HEAP_2( aMsg, aP1, aP2 )\
       
   586             {\
       
   587             TInt totalAllocSpace = 0;\
       
   588             User::AllocSize( totalAllocSpace );\
       
   589             RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2 );\
       
   590             }
       
   591         #define HEAP_3( aMsg, aP1, aP2, aP3 )\
       
   592             {\
       
   593             TInt totalAllocSpace = 0;\
       
   594             User::AllocSize( totalAllocSpace );\
       
   595             RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3 );\
       
   596             }
       
   597         #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 )\
       
   598             {\
       
   599             TInt totalAllocSpace = 0;\
       
   600             User::AllocSize( totalAllocSpace );\
       
   601             RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3, aP4 );\
       
   602             }
       
   603 
       
   604     #endif//TRACE_INTO_FILE
       
   605 
       
   606 #else//HEAP_TRACE not defined
       
   607 
       
   608     #define HEAP( aMsg )
       
   609     #define HEAP_1( aMsg, aP1 )
       
   610     #define HEAP_2( aMsg, aP1, aP2 )
       
   611     #define HEAP_3( aMsg, aP1, aP2, aP3 )
       
   612     #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 )
       
   613 
       
   614 #endif//HEAP_TRACE
       
   615 
       
   616 #endif
       
   617