smartinstaller/common/debug.h
branchADM
changeset 48 364021cecc90
equal deleted inserted replaced
47:3f419852be07 48:364021cecc90
       
     1 /*
       
     2 * Copyright (c) 2009-2010 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:
       
    15 *     Debug definitions.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 #ifndef __SI_DEBUG_H__
       
    21 #define __SI_DEBUG_H__
       
    22 
       
    23 #include <e32debug.h>
       
    24 #include <flogger.h>
       
    25 #include <coeutils.h>
       
    26 
       
    27 // Add:
       
    28 // ConeUtils::EnsurePathExistsL( *buf ); \
       
    29 // ..if log dir is required to be always created
       
    30 
       
    31 #ifdef USE_LOGFILE
       
    32 #define INIT_DEBUG_LOG( aLogFile, aLogDir, aLogName ) \
       
    33 { \
       
    34 HBufC* buf = aLogFile.AllocLC(); \
       
    35 TChar systemDrive; \
       
    36 RFs::DriveToChar(RFs::GetSystemDrive(),systemDrive); \
       
    37 buf->Des()[0] = systemDrive; \
       
    38 CleanupStack::PopAndDestroy(buf); \
       
    39 iLog.Connect(); \
       
    40 iLog.CreateLog( aLogDir, aLogName, EFileLoggingModeOverwrite); \
       
    41 }
       
    42 
       
    43 #define CLOSE_DEBUG_LOG \
       
    44 	iLog.CloseLog();    \
       
    45 	iLog.Close();
       
    46 
       
    47 #define INIT_OBJECT_DEBUG_LOG \
       
    48 	RFileLogger iLog;
       
    49 #else
       
    50 
       
    51 #define INIT_DEBUG_LOG( a, b, c )
       
    52 #define CLOSE_DEBUG_LOG
       
    53 #define INIT_OBJECT_DEBUG_LOG
       
    54 
       
    55 #endif
       
    56 
       
    57 #if defined(DEBUG_ADM) || defined(_DEBUG)
       
    58 
       
    59 #ifdef USE_LOGFILE
       
    60 
       
    61 #define LOG( aMsg ) { _LIT(KMsg, aMsg); iLog.Write( KMsg ); RDebug::Print( KMsg ); }
       
    62 #define LOG2( aMsg, aParam1 ) { _LIT(KMsg, aMsg); iLog.WriteFormat( KMsg, aParam1 ); RDebug::Print( KMsg, aParam1 ); }
       
    63 #define LOG3( aMsg, aParam1, aParam2 ) { _LIT(KMsg, aMsg); iLog.WriteFormat( KMsg, aParam1, aParam2 ); RDebug::Print( KMsg, aParam1, aParam2 ); }
       
    64 #define LOG4( aMsg, aParam1, aParam2, aParam3 ) { _LIT(KMsg, aMsg); iLog.WriteFormat( KMsg, aParam1, aParam2, aParam3 ); RDebug::Print( KMsg, aParam1, aParam2, aParam3 ); }
       
    65 #define LOG5( aMsg, aParam1, aParam2, aParam3, aParam4 ) { _LIT(KMsg, aMsg); iLog.WriteFormat( KMsg, aParam1, aParam2, aParam3, aParam4 ); RDebug::Print( KMsg, aParam1, aParam2, aParam3, aParam4 ); }
       
    66 #define LOG6( aMsg, aParam1, aParam2, aParam3, aParam4, aParam5 ) { _LIT(KMsg, aMsg); iLog.WriteFormat( KMsg, aParam1, aParam2, aParam3, aParam4, aParam5 ); RDebug::Print( KMsg, aParam1, aParam2, aParam3, aParam4, aParam5 ); }
       
    67 #define LOG7( aMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6 ) { _LIT(KMsg, aMsg); iLog.WriteFormat( KMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6 ); RDebug::Print( KMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6 ); }
       
    68 #define LOG8( aMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6, aParam7 ) { _LIT(KMsg, aMsg); iLog.WriteFormat( KMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6, aParam7 ); RDebug::Print( KMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6, aParam7 ); }
       
    69 #define LOG8_2( aMsg, aParam1 ) { _LIT8(KMsg, aMsg); iLog.WriteFormat( KMsg, aParam1 ); RDebug::Print(_L("RDebug _L8() at line %d"), __LINE__); }
       
    70 #else
       
    71 
       
    72 #define LOG( aMsg ) { _LIT(KMsg, aMsg); RDebug::Print( KMsg ); }
       
    73 #define LOG2( aMsg, aParam1 ) { _LIT(KMsg, aMsg); RDebug::Print( KMsg, aParam1 ); }
       
    74 #define LOG3( aMsg, aParam1, aParam2 ) { _LIT(KMsg, aMsg); RDebug::Print( KMsg, aParam1, aParam2 ); }
       
    75 #define LOG4( aMsg, aParam1, aParam2, aParam3 ) { _LIT(KMsg, aMsg); RDebug::Print( KMsg, aParam1, aParam2, aParam3 ); }
       
    76 #define LOG5( aMsg, aParam1, aParam2, aParam3, aParam4 ) { _LIT(KMsg, aMsg); RDebug::Print( KMsg, aParam1, aParam2, aParam3, aParam4 ); }
       
    77 #define LOG6( aMsg, aParam1, aParam2, aParam3, aParam4, aParam5 ) { _LIT(KMsg, aMsg); RDebug::Print( KMsg, aParam1, aParam2, aParam3, aParam4, aParam5 ); }
       
    78 #define LOG7( aMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6 ) { _LIT(KMsg, aMsg); RDebug::Print( KMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6 ); }
       
    79 #define LOG8( aMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6, aParam7 ) { _LIT(KMsg, aMsg); RDebug::Print( KMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6, aParam7 ); }
       
    80 #define LOG8_2( aMsg, aParam1 ) { _LIT8(KMsg, aMsg); TBuf8<128> t; t.AppendFormat(KMsg, aParam1); RDebug::RawPrint(t); }
       
    81 #endif
       
    82 
       
    83 #define RLOG( aMsg ) { RDebug::Print ( _L(##aMsg) ); }
       
    84 #define RLOG2( aMsg, aParam1 ) { RDebug::Print ( _L(##aMsg), aParam1 ); }
       
    85 #define RLOG3( aMsg, aParam1, aParam2 ) { RDebug::Print ( _L(##aMsg), aParam1, aParam2 ); }
       
    86 #define RLOG4( aMsg, aParam1, aParam2, aParam3 ) { RDebug::Print ( _L(##aMsg), aParam1, aParam2, aParam3 ); }
       
    87 #define RLOG5( aMsg, aParam1, aParam2, aParam3, aParam4 ) { RDebug::Print ( _L(##aMsg), aParam1, aParam2, aParam3, aParam4 ); }
       
    88 
       
    89 #else
       
    90 
       
    91 #define LOG( a )
       
    92 #define LOG2( a, b )
       
    93 #define LOG3( a, b, c )
       
    94 #define LOG4( a, b, c, d )
       
    95 #define LOG5( aMsg, aParam1, aParam2, aParam3, aParam4 )
       
    96 #define LOG6( aMsg, aParam1, aParam2, aParam3, aParam4, aParam5 )
       
    97 #define LOG7( aMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6 )
       
    98 #define LOG8( aMsg, aParam1, aParam2, aParam3, aParam4, aParam5, aParam6, aParam7 )
       
    99 #define LOG8_2( a, b )
       
   100 #define RLOG( a )
       
   101 #define RLOG2( a, b )
       
   102 #define RLOG3( a, b, c )
       
   103 #define RLOG4( a, b, c, d )
       
   104 #define RLOG5( a, b, c, d, e )
       
   105 #endif
       
   106 
       
   107 // Forced Logs - Always printed.
       
   108 #define FLOG( aMsg ) { _LIT(KMsg, aMsg); iLog.Write( KMsg ); RDebug::Print( KMsg ); }
       
   109 #define FLOG2( aMsg, aParam1 ) { _LIT(KMsg, aMsg); iLog.WriteFormat( KMsg, aParam1 ); RDebug::Print( KMsg, aParam1 ); }
       
   110 #define FLOG3( aMsg, aParam1, aParam2 ) { _LIT(KMsg, aMsg); iLog.WriteFormat( KMsg, aParam1, aParam2 ); RDebug::Print( KMsg, aParam1, aParam2 ); }
       
   111 
       
   112 #endif