appinstall_plat/appmngr2runtimeapi/inc/appmngr2debugutils.h
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     1 /*
       
     2 * Copyright (c) 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 "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:   Defines trace macros
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef APPMNGR2DEBUGUTILS_H
       
    20 #define APPMNGR2DEBUGUTILS_H
       
    21 
       
    22 #include "appmngr2debugconfig.h"        // Configuration macros
       
    23 #ifdef PRINT_FLOG_TO_RDEBUG
       
    24 #include <e32debug.h>                   // RDebug
       
    25 #endif
       
    26 #ifdef PRINT_FLOG_TO_UTRACE
       
    27 #include <e32utrace.h>                  // TUTrace
       
    28 #endif
       
    29 #ifdef PRINT_FLOG_TO_FLOGGER
       
    30 #include <flogger.h>                    // RFileLogger
       
    31 #endif
       
    32 #ifdef FLOG_PERFORMANCE_TRACES
       
    33 #include <e32std.h>                     // TTime, TTimeIntervalMicroSeconds
       
    34 #endif
       
    35 
       
    36 inline void DebugPrint( TRefByValue<const TDesC> aFmt, ... );
       
    37 
       
    38 #ifdef FLOG_TRACES_ENABLED
       
    39 
       
    40 #ifdef FLOG_PERFORMANCE_TRACES
       
    41 
       
    42 // Static macros
       
    43 #define FLOG_PERF_STATIC_BEGIN(a)   TTime perf_begin_ ##a ; perf_begin_ ##a.UniversalTime();
       
    44 #define FLOG_PERF_STATIC_END(a)     TTime perf_end_ ##a; perf_end_ ##a.UniversalTime(); \
       
    45     TTimeIntervalMicroSeconds perf_diff_ ##a; \
       
    46     perf_diff_ ##a = perf_end_ ##a.MicroSecondsFrom( perf_begin_ ##a ); \
       
    47     _LIT( perf_name_ ##a, #a ); \
       
    48     DebugPrint( _L("PERF %S: %Ld ms" ), &perf_name_ ##a, perf_diff_ ##a.Int64() / TInt64( 1000 ) );
       
    49 
       
    50 // Dynamic macros
       
    51 #define FLOG_PERF_DEFINE(a)         TTime perf_begin_ ##a; TTime perf_end_ ##a; \
       
    52     TTimeIntervalMicroSeconds perf_diff_ ##a;
       
    53 #define FLOG_PERF_START(a)          perf_begin_ ##a.UniversalTime();
       
    54 #define FLOG_PERF_STOP(a)           perf_end_ ##a.UniversalTime();
       
    55 #define FLOG_PERF_PRINT(a)          _LIT( perf_name_ ##a, #a ); \
       
    56     perf_diff_ ##a = perf_end_ ##a.MicroSecondsFrom( perf_begin_ ##a ); \
       
    57     DebugPrint( _L("PERF %S: %Ld ms" ), &perf_name_ ##a, perf_diff_ ##a.Int64() / TInt64( 1000 ) );
       
    58 
       
    59 #else
       
    60 
       
    61 #define FLOG_PERF_STATIC_BEGIN(a)
       
    62 #define FLOG_PERF_STATIC_END(a)
       
    63 #define FLOG_PERF_DEFINE(a)
       
    64 #define FLOG_PERF_START(a)
       
    65 #define FLOG_PERF_STOP(a)
       
    66 #define FLOG_PERF_PRINT(a)
       
    67 
       
    68 #endif  // FLOG_PERFORMANCE_TRACES
       
    69 
       
    70 
       
    71 #if( defined( FLOG_DEBUG_TRACES ) )
       
    72 #define FLOG( a, ARGS... )           DebugPrint( _L( a ), ##ARGS );
       
    73 #else
       
    74 #define FLOG( a, ARGS... )
       
    75 #endif  // FLOG_DEBUG_TRACES
       
    76 
       
    77 
       
    78 #else
       
    79 #define FLOG_PERF_STATIC_BEGIN(a)
       
    80 #define FLOG_PERF_STATIC_END(a)
       
    81 #define FLOG_PERF_DEFINE(a)
       
    82 #define FLOG_PERF_START(a)
       
    83 #define FLOG_PERF_STOP(a)
       
    84 #define FLOG_PERF_PRINT(a)
       
    85 #define FLOG( a, ARGS... )
       
    86 #endif  // FLOG_TRACES_ENABLED
       
    87 
       
    88 
       
    89 const TInt KMaxPrintSize = 256;
       
    90 _LIT( KAppMngr2Tag, "AppMngr2: " );
       
    91 
       
    92 #if( defined( PRINT_FLOG_TO_UTRACE ) )
       
    93 
       
    94 inline void DebugPrint( TRefByValue<const TDesC> aFmt, ... )
       
    95     {
       
    96     VA_LIST list;
       
    97     VA_START( list, aFmt );
       
    98     TBuf<KMaxPrintSize> buf;
       
    99     buf.Copy( KAppMngr2Tag );
       
   100     buf.AppendFormatList( aFmt, list );
       
   101     TUTrace::PrintfPrimary( KDebug, EFalse, EFalse, buf );
       
   102     }
       
   103 
       
   104 #elif( defined( PRINT_FLOG_TO_RDEBUG ) ) 
       
   105 
       
   106 inline void DebugPrint( TRefByValue<const TDesC> aFmt, ... )
       
   107     {
       
   108     VA_LIST list;
       
   109     VA_START( list, aFmt );
       
   110     TBuf<KMaxPrintSize> buf;
       
   111     buf.Copy( KAppMngr2Tag );
       
   112     buf.AppendFormatList( aFmt, list );
       
   113     RDebug::Print( buf );
       
   114     }
       
   115 
       
   116 #elif( defined( PRINT_FLOG_TO_FLOGGER ) )
       
   117 
       
   118 _LIT( KLogDir, "AppMngr2" );
       
   119 _LIT( KLogFile, "AppMngr2.txt" );
       
   120 
       
   121 inline void DebugPrint( TRefByValue<const TDesC> aFmt, ... )
       
   122     {
       
   123     VA_LIST list;
       
   124     VA_START( list, aFmt );
       
   125     RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list );
       
   126     }
       
   127 
       
   128 #else
       
   129 
       
   130 // No implementation needed, DebugPrint() not used
       
   131 
       
   132 #endif
       
   133 
       
   134 #endif  // APPMNGR2DEBUGUTILS_H
       
   135