presencecache/presencecachesymbian/presencecacheutils/inc/prestrace.h
changeset 71 7cc7d74059f9
child 72 6abfb1094884
equal deleted inserted replaced
65:ae724a111993 71:7cc7d74059f9
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Presence Cache trace utilities
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef PRESTRACE_H__
       
    19 #define PRESTRACE_H__
       
    20 
       
    21 #include <e32std.h>
       
    22 
       
    23 
       
    24 // CONSTANTS
       
    25 _LIT( KPresenceTraceLogDir, "presence" );
       
    26 _LIT( KPresenceTraceLogFile, "presence.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      * Statements produce traces only in debug builds.
       
    37      * In hardware debug builds traces go to file defined
       
    38      * KPresenceTraceLogDir and KPresenceTraceLogFile.
       
    39      */
       
    40     #define TRACE( aStatement ) PresenceTrace::Trace( aStatement )
       
    41     #define TRACE_1( aStatement, aP1 ) PresenceTrace::Trace( aStatement, aP1 )
       
    42     #define TRACE_2( aStatement, aP1, aP2 ) PresenceTrace::Trace( aStatement, aP1, aP2 )
       
    43     #define TRACE_3( aStatement, aP1, aP2, aP3 ) PresenceTrace::Trace( aStatement, aP1, aP2, aP3 )
       
    44     #define TRACE_4( aStatement, aP1, aP2, aP3, aP4 ) PresenceTrace::Trace( aStatement, aP1, aP2, aP3, aP4 )
       
    45     #define TRACE_5( aStatement, aP1, aP2, aP3, aP4, aP5 ) PresenceTrace::Trace( aStatement, aP1, aP2, aP3, aP4, aP5 )
       
    46     #define TRACE_6( aStatement, aP1, aP2, aP3, aP4, aP5, aP6 ) PresenceTrace::Trace( aStatement, aP1, aP2, aP3, aP4, aP5, aP6 )
       
    47 
       
    48 
       
    49     /**
       
    50      * Block (and thus also function) trace handlers. These 
       
    51      * mark block enter, exit and also non local exit to traces.
       
    52      *
       
    53      * Example:
       
    54      * void CSomeClass::SomeMethod()
       
    55      *      {
       
    56      *      TRACE_BLOCK_ENTER( "CSomeClass::SomeMethod" );
       
    57      *
       
    58      *      Do your stuff here. If there happens a leave
       
    59      *      or return before "TRACE_BLOCK_EXIT()" statement,
       
    60      *      it is marked to traces with "CSomeClass::SomeMethod - nonlocal exit"
       
    61      *
       
    62      *      TRACE_BLOCK_EXIT();
       
    63      *      }
       
    64      */
       
    65     #define TRACE_BLOCK_ENTER( aBlockName ) TPresenceBlockTraceHandler __blockTraceHandler( _S( aBlockName ) );
       
    66     #define TRACE_BLOCK_EXIT() __blockTraceHandler.NormalExit();
       
    67 
       
    68 
       
    69 
       
    70 #else //NOT _DEBUG
       
    71 
       
    72     #define TRACE( aStatement )
       
    73     #define TRACE_1( aStatement, aP1 )
       
    74     #define TRACE_2( aStatement, aP1, aP2 )
       
    75     #define TRACE_3( aStatement, aP1, aP2, aP3 )
       
    76     #define TRACE_4( aStatement, aP1, aP2, aP3, aP4 )
       
    77     #define TRACE_5( aStatement, aP1, aP2, aP3, aP4, aP5 )
       
    78     #define TRACE_6( aStatement, aP1, aP2, aP3, aP4, aP5, aP6 )
       
    79     #define TRACE_BLOCK_ENTER( aBlockName )
       
    80     #define TRACE_BLOCK_EXIT()
       
    81 
       
    82 #endif
       
    83 
       
    84 
       
    85 
       
    86 /**
       
    87  * trace sink.
       
    88  */
       
    89 class PresenceTrace
       
    90     {
       
    91 public:
       
    92 
       
    93     /**
       
    94      * Trace sink.
       
    95      *
       
    96      * @param aFmt A format list to print to trace.
       
    97      */
       
    98     IMPORT_C static void Trace( TRefByValue<const TDesC> aFmt,... );
       
    99 
       
   100 
       
   101 
       
   102 private: //Prohibited construtor / destructor
       
   103     PresenceTrace();
       
   104     ~PresenceTrace();
       
   105     };
       
   106 
       
   107 
       
   108 
       
   109 /**
       
   110  * Block trace handler.
       
   111  */
       
   112 NONSHARABLE_CLASS( TPresenceBlockTraceHandler )
       
   113     {
       
   114 public:
       
   115 
       
   116     /**
       
   117      * Block trace handler constructor.
       
   118      *
       
   119      * @param aBlockName Block name.
       
   120      */
       
   121     TPresenceBlockTraceHandler( const TText* aBlockName );
       
   122 
       
   123 
       
   124     /**
       
   125      * Block trace handler destructor.
       
   126      */
       
   127     ~TPresenceBlockTraceHandler();
       
   128 
       
   129 
       
   130     /**
       
   131      * Marks that block has reached its normal exit.
       
   132      */
       
   133     void NormalExit();
       
   134 
       
   135 
       
   136 private:
       
   137     //Block name
       
   138     const TPtrC   iBlockName;
       
   139 
       
   140     //Normal exit marker
       
   141     TBool iBlockNormalExit;
       
   142 };
       
   143 
       
   144 
       
   145 #endif  // PRESTRACE_H__
       
   146