usbengines/usbotgwatcher/inc/debug.h
changeset 0 1e05558e2206
child 6 a15c582fbf97
equal deleted inserted replaced
-1:000000000000 0:1e05558e2206
       
     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:  Central place for debug-type macros & functions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef _USBWATCHER_DEBUG_H
       
    20 #define _USBWATCHER_DEBUG_H
       
    21 
       
    22 #ifdef _DEBUG
       
    23 
       
    24 // Enable this to enable memory tracing
       
    25 //#define MEMTRACE
       
    26 
       
    27 // Following define is to enable OOM
       
    28 // situations in SRCS
       
    29 // SHOULD NEVER BE IN RELEASES.
       
    30 //#define TEST_OOM
       
    31 
       
    32 #ifdef __WINS__
       
    33 
       
    34 // File logging for WINS
       
    35 #define __FLOGGING__
       
    36 
       
    37 #else
       
    38 
       
    39 // Logging with RDebug for target HW
       
    40 #define __CLOGGING__
       
    41 
       
    42 #endif //__WINS__
       
    43 
       
    44 #endif // Debug
       
    45 
       
    46 #if defined ( __FLOGGING__ )
       
    47 
       
    48 _LIT( KLogFile,"UsbWatcher.txt" );
       
    49 _LIT( KLogDir,"usb" );
       
    50 
       
    51 #include <f32file.h>
       
    52 #include <flogger.h>
       
    53 
       
    54 #define FLOG( a ) { FPrint( a ); }
       
    55 
       
    56 #define FLOGHEX( value, len ) { RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, "", " ",value, len ); }
       
    57 
       
    58 #define FTRACE( a ) { a; }
       
    59 
       
    60 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
       
    61 {
       
    62     VA_LIST list;
       
    63     VA_START( list, aFmt );
       
    64     RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list );
       
    65 
       
    66     // If memory tracing is activated.
       
    67 #ifdef MEMTRACE
       
    68     TInt size;
       
    69     User::Heap().AllocSize( size );
       
    70     RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( "[USBWATCHER]\tmemory\tMemory usage: %d high: %d" ), size, User::Heap().Size() );
       
    71 #endif
       
    72 }
       
    73 
       
    74 inline void FHex( const TUint8* aPtr, TInt aLen )
       
    75 {
       
    76     RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen );
       
    77 }
       
    78 
       
    79 inline void FHex( const TDesC8& aDes )
       
    80 {
       
    81     FHex( aDes.Ptr(), aDes.Length() );
       
    82 }
       
    83 
       
    84 // RDebug logging
       
    85 #elif defined(__CLOGGING__)
       
    86 
       
    87 #include <e32svr.h>
       
    88 
       
    89 #define FLOG( a ) { RDebug::Print( a ); }
       
    90 
       
    91 #define FLOGHEX( a )
       
    92 
       
    93 #define FTRACE( a ) { a; }
       
    94 
       
    95 // Declare the FPrint function
       
    96 
       
    97 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
       
    98 {
       
    99     VA_LIST list;
       
   100     VA_START( list,aFmt );
       
   101     TInt tmpInt = VA_ARG( list, TInt );
       
   102     TInt tmpInt2 = VA_ARG( list, TInt );
       
   103     TInt tmpInt3 = VA_ARG( list, TInt );
       
   104     VA_END( list );
       
   105     RDebug::Print( aFmt, tmpInt, tmpInt2, tmpInt3 );
       
   106 }
       
   107 
       
   108 
       
   109 #else   // No loggings --> reduced code size
       
   110 
       
   111 #define FLOG( a )
       
   112 #define FLOGHEX( a )
       
   113 #define FTRACE( a )
       
   114 
       
   115 #endif //_DEBUG
       
   116 
       
   117 #endif // USBDEVCON_DEBUG_H
       
   118