logsui/group/LogsTraces.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2009 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 *
       
    16 */
       
    17 /**
       
    18 *
       
    19 **/
       
    20 #ifndef LOGS_TRACE_H
       
    21 #define LOGS_TRACE_H
       
    22 
       
    23 /*****************
       
    24 #ifdef _DEBUG
       
    25     #define PIM_TRAPD_HANDLE(_s) TRAPD(leave,_s); ASSERT(!leave)
       
    26     #define PIM_TRAP_HANDLE(leave, _s) TRAP(leave,_s); ASSERT(!leave)
       
    27     #define PIM_ASSERT_DEBUG(_s) TInt err = _s; ASSERT(!err)
       
    28 #else // _DEBUG
       
    29     #define PIM_TRAPD_HANDLE(_s) TRAP_IGNORE(_s)
       
    30     #define PIM_TRAP_HANDLE(leave, _s) TRAP_IGNORE(_s)    
       
    31     #define PIM_ASSERT_DEBUG(_s) _s   
       
    32 #endif // _DEBUG
       
    33 ******************/
       
    34 
       
    35 
       
    36 #ifdef _DEBUG
       
    37 
       
    38     /********************************************************************************************************************/
       
    39     //Inlude & define common data
       
    40     #include <e32base.h>
       
    41     #include <e32std.h>
       
    42     #include <flogger.h>
       
    43     #include <e32svr.h>
       
    44    
       
    45     const TInt KMaxLogLineLength = 512;
       
    46    
       
    47     /********************************************************************************************************************/
       
    48 
       
    49     // MMP MACROS
       
    50     #if defined( TRACE_MODULE_LOGSUI )
       
    51         _LIT8( KModuleName8, "LogsUI" );
       
    52     #elif defined( TRACE_MODULE_LOGSENGINE ) 
       
    53         _LIT8( KModuleName8, "LogsEngine" );
       
    54     #elif defined( TRACE_MODULE_LOGSPLUGIN ) 
       
    55         _LIT8( KModuleName8, "LogsPlugin" );
       
    56     #elif defined( TRACE_MODULE_LOGSINDICATORPLUGIN ) 
       
    57         _LIT8( KModuleName8, "LogsIndicatorPlugin" );
       
    58     #elif defined( TRACE_MODULE_AOCCTVIEW ) 
       
    59         _LIT8( KModuleName8, "AocCtView" );
       
    60     #endif
       
    61 
       
    62     // traces
       
    63     // [module_name]_ENTRY_POINT;[thread_id];[function_name];[filename]:[line_number];
       
    64     _LIT8( KFuncEntryFormat8, ";%S_ENTRY_POINT;%d;%S;%S:%d;");
       
    65     // [module_name]_EXIT_POINT;[thread_id];[function_name];[filename]:[line_number];
       
    66     _LIT8( KFuncExitFormat8,  ";%S_EXIT_POINT;%d;%S;%S:%d;");
       
    67     
       
    68     /********************************************************************************************************************/
       
    69     NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
       
    70         {
       
    71         public:
       
    72             void Overflow(TDes8& /*aDes*/) {}
       
    73         };
       
    74 
       
    75     //Trace macro 8bit
       
    76     inline void TraceDebugPrint( TRefByValue<const TDesC8> aFmt, ...)
       
    77         {
       
    78         VA_LIST list;
       
    79         VA_START( list, aFmt );
       
    80         
       
    81         TOverflowTruncate8 overflow;
       
    82         TBuf8<KMaxLogLineLength> buf8;
       
    83         buf8.AppendFormatList( aFmt, list, &overflow );
       
    84         TBuf16<KMaxLogLineLength> buf16( buf8.Length() );
       
    85         buf16.Copy( buf8 );
       
    86         TRefByValue<const TDesC> tmpFmt( _L("%S") );
       
    87         RDebug::Print( tmpFmt, &buf16 );
       
    88         }
       
    89         
       
    90     /********************************************************************************************************************/
       
    91     //Debug print
       
    92     #ifdef TRACE_ENTRY_EXIT_POINT // MACRO IN MMP FILE
       
    93         #ifdef __ARMCC__
       
    94             #define TRACE_FUNC_ENTRY_DEBUG_PRINT                                                                \
       
    95             {                                                                                                   \
       
    96                 const TUint threadId( RThread().Id() );                                                         \
       
    97                 TPtrC8 ptr8File( (TUint8*)__MODULE__ );                                                         \
       
    98                 TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ );                                                  \
       
    99                 TraceDebugPrint( KFuncEntryFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ );    \
       
   100             }
       
   101             #define TRACE_FUNC_EXIT_DEBUG_PRINT                                                                 \
       
   102             {                                                                                                   \
       
   103                 const TUint threadId( RThread().Id() );                                                         \
       
   104                 TPtrC8 ptr8File( (TUint8*)__MODULE__ );                                                         \
       
   105                 TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ );                                                  \
       
   106                 TraceDebugPrint( KFuncExitFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ );     \
       
   107             }
       
   108         #else // __WINS__
       
   109             #define TRACE_FUNC_ENTRY_DEBUG_PRINT                                                                \
       
   110             {                                                                                                   \
       
   111                 const TUint threadId( RThread().Id() );                                                         \
       
   112                 TPtrC8 ptr8File( (TUint8*)__FILE__ );                                                           \
       
   113                 TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ );                                                  \
       
   114                 TraceDebugPrint( KFuncEntryFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ );    \
       
   115             }
       
   116             #define TRACE_FUNC_EXIT_DEBUG_PRINT                                                                 \
       
   117             {                                                                                                   \
       
   118                 const TUint threadId( RThread().Id() );                                                         \
       
   119                 TPtrC8 ptr8File( (TUint8*)__FILE__ );                                                           \
       
   120                 TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ );                                                  \
       
   121                 TraceDebugPrint( KFuncExitFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ );     \
       
   122             }
       
   123         #endif
       
   124     #endif
       
   125 
       
   126     /********************************************************************************************************************/
       
   127     //Check if trace should be activated 
       
   128     #ifdef TRACE_ENTRY_EXIT_POINT // MACRO IN MMP FILE
       
   129         #define TRACE_ENTRY_POINT TRACE_FUNC_ENTRY_DEBUG_PRINT
       
   130         #define TRACE_EXIT_POINT  TRACE_FUNC_EXIT_DEBUG_PRINT
       
   131     #else
       
   132         #define TRACE_ENTRY_POINT
       
   133         #define TRACE_EXIT_POINT
       
   134     #endif
       
   135     
       
   136 #else  // _DEBUG
       
   137     #define TRACE_ENTRY_POINT
       
   138     #define TRACE_EXIT_POINT
       
   139 
       
   140 #endif // _DEBUG
       
   141 
       
   142 #endif // LOGS_TRACE_H