internetradio2.0/inc/irdebug.h
changeset 14 896e9dbc5f19
child 16 5723da102db1
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
       
     1 /*
       
     2 * Copyright (c) 2004-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:  Debug macros
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef IRDEBUG_H
       
    20 #define IRDEBUG_H
       
    21 
       
    22 
       
    23 #include <e32debug.h>
       
    24 #include <flogger.h>
       
    25 ///////////////////////////////////////////////////////
       
    26 ///////////////////////////////////////////////////////
       
    27 // Debug usage
       
    28 //
       
    29 // Set IR_DEBUG_LEVEL to desired level to get debug logs that are equal or more severe 
       
    30 // than the value set. E.g. IR_DEBUG_LEVEL_ERROR will print out ERROR and FATAL logs.
       
    31 //
       
    32 // Set IRDEBUG_TRACE_TO_FILE to get enable file logging.
       
    33 //
       
    34 ///////////////////////////////////////////////////////
       
    35 
       
    36 // Available debug levels. Internal. Don't touch these
       
    37 
       
    38 #define IR_DEBUG_LEVEL_NONE    0
       
    39 #define IR_DEBUG_LEVEL_FATAL   1
       
    40 #define IR_DEBUG_LEVEL_ERROR   2
       
    41 #define IR_DEBUG_LEVEL_WARNING 3
       
    42 #define IR_DEBUG_LEVEL_INFO    4
       
    43 #define IR_DEBUG_LEVEL_DEBUG   5
       
    44 
       
    45 /////////////////////////////////////////////////////////////////////
       
    46 // DEBUG SETTINGS:
       
    47 // To enable /adjust debug output, modify values ONLY in this section
       
    48 /////////////////////////////////////////////////////////////////////
       
    49 //#define IRDEBUG_LOGGING_ENABLED
       
    50 //#define IRDEBUG_TRACE_TO_FILE
       
    51 
       
    52 
       
    53 /////////////////////////////////////////////////////////////////////
       
    54 // DEBUG SETTINGS:
       
    55 // DO NOT Edit below sections
       
    56 /////////////////////////////////////////////////////////////////////
       
    57 
       
    58 #ifdef IRDEBUG_LOGGING_ENABLED
       
    59 #define IR_DEBUG_LEVEL IR_DEBUG_LEVEL_DEBUG
       
    60 #define IRDEBUG_LEVEL  IR_DEBUG_LEVEL_DEBUG
       
    61 #else
       
    62 #define IR_DEBUG_LEVEL IR_DEBUG_LEVEL_NONE
       
    63 #define IRDEBUG_LEVEL  IR_DEBUG_LEVEL_NONE
       
    64 #endif
       
    65 
       
    66 #ifdef IRDEBUG_TRACE_TO_FILE
       
    67     _LIT( KIRDebugLogDirectory, "internetradio" );
       
    68     _LIT( KIRDebugLogFile, "internetradiolog.txt" );
       
    69     const TFileLoggingMode KIRDebugLoggingMode = EFileLoggingModeAppend; // EFileLoggingModeOverwrite
       
    70 #endif
       
    71 
       
    72 #if IR_DEBUG_LEVEL > IR_DEBUG_LEVEL_NONE
       
    73 
       
    74 #ifdef IRDEBUG_TRACE_TO_FILE
       
    75         #define IRRDEBUG_DESC( a ) \
       
    76             { \
       
    77             RFileLogger::WriteFormat( KIRDebugLogDirectory, \
       
    78                                       KIRDebugLogFile, \
       
    79                                       KIRDebugLoggingMode, \
       
    80                                       a ); \
       
    81             }
       
    82             
       
    83         #define IRRDEBUG( a ) \
       
    84             { \
       
    85             RFileLogger::WriteFormat( KIRDebugLogDirectory, \
       
    86                                       KIRDebugLogFile, \
       
    87                                       KIRDebugLoggingMode, \
       
    88                                       _L( a )); \
       
    89             }
       
    90                      
       
    91         #define IRRDEBUG2( a, b ) \
       
    92             { \
       
    93             RFileLogger::WriteFormat( KIRDebugLogDirectory, \
       
    94                                       KIRDebugLogFile, \
       
    95                                       KIRDebugLoggingMode, \
       
    96                                       _L( a ), b); \
       
    97             }
       
    98             
       
    99         #define IRRDEBUG3( a, b, c ) \
       
   100             { \
       
   101             RFileLogger::WriteFormat( KIRDebugLogDirectory, \
       
   102                                       KIRDebugLogFile, \
       
   103                                       KIRDebugLoggingMode, \
       
   104                                       _L( a ), b, c); \
       
   105             }
       
   106             
       
   107         #define IRRDEBUG4( a, b, c, d ) \
       
   108             { \
       
   109             RFileLogger::WriteFormat( KIRDebugLogDirectory, \
       
   110                                       KIRDebugLogFile, \
       
   111                                       KIRDebugLoggingMode, \
       
   112                                       _L( a ), b, c, d); \
       
   113             }
       
   114             
       
   115         #define IRRDEBUG5( a, b, c, d, e ) \
       
   116             { \
       
   117             RFileLogger::WriteFormat( KIRDebugLogDirectory, \
       
   118                                       KIRDebugLogFile, \
       
   119                                       KIRDebugLoggingMode, \
       
   120                                       _L( a ), b, c, d, e); \
       
   121             }        
       
   122 #else // IRDEBUG_TRACE_TO_FILE
       
   123         #define IRRDEBUG_DESC( a ) RDebug::Print( a )
       
   124     
       
   125         #define IRRDEBUG( a ) RDebug::Print( _L( a ) )
       
   126                      
       
   127         #define IRRDEBUG2( a, b ) RDebug::Print( _L( a ), b )
       
   128             
       
   129         #define IRRDEBUG3( a, b, c ) RDebug::Print( _L( a ), b, c )
       
   130             
       
   131         #define IRRDEBUG4( a, b, c, d ) RDebug::Print( _L( a ), b, c, d )
       
   132             
       
   133         #define IRRDEBUG5( a, b, c, d, e ) RDebug::Print( _L( a ), b, c, d, e )
       
   134 #endif // IRDEBUG_TRACE_TO_FILE
       
   135            
       
   136 #else // IR_DEBUG_LEVEL > IR_DEBUG_LEVEL_NONE
       
   137     #define IRRDEBUG_DESC( a )
       
   138     #define IRRDEBUG( a )
       
   139     #define IRRDEBUG2( a, b )
       
   140     #define IRRDEBUG3( a, b, c )
       
   141     #define IRRDEBUG4( a, b, c, d )
       
   142     #define IRRDEBUG5( a, b, c, d, e )
       
   143 #endif
       
   144 
       
   145 ////////////////////////////////////////////////////////////////////
       
   146 // The interface macros
       
   147 ///////////////////////////////////////////////////////////////////
       
   148 
       
   149 
       
   150 #if IRDEBUG_LEVEL > IR_DEBUG_LEVEL_NONE
       
   151     #define IRLOG_FATAL( a ) IRRDEBUG( "InternetRadio [FATAL]: " L##a )
       
   152     #define IRLOG_FATAL2( a, b ) IRRDEBUG2( "InternetRadio [FATAL]: " L##a, b )
       
   153     #define IRLOG_FATAL3( a, b, c ) IRRDEBUG3( "InternetRadio [FATAL]: " L##a, b, c )
       
   154     #define IRLOG_FATAL4( a, b, c, d ) IRRDEBUG4( "InternetRadio [FATAL]: " L##a, b, c, d )
       
   155     #define IRLOG_FATAL5( a, b, c, d, e ) IRRDEBUG5( "InternetRadio [FATAL]: " L##a, b, c, d, e )
       
   156 #else    
       
   157     #define IRLOG_FATAL( a ) 
       
   158     #define IRLOG_FATAL2( a, b )
       
   159     #define IRLOG_FATAL3( a, b, c )
       
   160     #define IRLOG_FATAL4( a, b, c, d )
       
   161     #define IRLOG_FATAL5( a, b, c, d, e )
       
   162  #endif
       
   163 
       
   164 #if IRDEBUG_LEVEL > IR_DEBUG_LEVEL_FATAL
       
   165     #define IRLOG_ERROR( a ) IRRDEBUG( "InternetRadio [ERROR]: " L##a )
       
   166     #define IRLOG_ERROR2( a, b ) IRRDEBUG2( "InternetRadio [ERROR]: " L##a, b )
       
   167     #define IRLOG_ERROR3( a, b, c ) IRRDEBUG3( "InternetRadio [ERROR]: " L##a, b, c )
       
   168     #define IRLOG_ERROR4( a, b, c, d ) IRRDEBUG4( "InternetRadio [ERROR]: " L##a, b, c, d )
       
   169     #define IRLOG_ERROR5( a, b, c, d, e ) IRRDEBUG5( "InternetRadio [ERROR]: " L##a, b, c, d, e )
       
   170 #else
       
   171     #define IRLOG_ERROR( a )
       
   172     #define IRLOG_ERROR2( a, b )
       
   173     #define IRLOG_ERROR3( a, b, c )
       
   174     #define IRLOG_ERROR4( a, b, c, d ) 
       
   175     #define IRLOG_ERROR5( a, b, c, d, e )
       
   176 #endif
       
   177 
       
   178 #if IRDEBUG_LEVEL > IR_DEBUG_LEVEL_ERROR
       
   179     #define IRLOG_WARNING( a ) IRRDEBUG( "InternetRadio [WARNING]: " L##a )
       
   180     #define IRLOG_WARNING2( a, b ) IRRDEBUG2( "InternetRadio [WARNING]: " L##a, b )
       
   181     #define IRLOG_WARNING3( a, b, c ) IRRDEBUG3( "InternetRadio [WARNING]: " L##a, b, c )
       
   182     #define IRLOG_WARNING4( a, b, c, d ) IRRDEBUG4( "InternetRadio [WARNING]: " L##a, b, c, d )
       
   183     #define IRLOG_WARNING5( a, b, c, d, e ) IRRDEBUG5( "InternetRadio [WARNING]: " L##a, b, c, d, e )
       
   184 #else
       
   185     #define IRLOG_WARNING( a )
       
   186     #define IRLOG_WARNING2( a, b )
       
   187     #define IRLOG_WARNING3( a, b, c )
       
   188     #define IRLOG_WARNING4( a, b, c, d )
       
   189     #define IRLOG_WARNING5( a, b, c, d, e )
       
   190 #endif
       
   191 
       
   192 #if IRDEBUG_LEVEL > IR_DEBUG_LEVEL_WARNING
       
   193     #define IRLOG_INFO( a ) IRRDEBUG( "InternetRadio [INFO]: " L##a )
       
   194     #define IRLOG_INFO2( a, b ) IRRDEBUG2( "InternetRadio [INFO]: " L##a, b )
       
   195     #define IRLOG_INFO3( a, b, c ) IRRDEBUG3( "InternetRadio [INFO]: " L##a, b, c )
       
   196     #define IRLOG_INFO4( a, b, c, d ) IRRDEBUG4( "InternetRadio [INFO]: " L##a, b, c, d )
       
   197     #define IRLOG_INFO5( a, b, c, d, e ) IRRDEBUG5( "InternetRadio [INFO]: " L##a, b, c, d, e )
       
   198 #else
       
   199     #define IRLOG_INFO( a )
       
   200     #define IRLOG_INFO2( a, b )
       
   201     #define IRLOG_INFO3( a, b, c )
       
   202     #define IRLOG_INFO4( a, b, c, d )
       
   203     #define IRLOG_INFO5( a, b, c, d, e )
       
   204 #endif
       
   205 
       
   206 #if IRDEBUG_LEVEL > IR_DEBUG_LEVEL_INFO
       
   207     _LIT( KIRDebugMarker, "InternetRadio [DEBUG]: " );
       
   208     #define IRLOG_DEBUG_DESC( desc ) \
       
   209         { \
       
   210         RBuf tmp; \
       
   211         tmp.Create(KIRDebugMarker, KIRDebugMarker().Length() + desc.Length() ); \
       
   212         tmp.Append(desc); \
       
   213         IRRDEBUG_DESC(tmp); \
       
   214         tmp.Close(); \
       
   215         }
       
   216     #define IRLOG_DEBUG( a ) IRRDEBUG( "InternetRadio [DEBUG]: " L##a )
       
   217     #define IRLOG_DEBUG2( a, b ) IRRDEBUG2( "InternetRadio [DEBUG]: " L##a, b )
       
   218     #define IRLOG_DEBUG3( a, b, c ) IRRDEBUG3( "InternetRadio [DEBUG]: " L##a, b, c )
       
   219     #define IRLOG_DEBUG4( a, b, c, d ) IRRDEBUG4( "InternetRadio [DEBUG]: " L##a, b, c, d )
       
   220     #define IRLOG_DEBUG5( a, b, c, d, e ) IRRDEBUG5( "InternetRadio [DEBUG]: " L##a, b, c, d, e )
       
   221 #else
       
   222     #define IRLOG_DEBUG_DESC( desc )
       
   223     #define IRLOG_DEBUG( a )
       
   224     #define IRLOG_DEBUG2( a, b )
       
   225     #define IRLOG_DEBUG3( a, b, c )
       
   226     #define IRLOG_DEBUG4( a, b, c, d )
       
   227     #define IRLOG_DEBUG5( a, b, c, d, e )
       
   228 #endif     
       
   229 
       
   230 ////////////////////////////////////////////////////////////////////
       
   231 // Other debug related definitions
       
   232 ///////////////////////////////////////////////////////////////////
       
   233 
       
   234 #if IRDEBUG_LEVEL > IR_DEBUG_LEVEL_NONE
       
   235     #define IRDEBUGVAR( a ) a
       
   236     #define IRDEBUGCODE( a ) a
       
   237 #else    
       
   238     #define IRDEBUGVAR( a )   
       
   239     #define IRDEBUGCODE( a )
       
   240 #endif
       
   241 
       
   242 
       
   243           
       
   244 #endif          
       
   245             
       
   246 // End of File