radioengine/settings/tsrc/inc/trace.h
branchRCL_3
changeset 20 93c594350b9a
parent 19 cce62ebc198e
equal deleted inserted replaced
19:cce62ebc198e 20:93c594350b9a
     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 "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-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"[Settings]: " 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*)"[Settings]: " ##aMsg
       
    59 
       
    60 /**
       
    61 * Define needed directories if TRACE_INTO_FILE macro in use
       
    62 */
       
    63 #ifdef TRACE_INTO_FILE
       
    64 
       
    65     _LIT( KDir, "settings" );
       
    66     _LIT( KFile, "settings.txt" );
       
    67     _LIT( KFullPath, "c:\\logs\\settings\\" );
       
    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             
       
   132     #else//TRACE_INTO_FILE not defined
       
   133     
       
   134         #define ERROR( aErr, aMsg )\
       
   135             {\
       
   136             if( aErr < KErrNone )\
       
   137                 {\
       
   138                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr );\
       
   139                 }\
       
   140             }
       
   141         #define ERROR_1( aErr, aMsg, aP1 )\
       
   142             {\
       
   143             if( aErr < KErrNone )\
       
   144                 {\
       
   145                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1 );\
       
   146                 }\
       
   147             }
       
   148         #define ERROR_2( aErr, aMsg, aP1, aP2 )\
       
   149             {\
       
   150             if( aErr < KErrNone )\
       
   151                 {\
       
   152                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\
       
   153                 }\
       
   154             }
       
   155         #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\
       
   156             {\
       
   157             if( aErr < KErrNone )\
       
   158                 {\
       
   159                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\
       
   160                 }\
       
   161             }
       
   162         #define ERROR_4( aErr, aMsg, aP1, aP2, aP3, aP4 )\
       
   163             {\
       
   164             if( aErr < KErrNone )\
       
   165                 {\
       
   166                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4 );\
       
   167                 }\
       
   168             }
       
   169         #define ERROR_5( aErr, aMsg, aP1, aP2, aP3, aP4, aP5 )\
       
   170             {\
       
   171             if( aErr < KErrNone )\
       
   172                 {\
       
   173                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4, aP5 );\
       
   174                 }\
       
   175             }
       
   176         #define ERROR_6( aErr, aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\
       
   177             {\
       
   178             if( aErr < KErrNone )\
       
   179                 {\
       
   180                 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4, aP5, aP6 );\
       
   181                 }\
       
   182             }
       
   183     
       
   184     #endif//TRACE_INTO_FILE
       
   185 
       
   186     #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg )
       
   187     #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 )
       
   188     #define ERROR_GEN_2( aMsg, aP1, aP2 ) ERROR_2( KErrGeneral, aMsg, aP1, aP2 )
       
   189     #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 ) ERROR_3( KErrGeneral, aMsg, aP1, aP3 )
       
   190     #define ERROR_GEN_4( aMsg, aP1, aP2, aP3, aP4 ) ERROR_4( KErrGeneral, aMsg, aP1, aP3, aP4 )
       
   191     #define ERROR_GEN_5( aMsg, aP1, aP2, aP3, aP4, aP5 ) ERROR_5( KErrGeneral, aMsg, aP1, aP3, aP4, aP5 )
       
   192     #define ERROR_GEN_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 ) ERROR_6( KErrGeneral, aMsg, aP1, aP3, aP4, aP5, aP6 )
       
   193 
       
   194 #else//ERROR_TRACE not defined
       
   195 
       
   196     #define ERROR( aErr, aMsg )
       
   197     #define ERROR_1( aErr, aMsg, aP1 )
       
   198     #define ERROR_2( aErr, aMsg, aP1, aP2 )
       
   199     #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )
       
   200     #define ERROR_4( aErr, aMsg, aP1, aP2, aP3, aP4 )
       
   201     #define ERROR_5( aErr, aMsg, aP1, aP2, aP3, aP4, aP5 )
       
   202     #define ERROR_6( aErr, aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )
       
   203 
       
   204     #define ERROR_GEN( aMsg )
       
   205     #define ERROR_GEN_1( aMsg, aP1 )
       
   206     #define ERROR_GEN_2( aMsg, aP1, aP2 )
       
   207     #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 )
       
   208     #define ERROR_GEN_4( aMsg, aP1, aP2, aP3, aP4 )
       
   209     #define ERROR_GEN_5( aMsg, aP1, aP2, aP3, aP4, aP5 )
       
   210     #define ERROR_GEN_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )
       
   211 
       
   212 #endif//ERROR_TRACE
       
   213 
       
   214 //-----------------------------------------------------------------------------
       
   215 // TRAP and trace with error macro
       
   216 //-----------------------------------------------------------------------------
       
   217 //
       
   218 #define TRAP_ERROR( aErr, aFunction )\
       
   219     {\
       
   220     TRAP( aErr, aFunction );\
       
   221     TPtrC8 file( ( TText8* )__FILE__ );\
       
   222     ERROR_2( aErr, "Trapped leave in '%S' line %d", &file, __LINE__);\
       
   223     }
       
   224 
       
   225 //-----------------------------------------------------------------------------
       
   226 // Info trace macros
       
   227 //-----------------------------------------------------------------------------
       
   228 //
       
   229 #ifdef INFO_TRACE
       
   230 
       
   231     /**
       
   232     * Info log message definitions.
       
   233     */
       
   234     #ifdef TRACE_INTO_FILE
       
   235     
       
   236         #define INFO( aMsg )\
       
   237             {\
       
   238             RFileLogger::Write( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ) );\
       
   239             }
       
   240         #define INFO_1( aMsg, aP1 )\
       
   241             {\
       
   242             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1 );\
       
   243             }
       
   244         #define INFO_2( aMsg, aP1, aP2 )\
       
   245             {\
       
   246             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2 );\
       
   247             }
       
   248         #define INFO_3( aMsg, aP1, aP2, aP3 )\
       
   249             {\
       
   250             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3 );\
       
   251             }
       
   252         #define INFO_4( aMsg, aP1, aP2, aP3, aP4 )\
       
   253             {\
       
   254             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4 );\
       
   255             }
       
   256         #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 )\
       
   257             {\
       
   258             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5 );\
       
   259             }
       
   260         #define INFO_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\
       
   261             {\
       
   262             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5, aP6 );\
       
   263             }
       
   264 
       
   265     #else//TRACE_INTO_FILE not defined
       
   266 
       
   267         #define INFO( aMsg )\
       
   268             {\
       
   269             RDebug::Print( _PREFIX_INFO( aMsg ) );\
       
   270             }
       
   271         #define INFO_1( aMsg, aP1 )\
       
   272             {\
       
   273             RDebug::Print( _PREFIX_INFO( aMsg ), aP1 );\
       
   274             }
       
   275         #define INFO_2( aMsg, aP1, aP2 )\
       
   276             {\
       
   277             RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2 );\
       
   278             }
       
   279         #define INFO_3( aMsg, aP1, aP2, aP3 )\
       
   280             {\
       
   281             RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3 );\
       
   282             }
       
   283         #define INFO_4( aMsg, aP1, aP2, aP3, aP4 )\
       
   284             {\
       
   285             RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4 );\
       
   286             }
       
   287         #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 )\
       
   288             {\
       
   289             RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5 );\
       
   290             }
       
   291         #define INFO_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\
       
   292             {\
       
   293             RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5, aP6 );\
       
   294             }
       
   295 
       
   296     #endif//TRACE_INTO_FILE
       
   297         
       
   298 #else//INFO_TRACE not defined
       
   299 
       
   300     #define INFO( aMsg )
       
   301     #define INFO_1( aMsg, aP1 )
       
   302     #define INFO_2( aMsg, aP1, aP2 )
       
   303     #define INFO_3( aMsg, aP1, aP2, aP3 )
       
   304     #define INFO_4( aMsg, aP1, aP2, aP3, aP4 )
       
   305     #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 )
       
   306     #define INFO_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )
       
   307 
       
   308 #endif//INFO_TRACE
       
   309 
       
   310 //-----------------------------------------------------------------------------
       
   311 // Trace current client thread name and process id
       
   312 //-----------------------------------------------------------------------------
       
   313 //
       
   314 #ifdef CLIENT_TRACE
       
   315 
       
   316     #define CLIENT_PROCESS\
       
   317         {\
       
   318         CLIENT_PROCESS_PREFIX( "" );\
       
   319         }        
       
   320 
       
   321     #define CLIENT_PROCESS_PREFIX( aPrefix )\
       
   322         {\
       
   323         RProcess process;\
       
   324         TPtrC name( process.Name() );\
       
   325         TSecureId sid( process.SecureId() );\
       
   326         TPtrC prefix( _S( aPrefix ) );\
       
   327         if( prefix.Length() )\
       
   328             {\
       
   329             INFO_3( "%S: CLIENT - Name: [%S], Sid: [0x%x]", &prefix, &name, sid.iId );\
       
   330             }\
       
   331         else\
       
   332             {\
       
   333             INFO_2( "CLIENT - Name: [%S], Sid: [0x%x]", &name, sid.iId );\
       
   334             }\
       
   335         process.Close();\
       
   336         }        
       
   337 
       
   338     #define CLIENT_MESSAGE( aMsg )\
       
   339         {\
       
   340         CLIENT_MESSAGE_PREFIX( "", aMsg );\
       
   341         }
       
   342 
       
   343     #define CLIENT_MESSAGE_PREFIX( aPrefix, aMsg )\
       
   344         {\
       
   345         RThread thread;\
       
   346         TInt err = aMsg.Client( thread );\
       
   347         if( err == KErrNone )\
       
   348             {\
       
   349             RProcess process;\
       
   350             err = thread.Process( process );\
       
   351             if( err == KErrNone )\
       
   352                 {\
       
   353                 TPtrC threadName( thread.Name() );\
       
   354                 TUid processUid( process.SecureId() );\
       
   355                 TPtrC prefix( _S( aPrefix ) );\
       
   356                 if( prefix.Length() )\
       
   357                     {\
       
   358                     INFO_4( "%S: MSG - Name: [%S], Sid: [0x%x], Message ID: [%d]",\
       
   359                         &prefix,\
       
   360                         &threadName,\
       
   361                         processUid,\
       
   362                         aMsg.Function() );\
       
   363                     }\
       
   364                 else\
       
   365                     {\
       
   366                     INFO_3( "MSG - Name: [%S], Sid: [0x%x], Message ID: [%d]",\
       
   367                         &threadName,\
       
   368                         processUid,\
       
   369                         aMsg.Function() );\
       
   370                     }\
       
   371                 }\
       
   372             process.Close();\
       
   373             }\
       
   374         thread.Close();\
       
   375         }
       
   376 
       
   377 #else
       
   378 
       
   379     #define CLIENT_PROCESS
       
   380     #define CLIENT_PROCESS_PREFIX( aPrefix )
       
   381     #define CLIENT_MESSAGE( aMsg )
       
   382     #define CLIENT_MESSAGE_PREFIX( aPrefix, aMsg )
       
   383 
       
   384 #endif
       
   385 
       
   386 //-----------------------------------------------------------------------------
       
   387 // Function trace macros
       
   388 //-----------------------------------------------------------------------------
       
   389 //
       
   390 #ifdef FUNC_TRACE
       
   391 
       
   392     /**
       
   393     * Function logging definitions.
       
   394     */
       
   395     #ifdef TRACE_INTO_FILE
       
   396     
       
   397         #define FUNC( aMsg, aP1 )\
       
   398             {\
       
   399             TPtrC8 trace( _S8( aMsg ) );\
       
   400             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, trace, aP1 );\
       
   401             }\
       
   402     
       
   403     #else//TRACE_INTO_FILE not defined
       
   404     
       
   405         #define FUNC( aMsg, aP1 )\
       
   406             {\
       
   407             RDebug::Printf( aMsg, aP1 );\
       
   408             }\
       
   409     
       
   410     #endif//TRACE_INTO_FILE
       
   411         
       
   412     /**
       
   413     * Function trace helper class.
       
   414     * 
       
   415     * NOTE:
       
   416     * LC -methods cannot be trapped. Therefore if LC -method leaves
       
   417     * END trace is used instead of LEAVE trace.
       
   418     * If you have an idea how to round this problem please tell.
       
   419     */
       
   420     _LIT8( KFuncNameTerminator, "(" );
       
   421     _LIT8( KFuncLeavePatternL, "L" );
       
   422     class TFuncLog
       
   423         {
       
   424         public:
       
   425             static void Cleanup( TAny* aPtr )
       
   426                 {
       
   427                 TFuncLog* self = static_cast< TFuncLog* >( aPtr );
       
   428                 self->iLeft = ETrue;
       
   429                 FUNC( _PREFIX_CHAR("%S-LEAVE"), &self->iFunc ); // Leave detected
       
   430                 }
       
   431             inline TFuncLog( const char* aFunc ) :
       
   432                     iFunc( aFunc ? _S8( aFunc ) : _S8("") ),
       
   433                     iLeft( EFalse ),
       
   434                     iCleanupItem( Cleanup, this ),
       
   435                     iCanLeave( EFalse )
       
   436                 {
       
   437                 TInt pos( iFunc.Find( KFuncNameTerminator ) );
       
   438                 if( pos != KErrNotFound )
       
   439                     {
       
   440                     iFunc.Set( iFunc.Left( pos ) );
       
   441                     iCanLeave = !iFunc.Right( KFuncLeavePatternL().Length() ).Compare( KFuncLeavePatternL );
       
   442                     if ( iCanLeave )
       
   443                         {
       
   444                         CleanupStack::PushL( iCleanupItem ); // Ignore warnings
       
   445                         }
       
   446                     }
       
   447                 FUNC( _PREFIX_CHAR("%S-START"), &iFunc );
       
   448                 }
       
   449 
       
   450             inline ~TFuncLog()
       
   451                 {
       
   452                 if ( !iLeft )
       
   453                     {
       
   454                     if ( iCanLeave )
       
   455                         {
       
   456                         CleanupStack::Pop( this ); // Pop the cleanup item
       
   457                         }
       
   458                     FUNC( _PREFIX_CHAR("%S-END"), &iFunc ); // Normally finished
       
   459                     }
       
   460                 }
       
   461 
       
   462         private: // Data
       
   463             TPtrC8 iFunc;
       
   464             TBool iLeft;
       
   465             TCleanupItem iCleanupItem;
       
   466             TBool iCanLeave;
       
   467         };
       
   468     #define FUNC_LOG TFuncLog _fl( __PRETTY_FUNCTION__ );
       
   469     
       
   470 #else//FUNC_TRACE not defined
       
   471 
       
   472     #define FUNC_LOG
       
   473 
       
   474 #endif//FUNC_TRACE
       
   475 
       
   476 //-----------------------------------------------------------------------------
       
   477 // Timestamp trace macros
       
   478 //-----------------------------------------------------------------------------
       
   479 //
       
   480 #ifdef TIMESTAMP_TRACE
       
   481 
       
   482     #ifdef TRACE_INTO_FILE
       
   483     
       
   484         #define TIMESTAMP( aCaption )\
       
   485             {\
       
   486             TTime t;\
       
   487             t.HomeTime();\
       
   488             TDateTime dt = t.DateTime();\
       
   489             _LIT( KCaption, aCaption );\
       
   490             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\
       
   491                 _PREFIX_TRACE("[TIMESTAMP] %S %d:%02d:%02d.%d us"),\
       
   492                     &KCaption, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond() );\
       
   493             }
       
   494 
       
   495     #else//TRACE_INTO_FILE not defined
       
   496     
       
   497         #define TIMESTAMP( aCaption )\
       
   498             {\
       
   499             TTime t;\
       
   500             t.HomeTime();\
       
   501             TDateTime dt = t.DateTime();\
       
   502             _LIT( KCaption, aCaption );\
       
   503             RDebug::Print( _PREFIX_TRACE("[TIMESTAMP] %S %d:%02d:%02d.%d us"),\
       
   504                 &KCaption, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond() );\
       
   505             }
       
   506 
       
   507     #endif//TRACE_INTO_FILE
       
   508 
       
   509 #else//TIMESTAMP_TRACE not defined
       
   510 
       
   511     #define TIMESTAMP( aCaption )
       
   512 
       
   513 #endif//TIMESTAMP_TRACE
       
   514 
       
   515 #ifdef HEAP_TRACE
       
   516 
       
   517     #ifdef TRACE_INTO_FILE
       
   518 
       
   519         #define HEAP( aMsg )\
       
   520             {\
       
   521             TInt totalAllocSpace = 0;\
       
   522             User::AllocSize( totalAllocSpace );\
       
   523             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace );\
       
   524             }
       
   525         #define HEAP_1( aMsg, aP1 )\
       
   526             {\
       
   527             TInt totalAllocSpace = 0;\
       
   528             User::AllocSize( totalAllocSpace );\
       
   529             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1 );\
       
   530             }
       
   531         #define HEAP_2( aMsg, aP1, aP2 )\
       
   532             {\
       
   533             TInt totalAllocSpace = 0;\
       
   534             User::AllocSize( totalAllocSpace );\
       
   535             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2 );\
       
   536             }
       
   537         #define HEAP_3( aMsg, aP1, aP2, aP3 )\
       
   538             {\
       
   539             TInt totalAllocSpace = 0;\
       
   540             User::AllocSize( totalAllocSpace );\
       
   541             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3 );\
       
   542             }
       
   543         #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 )\
       
   544             {\
       
   545             TInt totalAllocSpace = 0;\
       
   546             User::AllocSize( totalAllocSpace );\
       
   547             RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3, aP4 );\
       
   548             }
       
   549 
       
   550     #else//TRACE_INTO_FILE not defined
       
   551 
       
   552         #define HEAP( aMsg )\
       
   553             {\
       
   554             TInt totalAllocSpace = 0;\
       
   555             User::AllocSize( totalAllocSpace );\
       
   556             RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace );\
       
   557             }
       
   558         #define HEAP_1( aMsg, aP1 )\
       
   559             {\
       
   560             TInt totalAllocSpace = 0;\
       
   561             User::AllocSize( totalAllocSpace );\
       
   562             RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1 );\
       
   563             }
       
   564         #define HEAP_2( aMsg, aP1, aP2 )\
       
   565             {\
       
   566             TInt totalAllocSpace = 0;\
       
   567             User::AllocSize( totalAllocSpace );\
       
   568             RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2 );\
       
   569             }
       
   570         #define HEAP_3( aMsg, aP1, aP2, aP3 )\
       
   571             {\
       
   572             TInt totalAllocSpace = 0;\
       
   573             User::AllocSize( totalAllocSpace );\
       
   574             RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3 );\
       
   575             }
       
   576         #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 )\
       
   577             {\
       
   578             TInt totalAllocSpace = 0;\
       
   579             User::AllocSize( totalAllocSpace );\
       
   580             RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3, aP4 );\
       
   581             }
       
   582 
       
   583     #endif//TRACE_INTO_FILE
       
   584 
       
   585 #else//HEAP_TRACE not defined
       
   586 
       
   587     #define HEAP( aMsg )
       
   588     #define HEAP_1( aMsg, aP1 )
       
   589     #define HEAP_2( aMsg, aP1, aP2 )
       
   590     #define HEAP_3( aMsg, aP1, aP2, aP3 )
       
   591     #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 )
       
   592 
       
   593 #endif//HEAP_TRACE
       
   594 
       
   595 #endif
       
   596