clfwrapper/CommonInc/MGTracePrint.h
changeset 0 c53acadfccc6
child 42 63d7c3197545
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Trace macros
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MGTRACEPRINT_H
       
    20 #define MGTRACEPRINT_H
       
    21 
       
    22 #include "harvesterlog.h"
       
    23 
       
    24 #ifdef _DEBUG
       
    25 #define MG_ENABLE_TRACE_PRINT
       
    26 #endif
       
    27 
       
    28 // Debug logging is enabled, you may enable debug printing in release builds also
       
    29 #ifdef MG_ENABLE_TRACE_PRINT
       
    30 
       
    31     // warn if this is a release build!!
       
    32     #ifndef __WINSCW__
       
    33     #ifndef _DEBUG
       
    34         #if defined(__VC32__)
       
    35             #pragma message( "Warning: MG trace printing is on in release build!" )     // CSI: 68 #  68:use of #pragma message
       
    36         #else // __GCC32__
       
    37             #warning "MG trace printing is on in release build!"
       
    38         #endif // __VC32__
       
    39     #endif
       
    40     #endif // __WINSCW__
       
    41 
       
    42 // no include files if no debug printing --> faster compile time
       
    43 // INCLUDES
       
    44 #include <e32std.h>
       
    45 #include <e32svr.h>
       
    46 
       
    47     /**
       
    48      * Helper macro for defining debug strings with just the debug text.
       
    49      */
       
    50     #define MG_TRACE_STRING(name,s) _LIT(name,s)
       
    51 
       
    52     /**
       
    53      * Output to debugger output
       
    54      */
       
    55     #define MG_TRACE_PRINT RDebug::Print
       
    56 
       
    57 #else   // MG_ENABLE_TRACE_PRINT
       
    58 
       
    59     /**
       
    60      * Dummy struct for checking that all MG_TRACE_PRINT's define string
       
    61      * literals using space-saving MG_TRACE_STRING.
       
    62      */
       
    63     struct TMGEmptyTraceString { };     // CSI: 80 #  80:use of struct
       
    64 
       
    65     /**
       
    66      * Macro for defining debug-only literal strings (empty release version)
       
    67      */
       
    68     #define MG_TRACE_STRING(name, s) const TMGEmptyTraceString name
       
    69 
       
    70     /**
       
    71      * Output to debugger output (empty)
       
    72      */
       
    73     #define MG_TRACE_PRINT MG_EmptyTracePrint
       
    74 
       
    75 
       
    76     /// Empty debug print function for release builds.
       
    77     inline void MG_EmptyTracePrint(TMGEmptyTraceString)
       
    78         {
       
    79         }
       
    80 
       
    81     /// Empty debug print function for release builds.
       
    82     template<class T1>
       
    83     inline void MG_EmptyTracePrint(TMGEmptyTraceString,T1)
       
    84         {
       
    85         }
       
    86 
       
    87     /// Empty debug print function for release builds.
       
    88     template<class T1,class T2>
       
    89     inline void MG_EmptyTracePrint(TMGEmptyTraceString,T1,T2)
       
    90         {
       
    91         }
       
    92 
       
    93     /// Empty debug print function for release builds.
       
    94     template<class T1,class T2,class T3>
       
    95     inline void MG_EmptyTracePrint(TMGEmptyTraceString,T1,T2,T3)
       
    96         {
       
    97         }
       
    98 
       
    99     /// Empty debug print function for release builds.
       
   100     template<class T1,class T2,class T3,class T4>
       
   101     inline void MG_EmptyTracePrint(TMGEmptyTraceString,T1,T2,T3,T4)
       
   102         {
       
   103         }
       
   104 
       
   105     /// Empty debug print function for release builds.
       
   106     template<class T1,class T2,class T3,class T4,class T5>
       
   107     inline void MG_EmptyTracePrint(TMGEmptyTraceString,T1,T2,T3,T4,T5)
       
   108         {
       
   109         }
       
   110 
       
   111     /// Empty debug print function for release builds.
       
   112     template<class T1,class T2,class T3,class T4,class T5,class T6>
       
   113     inline void MG_EmptyTracePrint(TMGEmptyTraceString,T1,T2,T3,T4,T5,T6)
       
   114         {
       
   115         }
       
   116 
       
   117     /// Empty debug print function for release builds.
       
   118     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7>
       
   119     inline void MG_EmptyTracePrint(TMGEmptyTraceString,T1,T2,T3,T4,T5,T6,T7)
       
   120         {
       
   121         }
       
   122 
       
   123     /// Empty debug print function for release builds.
       
   124     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8>
       
   125     inline void MG_EmptyTracePrint(TMGEmptyTraceString,T1,T2,T3,T4,T5,T6,T7,T8)
       
   126         {
       
   127         }
       
   128 
       
   129 
       
   130 #endif  // MG_ENABLE_TRACE_PRINT
       
   131 
       
   132 /**
       
   133  * Short variant for easier basic usage.
       
   134  */
       
   135 #define MG_TRACE1( name, s ) MG_TRACE_STRING( name, s ); MG_TRACE_PRINT( name );
       
   136 
       
   137 #ifdef MG_ENABLE_TRACE_PRINT
       
   138 #define MG_TRACE2( name, s, i ) MG_TRACE_STRING( name, s ); MG_TRACE_PRINT( name, i );
       
   139 #define MG_TRACE3( name, s, i, j ) MG_TRACE_STRING( name, s ); MG_TRACE_PRINT( name, i, j );
       
   140 #define MG_TRACE4( name, s, i, j, k ) MG_TRACE_STRING( name, s ); MG_TRACE_PRINT( name, i, j, k );
       
   141 #define MG_TRACE5( name, s, i, j, k, l ) MG_TRACE_STRING( name, s ); MG_TRACE_PRINT( name, i, j, k, l );
       
   142 #else  // MG_ENABLE_DEBUG_PRINT
       
   143 // If debug printing is not enabled, strip other parameters than the string
       
   144 // away to prevent unwanted function calls in release build.
       
   145 #define MG_TRACE2( name, s, i ) MG_TRACE1( name, s )
       
   146 #define MG_TRACE3( name, s, i, j ) MG_TRACE1( name, s )
       
   147 #define MG_TRACE4( name, s, i, j, k ) MG_TRACE1( name, s )
       
   148 #define MG_TRACE5( name, s, i, j, k, l ) MG_TRACE1( name, s )
       
   149 #endif  // MG_ENABLE_DEBUG_PRINT
       
   150 
       
   151 #endif //  MGTRACEPRINT_H