bthci/hciextensioninterface/tsrc/debug.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Central place for nice debug-type macros & functions
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef BT_DEBUG_H
       
    19 #define BT_DEBUG_H
       
    20 
       
    21 #define __FLOGGING__
       
    22 #undef __FLOGGING__
       
    23 
       
    24 #include <e32std.h>
       
    25 
       
    26 _LIT(KLogFile,"btlog0.txt");
       
    27 const TInt KLogIndexOffset=5;
       
    28 _LIT(KLogDirFullName,"c:\\logs\\bt\\");
       
    29 _LIT(KLogDir,"BT");
       
    30 
       
    31 #include <f32file.h>
       
    32 #include <flogger.h>
       
    33 
       
    34 #define FLOG(a) {FPrint(a);}
       
    35 #define FTRACE(a) {a;}
       
    36 
       
    37 
       
    38 #ifdef __FLOGGING__
       
    39 //#define MEMTRACE
       
    40 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
       
    41 	{
       
    42 	VA_LIST list;
       
    43 	VA_START(list,aFmt);
       
    44 	TBuf<32> logFile(KLogFile);
       
    45 	logFile[KLogIndexOffset]=TText('0'+(TInt)Dll::Tls());
       
    46 	RFileLogger::WriteFormat(KLogDir, logFile, EFileLoggingModeAppend, aFmt, list);
       
    47 #ifdef MEMTRACE
       
    48 	TInt size;
       
    49 	User::Heap().AllocSize(size);
       
    50 	
       
    51 	RFileLogger::WriteFormat(KLogDir, logFile, EFileLoggingModeAppend, _L("Mem usage: %d high: %d"), size, User::Heap().Size());
       
    52 #endif
       
    53 	}
       
    54 
       
    55 inline void FHex(const TUint8* aPtr, TInt aLen)
       
    56 	{
       
    57 	RFileLogger::HexDump(KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen);
       
    58 	}
       
    59 
       
    60 inline void FHex(const TDesC8& aDes)
       
    61 	{
       
    62 	FHex(aDes.Ptr(), aDes.Length());
       
    63 	}
       
    64 
       
    65 #else // i.e. __FLOGGING__ undefined
       
    66 
       
    67 inline void FPrint(const TRefByValue<const TDesC> /*aFmt*/,...) 
       
    68 	{
       
    69 	}
       
    70 
       
    71 inline void FHex(const TUint8* /*aPtr*/, TInt /*aLen*/)
       
    72 	{
       
    73 	}
       
    74 
       
    75 inline void FHex(const TDesC8& /*aDes*/)
       
    76 	{
       
    77 	}
       
    78 
       
    79 #endif //	__FLOGGING__
       
    80 
       
    81 
       
    82 #endif // __BT_DEBUG_H__