usbclasses/usbbasicpersonality/inc/debug.h
changeset 35 9d8b04ca6939
parent 0 1e05558e2206
equal deleted inserted replaced
34:7858bc6ead78 35:9d8b04ca6939
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Debug macros
       
    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 //#define __FLOGGING__
       
    42 
       
    43 
       
    44 #endif //__WINS__
       
    45 
       
    46 #endif
       
    47 
       
    48 #if defined ( __FLOGGING__ )
       
    49 
       
    50 _LIT( KLogFile,"UsbWatcher.txt" );
       
    51 _LIT( KLogDir,"usb" );
       
    52 
       
    53 #include <f32file.h>
       
    54 #include <flogger.h>
       
    55 
       
    56 #define FLOG( a ) { FPrint( a ); }
       
    57 
       
    58 #define FLOGHEX( value, len ) { RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, "", " ",value, len ); }
       
    59 
       
    60 #define FTRACE( a ) { a; }
       
    61 // Declare the FPrint function
       
    62 
       
    63 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
       
    64 {
       
    65     VA_LIST list;
       
    66     VA_START( list, aFmt );
       
    67     RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list );
       
    68 
       
    69     // If memory tracing is activated.
       
    70 #ifdef MEMTRACE
       
    71     TInt size;
       
    72     User::Heap().AllocSize( size );
       
    73     RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( "[USBWATCHER]\tmemory\tMemory usage: %d high: %d" ), size, User::Heap().Size() );
       
    74 #endif
       
    75 }
       
    76 
       
    77 inline void FHex( const TUint8* aPtr, TInt aLen )
       
    78 {
       
    79     RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen );
       
    80 }
       
    81 
       
    82 inline void FHex( const TDesC8& aDes )
       
    83 {
       
    84     FHex( aDes.Ptr(), aDes.Length() );
       
    85 }
       
    86 
       
    87 // RDebug logging
       
    88 #elif defined(__CLOGGING__)
       
    89 
       
    90 #include <e32svr.h>
       
    91 
       
    92 #define FLOG( a ) { RDebug::Print( a ); }
       
    93 
       
    94 #define FLOGHEX( a )
       
    95 
       
    96 #define FTRACE( a ) { a; }
       
    97 
       
    98 // Declare the FPrint function
       
    99 
       
   100 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
       
   101 {
       
   102     VA_LIST list;
       
   103     VA_START( list,aFmt );
       
   104     TInt tmpInt = VA_ARG( list, TInt );
       
   105     TInt tmpInt2 = VA_ARG( list, TInt );
       
   106     TInt tmpInt3 = VA_ARG( list, TInt );
       
   107     VA_END( list );
       
   108     RDebug::Print( aFmt, tmpInt, tmpInt2, tmpInt3 );
       
   109 }
       
   110 
       
   111 
       
   112 #else   // No loggings --> reduced code size
       
   113 #define FLOG( a )
       
   114 #define FLOGHEX( a )
       
   115 #define FTRACE( a )
       
   116 
       
   117 #endif //_DEBUG
       
   118 
       
   119 #endif // USBWATCHER_DEBUG_H