btaudioadaptation_stub/inc/btaudioadaptationdebug.h
changeset 0 0ce1b5ce9557
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     1 /*
       
     2 * Copyright (c) 2005 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 definitions for BT Audio Adaptation 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef BT_AUDIO_ADAPTATION_DEBUG_H 
       
    20 #define BT_AUDIO_ADAPTATION_DEBUG_H 
       
    21 
       
    22 #include <f32file.h>
       
    23 
       
    24 
       
    25 #ifdef _DEBUG
       
    26 
       
    27 // Print options
       
    28 
       
    29 #define KPRINTERROR		0x00000001 // Print error
       
    30 #define KPRINTFTRACE	0x00000002 // Print function trace
       
    31 #define KPRINTSTATE		0x00000004 // Print state machine infos
       
    32 
       
    33 const TInt KDebugMask = KPRINTERROR	| KPRINTFTRACE | KPRINTSTATE ; 
       
    34 
       
    35 
       
    36 // Un-comment/comment this definition to enable/disable memory tracing
       
    37 //#define MEMTRACE
       
    38 
       
    39 #ifdef __WINS__
       
    40 
       
    41 // File logging for WINS
       
    42 #define __FLOGGING__
       
    43 
       
    44 #else
       
    45 
       
    46 // Logging with RDebug for target HW
       
    47 #define __CLOGGING__
       
    48 
       
    49 #endif //__WINS__
       
    50 
       
    51 #endif // _DEBUG
       
    52 
       
    53 
       
    54 // ==================================================================
       
    55 // File logging
       
    56 // ==================================================================
       
    57 //
       
    58 #if  defined(__FLOGGING__)
       
    59 
       
    60 #include <e32std.h>
       
    61 
       
    62 _LIT(KLogFile,"BTAudioAdaptationLog.txt");
       
    63 _LIT(KLogDirFullName,"c:\\logs\\bt\\");
       
    64 _LIT(KLogDir,"BT");
       
    65 
       
    66 #include <f32file.h>
       
    67 #include <flogger.h>
       
    68 
       
    69 #define FLOG(a) { FPrint(a); }
       
    70   
       
    71 #define FTRACE(a) { a; }
       
    72 
       
    73 #define BT_AUDIO_ADAPTATION_TRACE_OPT(a,p) {if((KDebugMask)&(a))p;}
       
    74 
       
    75 
       
    76 
       
    77 
       
    78 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
       
    79     {
       
    80     VA_LIST list;
       
    81     VA_START(list,aFmt);
       
    82     RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
       
    83 #ifdef MEMTRACE
       
    84     TInt size;
       
    85     User::Heap().AllocSize(size);   
       
    86     RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, _L("[BTAudioAdaptation]\t MEM\tAllocated from heap: %d B. Total heap size: %d B"), size, User::Heap().Size());
       
    87 #endif
       
    88     }
       
    89 
       
    90 
       
    91 inline void FHex(const TUint8* aPtr, TInt aLen)
       
    92     {
       
    93     RFileLogger::HexDump(KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen);
       
    94     }
       
    95 
       
    96 
       
    97 inline void FHex(const TDesC8& aDes)
       
    98     {
       
    99     FHex(aDes.Ptr(), aDes.Length());
       
   100     }
       
   101 
       
   102 
       
   103 // ==================================================================
       
   104 // RDebug logging
       
   105 // ==================================================================
       
   106 //
       
   107 #elif defined(__CLOGGING__)
       
   108 
       
   109 #include <e32svr.h>
       
   110 
       
   111 #define FLOG(a) { RDebug::Print(a);  }
       
   112 
       
   113 #define FHex(a)
       
   114 
       
   115 #define FTRACE(a) { a; }
       
   116 
       
   117 #define BT_AUDIO_ADAPTATION_TRACE_OPT(a,p) {if((KDebugMask)&(a))p;}
       
   118 
       
   119 
       
   120 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
       
   121     {
       
   122     VA_LIST list;
       
   123     VA_START(list,aFmt);
       
   124     TInt tmpInt = VA_ARG(list, TInt);
       
   125     TInt tmpInt2 = VA_ARG(list, TInt);
       
   126     TInt tmpInt3 = VA_ARG(list, TInt);
       
   127     VA_END(list);
       
   128     RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3);
       
   129     }
       
   130 
       
   131 
       
   132 // ==================================================================
       
   133 // No loggings --> Reduced binary size
       
   134 // ==================================================================
       
   135 //
       
   136 #else // if no __FLOGGING__ and no __CLOGGING__
       
   137 
       
   138 #define FLOG(a)
       
   139 
       
   140 #define FTRACE(a)
       
   141 
       
   142 #define FHex(a)
       
   143 
       
   144 #define BT_AUDIO_ADAPTATION_TRACE_OPT(a,p)
       
   145 
       
   146 #endif // ...loggings 
       
   147 
       
   148 #endif // BTAUDIOADAPTATION_DEBUG_H
       
   149 
       
   150 // End of File