convergedconnectionhandler/inc/cchlogger.h
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Provides macros for logging
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CCHLOGGER_H__
       
    21 #define __CCHLOGGER_H__
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32def.h>
       
    25 #include <e32svr.h>
       
    26 #include <e32base.h>
       
    27 #include <e32std.h>
       
    28 
       
    29 // CONSTS
       
    30 const TInt KMaxLogLineLength = 512;
       
    31 _LIT8( KModuleName8, "CCH" );
       
    32 
       
    33 //----------------------------------------------------------------------------
       
    34 //  USER LOGGING SETTINGS
       
    35 //----------------------------------------------------------------------------
       
    36 
       
    37 #ifndef _DEBUG
       
    38 
       
    39 /***************************
       
    40  * Logging method variants:
       
    41  *   0 = No logging
       
    42  *   1 = Flogger
       
    43  *   2 = RDebug
       
    44  ***************************/ 
       
    45 
       
    46 #define CCH_LOGGING_METHOD      0   // UREL BUILD
       
    47 
       
    48 #else
       
    49 
       
    50 #ifdef __WINS__
       
    51 #define CCH_LOGGING_METHOD      2   // UDEB BUILD, WINS
       
    52 #else
       
    53 #define CCH_LOGGING_METHOD      2   // UDEB BUILD, HW
       
    54 #endif // __WINS__
       
    55 
       
    56 #ifdef TRACE_ENTRY_EXIT_POINT // MACRO IN MMP FILE
       
    57     #define TRACE_ENTRY_POINT TRACE_FUNC_ENTRY_DEBUG_PRINT
       
    58     #define TRACE_EXIT_POINT TRACE_FUNC_EXIT_DEBUG_PRINT    
       
    59 #endif
       
    60 
       
    61 #endif // _DEBUG
       
    62 
       
    63 // [module_name]_ENTRY_POINT;[thread_id];[function_name];[filename]:[line_number];
       
    64 _LIT8( KFuncEntryFormat8, "%S_ENTRY;%d;%S;%S:%d;");
       
    65 // [module_name]_EXIT_POINT;[thread_id];[function_name];[filename]:[line_number];
       
    66 _LIT8( KFuncExitFormat8,  "%S_EXIT_;%d;%S;%S:%d;");
       
    67 //-----------------------------------------------------------------------------
       
    68 //  LOGGING SETTINGS (DO NOT EDIT)
       
    69 //-----------------------------------------------------------------------------
       
    70 
       
    71 #if CCH_LOGGING_METHOD == 1      // Flogger
       
    72 
       
    73 #include <flogger.h>
       
    74 _LIT(KCCHLogFolder,"CCH");
       
    75 _LIT(KCCHLogFile,"CCHLOG.TXT");
       
    76 
       
    77 #elif CCH_LOGGING_METHOD == 2    // RDebug
       
    78 //Check if entry exit trace should be activated 
       
    79 
       
    80 
       
    81 
       
    82 
       
    83 #endif
       
    84 
       
    85 
       
    86 NONSHARABLE_CLASS( TOverflowTruncate8 ) : public TDes8Overflow
       
    87     {
       
    88 
       
    89 public:
       
    90     void Overflow( TDes8& /*aDes*/ ) {}
       
    91     };
       
    92 
       
    93 //Trace macro 8bit
       
    94 inline void TraceDebugPrint( TRefByValue<const TDesC8> aFmt, ...)
       
    95     {
       
    96     VA_LIST list;
       
    97     VA_START( list, aFmt );
       
    98         
       
    99     TOverflowTruncate8 overflow;
       
   100     TBuf8<KMaxLogLineLength> buf8;
       
   101     buf8.AppendFormatList( aFmt, list, &overflow );
       
   102     TBuf16<KMaxLogLineLength> buf16( buf8.Length() );
       
   103     buf16.Copy( buf8 );
       
   104     TRefByValue<const TDesC> tmpFmt( _L("%S") );
       
   105     RDebug::Print( tmpFmt, &buf16 );
       
   106     }
       
   107 
       
   108 //-----------------------------------------------------------------------------
       
   109 //  LOGGING MACROs (DO NOT EDIT)
       
   110 //
       
   111 //  USE THESE MACROS IN YOUR CODE !
       
   112 //-----------------------------------------------------------------------------
       
   113 
       
   114 #if CCH_LOGGING_METHOD == 1      // Flogger
       
   115 
       
   116 #define CCHLOGSTRING(AA)           { RFileLogger::Write(KCCHLogFolder(),KCCHLogFile(),EFileLoggingModeAppend, _L(AA) ); }
       
   117 #define CCHLOGSTRING2(AA,BB)       { RFileLogger::WriteFormat(KCCHLogFolder(),KCCHLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(_L(AA)),BB); }
       
   118 #define CCHLOGSTRING3(AA,BB,CC)    { RFileLogger::WriteFormat(KCCHLogFolder(),KCCHLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(_L(AA)),BB,CC); }
       
   119 #define CCHLOGSTRING4(AA,BB,CC,DD) { RFileLogger::WriteFormat(KCCHLogFolder(),KCCHLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(_L(AA)),BB,CC,DD); }
       
   120 
       
   121 #elif CCH_LOGGING_METHOD == 2    // RDebug
       
   122 
       
   123 #define CCHLOGSTRING(AA)           { RDebug::Print(_L(AA)); }
       
   124 #define CCHLOGSTRING2(AA,BB)       { RDebug::Print(_L(AA),BB); }
       
   125 #define CCHLOGSTRING3(AA,BB,CC)    { RDebug::Print(_L(AA),BB,CC); }
       
   126 #define CCHLOGSTRING4(AA,BB,CC,DD) { RDebug::Print(_L(AA),BB,CC,DD); }
       
   127 
       
   128 
       
   129 
       
   130 #else   // CCH_LOGGING_METHOD == 0 or invalid -> Disable loggings
       
   131 
       
   132 #define CCHLOGSTRING(AA)           // Example: CCHLOGSTRING("Test");
       
   133 #define CCHLOGSTRING2(AA,BB)       // Example: CCHLOGSTRING("Test %d", aValue);
       
   134 #define CCHLOGSTRING3(AA,BB,CC)    // Example: CCHLOGSTRING("Test %d %d", aValue1, aValue2);
       
   135 #define CCHLOGSTRING4(AA,BB,CC,DD) // Example: CCHLOGSTRING("Test %d %d %d", aValue1, aValue2, aValue3);
       
   136 
       
   137 #define TRACE_ENTRY_POINT
       
   138 #define TRACE_EXIT_POINT
       
   139     
       
   140 #endif  // CCH_LOGGING_METHOD
       
   141 
       
   142 #ifdef TRACE_ENTRY_EXIT_POINT // MACRO IN MMP FILE
       
   143     #ifdef __ARMCC__
       
   144         #define TRACE_FUNC_ENTRY_DEBUG_PRINT                                                                \
       
   145         {                                                                                                   \
       
   146             const TUint threadId( RThread().Id() );                                                         \
       
   147             TPtrC8 ptr8File( (TUint8*)__MODULE__ );                                                         \
       
   148             TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ );                                                  \
       
   149             TraceDebugPrint( KFuncEntryFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ );    \
       
   150         }
       
   151         #define TRACE_FUNC_EXIT_DEBUG_PRINT                                                                 \
       
   152         {                                                                                                   \
       
   153             const TUint threadId( RThread().Id() );                                                         \
       
   154             TPtrC8 ptr8File( (TUint8*)__MODULE__ );                                                         \
       
   155             TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ );                                                  \
       
   156             TraceDebugPrint( KFuncExitFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ );     \
       
   157         }
       
   158     #else // __WINS__
       
   159         #define TRACE_FUNC_ENTRY_DEBUG_PRINT                                                                \
       
   160         {                                                                                                   \
       
   161             const TUint threadId( RThread().Id() );                                                         \
       
   162             TPtrC8 ptr8File( (TUint8*)__FILE__ );                                                           \
       
   163             TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ );                                                  \
       
   164             TraceDebugPrint( KFuncEntryFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ );    \
       
   165         }
       
   166         #define TRACE_FUNC_EXIT_DEBUG_PRINT                                                                 \
       
   167         {                                                                                                   \
       
   168             const TUint threadId( RThread().Id() );                                                         \
       
   169             TPtrC8 ptr8File( (TUint8*)__FILE__ );                                                           \
       
   170             TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ );                                                  \
       
   171             TraceDebugPrint( KFuncExitFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ );     \
       
   172         }           
       
   173     #endif
       
   174 #endif
       
   175 
       
   176 #endif  // CCHLOGGER_H