ximpfw/core/srcutils/ximptrace.h
changeset 51 61fad867f68e
equal deleted inserted replaced
-1:000000000000 51:61fad867f68e
       
     1 /*
       
     2 * Copyright (c) 2006 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:  XIMP Framework trace utilities
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef XIMPTRACE_H__
       
    19 #define XIMPTRACE_H__
       
    20 
       
    21 #include <e32std.h>
       
    22 
       
    23 
       
    24 // CONSTANTS
       
    25 _LIT( KXIMPTraceLogDir, "ximp" );
       
    26 _LIT( KXIMPTraceLogFile, "ximp.log" );
       
    27 
       
    28 
       
    29  //TRACE INDIRECTION
       
    30 #ifdef _DEBUG
       
    31 
       
    32     /**
       
    33      * Trace handlers. Different statements with 
       
    34      * different names for handling different parameter amounts.
       
    35      *
       
    36      * Link against ximpdatamodel.dll to use trace
       
    37      * services.
       
    38      *
       
    39      * Statements produce traces only in debug builds.
       
    40      * In hardware debug builds traces go to file defined
       
    41      * KXIMPTraceLogDir and KXIMPTraceLogFile.
       
    42      */
       
    43     #define TRACE( aStatement ) XIMPTrace::Trace( aStatement )
       
    44     #define TRACE_1( aStatement, aP1 ) XIMPTrace::Trace( aStatement, aP1 )
       
    45     #define TRACE_2( aStatement, aP1, aP2 ) XIMPTrace::Trace( aStatement, aP1, aP2 )
       
    46     #define TRACE_3( aStatement, aP1, aP2, aP3 ) XIMPTrace::Trace( aStatement, aP1, aP2, aP3 )
       
    47     #define TRACE_4( aStatement, aP1, aP2, aP3, aP4 ) XIMPTrace::Trace( aStatement, aP1, aP2, aP3, aP4 )
       
    48     #define TRACE_5( aStatement, aP1, aP2, aP3, aP4, aP5 ) XIMPTrace::Trace( aStatement, aP1, aP2, aP3, aP4, aP5 )
       
    49     #define TRACE_6( aStatement, aP1, aP2, aP3, aP4, aP5, aP6 ) XIMPTrace::Trace( aStatement, aP1, aP2, aP3, aP4, aP5, aP6 )
       
    50 
       
    51 
       
    52     /**
       
    53      * Block (and thus also function) trace handlers. These 
       
    54      * mark block enter, exit and also non local exit to traces.
       
    55      *
       
    56      * Example:
       
    57      * void CSomeClass::SomeMethod()
       
    58      *      {
       
    59      *      TRACE_BLOCK_ENTER( "CSomeClass::SomeMethod" );
       
    60      *
       
    61      *      Do your stuff here. If there happens a leave
       
    62      *      or return before "TRACE_BLOCK_EXIT()" statement,
       
    63      *      it is marked to traces with "CSomeClass::SomeMethod - nonlocal exit"
       
    64      *
       
    65      *      TRACE_BLOCK_EXIT();
       
    66      *      }
       
    67      */
       
    68     #define TRACE_BLOCK_ENTER( aBlockName ) TXIMPBlockTraceHandler __blockTraceHandler( _S( aBlockName ) );
       
    69     #define TRACE_BLOCK_EXIT() __blockTraceHandler.NormalExit();
       
    70 
       
    71 
       
    72 
       
    73 #else //NOT _DEBUG
       
    74 
       
    75     #define TRACE( aStatement )
       
    76     #define TRACE_1( aStatement, aP1 )
       
    77     #define TRACE_2( aStatement, aP1, aP2 )
       
    78     #define TRACE_3( aStatement, aP1, aP2, aP3 )
       
    79     #define TRACE_4( aStatement, aP1, aP2, aP3, aP4 )
       
    80     #define TRACE_5( aStatement, aP1, aP2, aP3, aP4, aP5 )
       
    81     #define TRACE_6( aStatement, aP1, aP2, aP3, aP4, aP5, aP6 )
       
    82     #define TRACE_BLOCK_ENTER( aBlockName )
       
    83     #define TRACE_BLOCK_EXIT()
       
    84 
       
    85 #endif
       
    86 
       
    87 
       
    88 
       
    89 /**
       
    90  * XIMP Framework trace sink.
       
    91  *
       
    92  * @lib ximpdatamodel.dll
       
    93  * @since S60 v3.2
       
    94  */
       
    95 class XIMPTrace
       
    96     {
       
    97 public:
       
    98 
       
    99     /**
       
   100      * Trace sink.
       
   101      *
       
   102      * @param aFmt A format list to print to trace.
       
   103      */
       
   104     IMPORT_C static void Trace( TRefByValue<const TDesC> aFmt,... );
       
   105 
       
   106 
       
   107 
       
   108 private: //Prohibited construtor / destructor
       
   109     XIMPTrace();
       
   110     ~XIMPTrace();
       
   111     };
       
   112 
       
   113 
       
   114 
       
   115 /**
       
   116  * XIMP Framework block trace handler.
       
   117  *
       
   118  * @lib ximpdatamodel.dll
       
   119  * @since S60 v3.2
       
   120  */
       
   121 NONSHARABLE_CLASS( TXIMPBlockTraceHandler )
       
   122     {
       
   123 public:
       
   124 
       
   125     /**
       
   126      * Block trace handler constructor.
       
   127      *
       
   128      * @param aBlockName Block name.
       
   129      */
       
   130     TXIMPBlockTraceHandler( const TText* aBlockName );
       
   131 
       
   132 
       
   133     /**
       
   134      * Block trace handler destructor.
       
   135      */
       
   136     ~TXIMPBlockTraceHandler();
       
   137 
       
   138 
       
   139     /**
       
   140      * Marks that block has reached its normal exit.
       
   141      */
       
   142     void NormalExit();
       
   143 
       
   144 
       
   145 private:
       
   146     //Block name
       
   147     const TPtrC   iBlockName;
       
   148 
       
   149     //Normal exit marker
       
   150     TBool iBlockNormalExit;
       
   151 };
       
   152 
       
   153 
       
   154 #endif  // XIMPTRACE_H__
       
   155