videofeeds/utils/inc/IptvDebug.h
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2004-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 the License "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:    Helper class for serial or file tracing of Video Center.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef IPTVDEBUG_H
       
    21 #define IPTVDEBUG_H
       
    22 
       
    23 #include <flogger.h>
       
    24 
       
    25 // Define logging level here
       
    26 
       
    27 // Minimum log output
       
    28 #define IPTV_HIGH_LEVEL_TRACES
       
    29 
       
    30 // Medium log output
       
    31 #define IPTV_MIDDLE_LEVEL_TRACES
       
    32 
       
    33 // Maximum log output
       
    34 #define IPTV_LOW_LEVEL_TRACES
       
    35 
       
    36 
       
    37 /*
       
    38 -----------------------------------------------------------------------------
       
    39 
       
    40 	LOGGING MACROs
       
    41 
       
    42 	USE THESE MACROS IN YOUR CODE
       
    43 
       
    44 	Usage:
       
    45 	
       
    46 	Example: IPTVLOGSTRING_HIGH_LEVEL ("Test");
       
    47 	Example: IPTVLOGSTRING2_HIGH_LEVEL ("Test %d", aValue);
       
    48 	Example: IPTVLOGSTRING3_HIGH_LEVEL ("Test %d %d", aValue1, aValue2);
       
    49 	Example: IPTVLOGSTRING4_HIGH_LEVEL ("Test %d %d %d", aValue1, aValue2, aValue3);
       
    50 
       
    51 	Example: IPTV_LOG_STR_DESC_HIGH_LEVEL (own_desc);
       
    52 	Example: IPTV_LOG_STR_DESC2_HIGH_LEVEL (own_desc, aValue));
       
    53 	Example: IPTV_LOG_STR_DESC3_HIGH_LEVEL (own_desc, aValue, aValue2);
       
    54 	Example: IPTV_LOG_STR_DESC4_HIGH_LEVEL (own_desc, aValue, aValue2, aValue3);
       
    55 
       
    56 -----------------------------------------------------------------------------
       
    57 */
       
    58 
       
    59 
       
    60 #ifdef IPTV_HIGH_LEVEL_TRACES
       
    61 
       
    62 #define IPTVLOGTEXT_HIGH_LEVEL(AAAA)   IPTV_LOGTEXT(AAAA)
       
    63 #define IPTVLOGSTRING_HIGH_LEVEL(AAAA) 	IPTV_LOGSTRING(AAAA) 
       
    64 #define IPTVLOGSTRING2_HIGH_LEVEL(AAAA,BBBB) 	IPTV_LOGSTRING2(AAAA,BBBB) 
       
    65 #define IPTVLOGSTRING3_HIGH_LEVEL(AAAA,BBBB,CCCC)   IPTV_LOGSTRING3(AAAA,BBBB,CCCC) 
       
    66 #define IPTVLOGSTRING4_HIGH_LEVEL(AAAA,BBBB,CCCC,DDDD)   IPTV_LOGSTRING4(AAAA,BBBB,CCCC,DDDD) 
       
    67 
       
    68 #define IPTV_LOG_STR_DESC_HIGH_LEVEL(AAAA) 	IPTV_LOG_STR_DESC(AAAA) 
       
    69 #define IPTV_LOG_STR_DESC2_HIGH_LEVEL(AAAA,BBBB) 	IPTV_LOG_STR_DESC2(AAAA,BBBB) 
       
    70 #define IPTV_LOG_STR_DESC3_HIGH_LEVEL(AAAA,BBBB,CCCC)   IPTV_LOG_STR_DESC3(AAAA,BBBB,CCCC) 
       
    71 #define IPTV_LOG_STR_DESC4_HIGH_LEVEL(AAAA,BBBB,CCCC,DDDD)   IPTV_LOG_STR_DESC4(AAAA,BBBB,CCCC,DDDD) 
       
    72 
       
    73 #else
       
    74 
       
    75 #define IPTVLOGTEXT_HIGH_LEVEL(AAAA)
       
    76 #define IPTVLOGSTRING_HIGH_LEVEL(AAAA)
       
    77 #define IPTVLOGSTRING2_HIGH_LEVEL(AAAA,BBBB)
       
    78 #define IPTVLOGSTRING3_HIGH_LEVEL(AAAA,BBBB,CCCC)
       
    79 #define IPTVLOGSTRING4_HIGH_LEVEL(AAAA,BBBB,CCCC,DDDD)
       
    80 
       
    81 #define IPTV_LOG_STR_DESC_HIGH_LEVEL(AAAA)
       
    82 #define IPTV_LOG_STR_DESC2_HIGH_LEVEL(AAAA,BBBB)
       
    83 #define IPTV_LOG_STR_DESC3_HIGH_LEVEL(AAAA,BBBB,CCCC)
       
    84 #define IPTV_LOG_STR_DESC4_HIGH_LEVEL(AAAA,BBBB,CCCC,DDDD)
       
    85 
       
    86 #endif
       
    87 
       
    88 
       
    89 #ifdef IPTV_MIDDLE_LEVEL_TRACES
       
    90 #define TFLOGTEXT_MIDDLE_LEVEL(AAAA) IPTV_LOGTEXT(AAAA)
       
    91 #define IPTVLOGSTRING_MIDDLE_LEVEL(AAAA) IPTV_LOGSTRING(AAAA)
       
    92 #define IPTVLOGSTRING2_MIDDLE_LEVEL(AAAA,BBBB) IPTV_LOGSTRING2(AAAA,BBBB)
       
    93 #define IPTVLOGSTRING3_MIDDLE_LEVEL(AAAA,BBBB,CCCC) IPTV_LOGSTRING3(AAAA,BBBB,CCCC)
       
    94 #define IPTVLOGSTRING4_MIDDLE_LEVEL(AAAA,BBBB,CCCC,DDDD) IPTV_LOGSTRING4(AAAA,BBBB,CCCC,DDDD)
       
    95 
       
    96 #define IPTV_LOG_STR_DESC_MIDDLE_LEVEL(AAAA) 	IPTV_LOG_STR_DESC(AAAA) 
       
    97 #define IPTV_LOG_STR_DESC2_MIDDLE_LEVEL(AAAA,BBBB) 	IPTV_LOG_STR_DESC2(AAAA,BBBB) 
       
    98 #define IPTV_LOG_STR_DESC3_MIDDLE_LEVEL(AAAA,BBBB,CCCC)   IPTV_LOG_STR_DESC3(AAAA,BBBB,CCCC) 
       
    99 #define IPTV_LOG_STR_DESC4_MIDDLE_LEVEL(AAAA,BBBB,CCCC,DDDD)   IPTV_LOG_STR_DESC4(AAAA,BBBB,CCCC,DDDD) 
       
   100 
       
   101 #else
       
   102 
       
   103 #define TFLOGTEXT_MIDDLE_LEVEL(AAAA)
       
   104 #define IPTVLOGSTRING_MIDDLE_LEVEL(AAAA)
       
   105 #define IPTVLOGSTRING2_MIDDLE_LEVEL(AAAA,BBBB)
       
   106 #define IPTVLOGSTRING3_MIDDLE_LEVEL(AAAA,BBBB,CCCC)
       
   107 #define IPTVLOGSTRING4_MIDDLE_LEVEL(AAAA,BBBB,CCCC,DDDD)
       
   108 
       
   109 #define IPTV_LOG_STR_DESC_MIDDLE_LEVEL(AAAA)
       
   110 #define IPTV_LOG_STR_DESC2_MIDDLE_LEVEL(AAAA,BBBB)
       
   111 #define IPTV_LOG_STR_DESC3_MIDDLE_LEVEL(AAAA,BBBB,CCCC)
       
   112 #define IPTV_LOG_STR_DESC4_MIDDLE_LEVEL(AAAA,BBBB,CCCC,DDDD)
       
   113 
       
   114 #endif
       
   115 	    
       
   116 
       
   117 #ifdef IPTV_LOW_LEVEL_TRACES
       
   118 
       
   119 #define IPTVLOGTEXT_LOW_LEVEL(AAAA)    IPTV_LOGTEXT(AAAA)
       
   120 #define IPTVLOGSTRING_LOW_LEVEL(AAAA)    IPTV_LOGSTRING(AAAA)
       
   121 #define IPTVLOGSTRING2_LOW_LEVEL(AAAA,BBBB)    IPTV_LOGSTRING2(AAAA,BBBB)
       
   122 #define IPTVLOGSTRING3_LOW_LEVEL(AAAA,BBBB,CCCC)    IPTV_LOGSTRING3(AAAA,BBBB,CCCC)
       
   123 #define IPTVLOGSTRING4_LOW_LEVEL(AAAA,BBBB,CCCC,DDDD)    IPTV_LOGSTRING4(AAAA,BBBB,CCCC,DDDD)
       
   124 
       
   125 #define IPTV_LOG_STR_DESC_LOW_LEVEL(AAAA) 	IPTV_LOG_STR_DESC(AAAA) 
       
   126 #define IPTV_LOG_STR_DESC2_LOW_LEVEL(AAAA,BBBB) 	IPTV_LOG_STR_DESC2(AAAA,BBBB) 
       
   127 #define IPTV_LOG_STR_DESC3_LOW_LEVEL(AAAA,BBBB,CCCC)   IPTV_LOG_STR_DESC3(AAAA,BBBB,CCCC) 
       
   128 #define IPTV_LOG_STR_DESC4_LOW_LEVEL(AAAA,BBBB,CCCC,DDDD)   IPTV_LOG_STR_DESC4(AAAA,BBBB,CCCC,DDDD) 
       
   129 
       
   130 #else
       
   131 
       
   132 #define IPTVLOGTEXT_LOW_LEVEL(AAAA)
       
   133 #define IPTVLOGSTRING_LOW_LEVEL(AAAA)
       
   134 #define IPTVLOGSTRING2_LOW_LEVEL(AAAA,BBBB)
       
   135 #define IPTVLOGSTRING3_LOW_LEVEL(AAAA,BBBB,CCCC)
       
   136 #define IPTVLOGSTRING4_LOW_LEVEL(AAAA,BBBB,CCCC,DDDD)
       
   137 
       
   138 #define IPTV_LOG_STR_DESC_LOW_LEVEL(AAAA)
       
   139 #define IPTV_LOG_STR_DESC2_LOW_LEVEL(AAAA,BBBB)
       
   140 #define IPTV_LOG_STR_DESC3_LOW_LEVEL(AAAA,BBBB,CCCC)
       
   141 #define IPTV_LOG_STR_DESC4_LOW_LEVEL(AAAA,BBBB,CCCC,DDDD)
       
   142 
       
   143 #endif
       
   144 
       
   145 
       
   146 /* 
       
   147 -----------------------------------------------------------------------------
       
   148 
       
   149 	LOG SELECTION
       
   150 
       
   151 -----------------------------------------------------------------------------
       
   152 */
       
   153 
       
   154 
       
   155 // 0 = No logging, 
       
   156 // 1 = Flogger, 
       
   157 // 2 = RDebug
       
   158 
       
   159 
       
   160 #ifndef _DEBUG
       
   161 
       
   162 // UREL BUILD:
       
   163 #define IPTV_LOGGING_METHOD  0   // No logging in UREL builds
       
   164 
       
   165 #else // urel
       
   166 
       
   167 
       
   168 #ifdef __WINSCW__
       
   169 
       
   170 // WINSCW BUILD:
       
   171 #define IPTV_LOGGING_METHOD  2  // RDebug is default with emulator
       
   172 
       
   173 #else
       
   174 
       
   175 // ARMV5 BUILD:
       
   176 #define IPTV_LOGGING_METHOD  1  // Flogger is default with target device
       
   177 
       
   178 #endif
       
   179 
       
   180 
       
   181 #endif // _DEBUG
       
   182 
       
   183 
       
   184 /* 
       
   185 -----------------------------------------------------------------------------
       
   186 
       
   187 	LOG SETTINGS
       
   188 
       
   189 -----------------------------------------------------------------------------
       
   190 */
       
   191 
       
   192 #if IPTV_LOGGING_METHOD == 1      // Flogger
       
   193 
       
   194 #include <flogger.h>
       
   195 _LIT(KIPTVLogFolder,"IPTV");
       
   196 _LIT(KIPTVLogFile,"IPTVLOG.TXT");
       
   197 
       
   198 #elif IPTV_LOGGING_METHOD == 2    // RDebug
       
   199 
       
   200 #include <e32svr.h>
       
   201 
       
   202 #endif
       
   203 
       
   204 
       
   205 
       
   206 
       
   207 
       
   208 #if IPTV_LOGGING_METHOD == 1      // Flogger
       
   209 
       
   210 
       
   211 #define IPTV_LOGTEXT(AAA)                RFileLogger::Write(KIPTVLogFolder(),KIPTVLogFile(),EFileLoggingModeAppend, AAA)
       
   212 
       
   213 #define IPTV_LOG_STR_DESC(AAA)                RFileLogger::Write(KIPTVLogFolder(),KIPTVLogFile(),EFileLoggingModeAppend, AAA)
       
   214 #define IPTV_LOG_STR_DESC2(AAA,BBB)         /*lint -e{717}*/ do { RFileLogger::WriteFormat(KIPTVLogFolder(),KIPTVLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(AAA()),BBB); } while ( EFalse )
       
   215 #define IPTV_LOG_STR_DESC3(AAA,BBB,CCC)     /*lint -e{717}*/ do { RFileLogger::WriteFormat(KIPTVLogFolder(),KIPTVLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(AAA()),BBB,CCC); } while ( EFalse )
       
   216 #define IPTV_LOG_STR_DESC4(AAA,BBB,CCC,DDD) /*lint -e{717}*/ do { RFileLogger::WriteFormat(KIPTVLogFolder(),KIPTVLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(AAA()),BBB,CCC,DDD); } while ( EFalse )
       
   217 
       
   218 #define IPTV_LOGSTRING(AAA)                 /*lint -e{717}*/ do { _LIT(tempIPTVLogDes,AAA); RFileLogger::Write(KIPTVLogFolder(),KIPTVLogFile(),EFileLoggingModeAppend,tempIPTVLogDes()); } while ( EFalse )
       
   219 #define IPTV_LOGSTRING2(AAA,BBB)            /*lint -e{717}*/ do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder(),KIPTVLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempIPTVLogDes()),BBB); } while ( EFalse )
       
   220 #define IPTV_LOGSTRING3(AAA,BBB,CCC)        /*lint -e{717}*/ do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder(),KIPTVLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempIPTVLogDes()),BBB,CCC); } while ( EFalse )
       
   221 #define IPTV_LOGSTRING4(AAA,BBB,CCC,DDD)    /*lint -e{717}*/ do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder(),KIPTVLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempIPTVLogDes()),BBB,CCC,DDD); } while ( EFalse )
       
   222 
       
   223 // Time stamp
       
   224 _LIT(KIptvLogTimeFormatString, "IPTV TIMESTAMP: %H:%T:%S:%*C3");
       
   225 #define IPTV_LOGSTRING_TIMESTAMP { \
       
   226                                  TTime logTime; \
       
   227                                  logTime.HomeTime(); \
       
   228                                  TBuf<256> logBuffer; \
       
   229                                  logTime.FormatL(logBuffer, KIptvLogTimeFormatString); \
       
   230                                  RFileLogger::Write(KIPTVLogFolder(), KIPTVLogFile(), EFileLoggingModeAppend, logBuffer); \
       
   231                                  }
       
   232 
       
   233 // Memory stamp
       
   234 _LIT(KIptvLogMemoryStampString, "IPTV MEMORYSTAMP: %d KB");
       
   235 #define IPTV_LOGSTRING_MEMORYSTAMP { \
       
   236                                    User::CompressAllHeaps(); \
       
   237                                    TMemoryInfoV1Buf logMemory; \
       
   238                                    UserHal::MemoryInfo(logMemory); \
       
   239                                    TInt logMemoryInt = (TInt)(logMemory().iFreeRamInBytes); \
       
   240                                    TBuf<256> logMemoryStr; \
       
   241                                    logMemoryStr.Format(KIptvLogMemoryStampString, (logMemoryInt / 1024) ); \
       
   242                                    RFileLogger::Write(KIPTVLogFolder(), KIPTVLogFile(), EFileLoggingModeAppend, logMemoryStr); \
       
   243                                    }
       
   244 
       
   245 
       
   246 #elif IPTV_LOGGING_METHOD == 2    // RDebug
       
   247 
       
   248 
       
   249 #define IPTV_LOGTEXT(AAA)                    RDebug::Print(AAA)
       
   250 
       
   251 #define IPTV_LOG_STR_DESC(AAA)               RDebug::Print(AAA)
       
   252 #define IPTV_LOG_STR_DESC2(AAA,BBB)       	 /*lint -e{717}*/ do {  RDebug::Print(AAA, BBB); } while ( EFalse )
       
   253 #define IPTV_LOG_STR_DESC3(AAA,BBB,CCC)      /*lint -e{717}*/ do {  RDebug::Print(AAA, BBB, CCC); } while ( EFalse )
       
   254 #define IPTV_LOG_STR_DESC4(AAA,BBB,CCC,DDD)  /*lint -e{717}*/ do {  RDebug::Print(AAA, BBB, CCC, DDD); } while ( EFalse )
       
   255 
       
   256 #define IPTV_LOGSTRING(AAA)                  /*lint -e{717}*/ do { _LIT(tempIPTVLogDes,AAA); RDebug::Print(tempIPTVLogDes); } while ( EFalse )
       
   257 #define IPTV_LOGSTRING2(AAA,BBB)             /*lint -e{717}*/ do { _LIT(tempIPTVLogDes,AAA); RDebug::Print(tempIPTVLogDes, BBB); } while ( EFalse )
       
   258 #define IPTV_LOGSTRING3(AAA,BBB,CCC)         /*lint -e{717}*/ do { _LIT(tempIPTVLogDes,AAA); RDebug::Print(tempIPTVLogDes, BBB, CCC); } while ( EFalse )
       
   259 #define IPTV_LOGSTRING4(AAA,BBB,CCC,DDD)     /*lint -e{717}*/ do { _LIT(tempIPTVLogDes,AAA); RDebug::Print(tempIPTVLogDes, BBB, CCC, DDD); } while ( EFalse )
       
   260 
       
   261 // Time stamp
       
   262 _LIT(KIptvLogTimeFormatString, "IPTV TIMESTAMP: %H:%T:%S:%*C3");
       
   263 #define IPTV_LOGSTRING_TIMESTAMP { \
       
   264                                  TTime logTime; \
       
   265                                  logTime.HomeTime(); \
       
   266                                  TBuf<256> logBuffer; \
       
   267                                  logTime.FormatL(logBuffer, KIptvLogTimeFormatString); \
       
   268                                  RDebug::Print(logBuffer); \
       
   269                                  }
       
   270 
       
   271 // Memory stamp
       
   272 _LIT(KIptvLogMemoryStampString, "IPTV MEMORYSTAMP: %d KB");
       
   273 #define IPTV_LOGSTRING_MEMORYSTAMP { \
       
   274                                    User::CompressAllHeaps(); \
       
   275                                    TMemoryInfoV1Buf logMemory; \
       
   276                                    UserHal::MemoryInfo(logMemory); \
       
   277                                    TInt logMemoryInt = (TInt)(logMemory().iFreeRamInBytes); \
       
   278                                    TBuf<256> logMemoryStr; \
       
   279                                    logMemoryStr.Format(KIptvLogMemoryStampString, (logMemoryInt / 1024) ); \
       
   280                                    RDebug::Print(logMemoryStr); \
       
   281                                    }
       
   282 
       
   283 
       
   284 #else	// TF_LOGGING_METHOD == 0 or invalid
       
   285 
       
   286 
       
   287 #define IPTV_LOGSTRING(AAA)              
       
   288 #define IPTV_LOGSTRING2(AAA,BBB)         
       
   289 #define IPTV_LOGSTRING3(AAA,BBB,CCC)     
       
   290 #define IPTV_LOGSTRING4(AAA,BBB,CCC,DDD) 
       
   291 
       
   292 #define IPTV_LOGTEXT(AAA)                
       
   293 
       
   294 #define IPTV_LOG_STR_DESC(AAA)              
       
   295 #define IPTV_LOG_STR_DESC2(AAA,BBB)         
       
   296 #define IPTV_LOG_STR_DESC3(AAA,BBB,CCC)     
       
   297 #define IPTV_LOG_STR_DESC4(AAA,BBB,CCC,DDD) 
       
   298 
       
   299 #define IPTV_LOGSTRING_TIMESTAMP
       
   300 #define IPTV_LOGSTRING_MEMORYSTAMP
       
   301 
       
   302 
       
   303 #endif // TF_LOGGING_METHOD
       
   304 
       
   305 
       
   306 #endif // IPTVDEBUG_H