remotemgmt_plat/diagnostics_framework_api/inc/diagframeworkdebug.h
branchRCL_3
changeset 26 19bba8228ff0
parent 0 b497e44ab2fc
equal deleted inserted replaced
25:b183ec05bd8c 26:19bba8228ff0
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Debugging trace definition for framework and plug-ins.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DIAGFRAMEWORKDEBUG_H
       
    20 #define DIAGFRAMEWORKDEBUG_H
       
    21 
       
    22 /**
       
    23 * Diagnostics Framework Debug Traces
       
    24 *
       
    25 * This header file defines common debug trace macros for Diagnostics Framework.
       
    26 * It is used by the diagnostics framework internally. However, it is 
       
    27 * recomanded that application and plug-ins use the macros defined here
       
    28 * in order to allow consistent logging.
       
    29 *
       
    30 * Debugging messages are enabled only on non DEBUG build. 
       
    31 *
       
    32 * These macros can be configured to use either Flogger (RFileLogger) or
       
    33 * RDebug.  By default, it will use RFileLogger. If RDebug trace is needed,
       
    34 * uncomment //#define DIAG_DEBUG_LOG_USE_RDEBUG below.
       
    35 *
       
    36 * The following macros are provided by this files.
       
    37 *
       
    38 * LOGTEXT( aDescriptor );   
       
    39 *   - This prints a descriptor to log. E.g. if you have a TDesC type, then
       
    40 *   you can use this. e.g.
       
    41 *
       
    42 *       void CMyClass::PrintSomeText( const TDesC& aText )
       
    43 *           {
       
    44 *           LOGTEXT( aText );
       
    45 *           }
       
    46 * 
       
    47 * LOGSTRING( aFormat )
       
    48 * LOGSTRING2( aFormat, a );
       
    49 * LOGSTRING3( aFormat, a, b );
       
    50 * LOGSTRING4( aFormat, a, b, c );
       
    51 * LOGSTRING5( aFormat, a, b, c, d );
       
    52 *   - These macros are used to print debugging messages with formatting text 
       
    53 *   and several arguments. Formatting string is similar to printf.
       
    54 *
       
    55 *       void CMyClass::PrintSomeText( TInt aInt, TInt aHex )
       
    56 *           {
       
    57 *           LOGSTRING( "CMyClass::PrintSomeText() Enter" );
       
    58 *           LOGSTRING3( "CMyClass::PrintSomeText() aInt = %d, aHex = 0x%08x", 
       
    59 *                       aInt, 
       
    60 *                       aHex );
       
    61 *           }
       
    62 *
       
    63 */
       
    64 
       
    65 #define ENABLE_DIAG_DEBUG_LOG       // Enable diagnostics debug log
       
    66 //#define DIAG_DEBUG_LOG_USE_RDEBUG   // Use RDebug::Print instead of flogger.
       
    67 
       
    68 #if ( defined _DEBUG && defined ENABLE_DIAG_DEBUG_LOG )
       
    69 
       
    70 #ifdef DIAG_DEBUG_LOG_USE_RDEBUG
       
    71 
       
    72 #include <e32debug.h> // RDebug
       
    73 
       
    74 #define LOGTEXT( aDescriptor )                              \
       
    75     {                                                       \
       
    76     RDebug::Print( aDescriptor );                           \
       
    77     }
       
    78 
       
    79 #define LOGSTRING( aFormat )                                \
       
    80     {                                                       \
       
    81     _LIT( KFormat, aFormat );                               \
       
    82     RDebug::Print( KFormat );                               \
       
    83     }
       
    84 
       
    85 #define LOGSTRING2( aFormat, a )                            \
       
    86     {                                                       \
       
    87     _LIT( KFormat, aFormat );                               \
       
    88     RDebug::Print( KFormat, a );                            \
       
    89     }
       
    90 
       
    91 #define LOGSTRING3( aFormat, a, b )                         \
       
    92     {                                                       \
       
    93     _LIT( KFormat, aFormat );                               \
       
    94     RDebug::Print( KFormat, a, b );                         \
       
    95     }
       
    96 
       
    97 #define LOGSTRING4( aFormat, a, b, c )                      \
       
    98     {                                                       \
       
    99     _LIT( KFormat, aFormat );                               \
       
   100     RDebug::Print( KFormat, a, b, c );                      \
       
   101     }
       
   102 
       
   103 #define LOGSTRING5( aFormat, a, b, c, d )                   \
       
   104     {                                                       \
       
   105     _LIT( KFormat, aFormat );                               \
       
   106     RDebug::Print( KFormat, a, b, c, d );                   \
       
   107     }
       
   108 
       
   109 #else // #ifdef DIAG_DEBUG_LOG_USE_RDEBUG
       
   110 
       
   111 // SYSTEM INCLUDES
       
   112 #include <flogger.h>
       
   113 
       
   114 // CONSTANTS
       
   115 _LIT( KDiagFrameworkLogFolder,  "DiagFramework" );
       
   116 _LIT( KDiagFrameworkLogFile,    "LOG.TXT" );
       
   117 
       
   118 // MACROS
       
   119 #define LOGTEXT( aDescriptor )                              \
       
   120     {                                                       \
       
   121     RFileLogger::Write( KDiagFrameworkLogFolder(),          \
       
   122                         KDiagFrameworkLogFile(),            \
       
   123                         EFileLoggingModeAppend,             \
       
   124                         aDescriptor );                      \
       
   125     }
       
   126 
       
   127 #define LOGSTRING( aFormat )                                \
       
   128     {                                                       \
       
   129     _LIT( KFormat, aFormat );                               \
       
   130     RFileLogger::Write( KDiagFrameworkLogFolder(),          \
       
   131                         KDiagFrameworkLogFile(),            \
       
   132                         EFileLoggingModeAppend,             \
       
   133                         KFormat() );                        \
       
   134     }
       
   135 
       
   136 #define LOGSTRING2( aFormat, a )                            \
       
   137     {                                                       \
       
   138     _LIT( KFormat, aFormat );                               \
       
   139     RFileLogger::WriteFormat( KDiagFrameworkLogFolder(),    \
       
   140                               KDiagFrameworkLogFile(),      \
       
   141                               EFileLoggingModeAppend,       \
       
   142                               TRefByValue<const TDesC>( KFormat() ), \
       
   143                               a );                          \
       
   144     }
       
   145 
       
   146 #define LOGSTRING3( aFormat, a, b )                         \
       
   147     {                                                       \
       
   148     _LIT( KFormat, aFormat );                               \
       
   149     RFileLogger::WriteFormat( KDiagFrameworkLogFolder(),    \
       
   150                               KDiagFrameworkLogFile(),      \
       
   151                               EFileLoggingModeAppend,       \
       
   152                               TRefByValue<const TDesC>( KFormat() ), \
       
   153                               a, b );                       \
       
   154     }
       
   155 
       
   156 #define LOGSTRING4( aFormat, a, b, c )                      \
       
   157     {                                                       \
       
   158     _LIT( KFormat, aFormat );                               \
       
   159     RFileLogger::WriteFormat( KDiagFrameworkLogFolder(),    \
       
   160                               KDiagFrameworkLogFile(),      \
       
   161                               EFileLoggingModeAppend,       \
       
   162                               TRefByValue<const TDesC>( KFormat() ), \
       
   163                               a, b, c );                    \
       
   164     }
       
   165 
       
   166 #define LOGSTRING5( aFormat, a, b, c, d )                   \
       
   167     {                                                       \
       
   168     _LIT( KFormat, aFormat );                               \
       
   169     RFileLogger::WriteFormat( KDiagFrameworkLogFolder(),    \
       
   170                               KDiagFrameworkLogFile(),      \
       
   171                               EFileLoggingModeAppend, \
       
   172                               TRefByValue<const TDesC>( KFormat() ), \
       
   173                               a, b, c, d );                 \
       
   174     }
       
   175 
       
   176 #endif // #else DIAG_DEBUG_LOG_USE_RDEBUG
       
   177 
       
   178 #else   // _DEBUG && ENABLE_DIAG_DEBUG_LOG
       
   179 
       
   180 #define LOGTEXT( aDescriptor )
       
   181 #define LOGSTRING( aFormat )
       
   182 #define LOGSTRING2( aFormat, a )
       
   183 #define LOGSTRING3( aFormat, a, b )
       
   184 #define LOGSTRING4( aFormat, a, b, c )
       
   185 #define LOGSTRING5( aFormat, a, b, c, d )
       
   186 
       
   187 #endif  // else _DEBUG && ENABLE_DIAG_DEBUG_LOG
       
   188 
       
   189 #endif // DIAGFRAMEWORKDEBUG_H
       
   190 
       
   191 // End of File
       
   192