|
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 DEBUG_H |
|
19 #define DEBUG_H |
|
20 |
|
21 #undef __FLOGGING__ |
|
22 #ifdef _DEBUG |
|
23 #define __FLOGGING__ |
|
24 #endif |
|
25 |
|
26 #ifdef __SECURITY_ON__ |
|
27 #undef __SECURITY_ON__ |
|
28 #endif |
|
29 //#define __SECURITY_ON__ |
|
30 |
|
31 #include <flogger.h> |
|
32 #include <e32std.h> |
|
33 |
|
34 |
|
35 extern TInt sdp_debug_level; |
|
36 |
|
37 |
|
38 #include <f32file.h> |
|
39 |
|
40 |
|
41 // Use level 0 for production, 1 for verification, >=2 for debug |
|
42 // 0 Errors |
|
43 // 1 Warnings |
|
44 // 2 Function calls |
|
45 // 3 Key values |
|
46 // 4 Full packet logging |
|
47 // 5 Insane |
|
48 |
|
49 #ifdef __FLOGGING__ |
|
50 |
|
51 _LIT(KLogFile,"sdplog.txt"); |
|
52 _LIT(KLogDirFullName,"c:\\logs\\bt\\"); |
|
53 _LIT(KLogDir,"BT"); |
|
54 const TInt KLogIndexOffset=5; |
|
55 |
|
56 #define SDP_DEBUG(n, arg) {if(sdp_debug_level >= (n)){arg ;}} |
|
57 |
|
58 #define FLOG(a) {FPrint(a);} |
|
59 #define FTRACE(a) {a;} |
|
60 |
|
61 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...) |
|
62 { |
|
63 VA_LIST list; |
|
64 VA_START(list,aFmt); |
|
65 // TBuf<32> logFile(KLogFile); |
|
66 // logFile[KLogIndexOffset]=TText('0'+(TInt)Dll::Tls()); |
|
67 // RFileLogger::WriteFormat(KLogDir, logFile, EFileLoggingModeAppend, aFmt, list); |
|
68 RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); |
|
69 } |
|
70 |
|
71 inline void FHex(const TUint8* aPtr, TInt aLen) |
|
72 { |
|
73 RFileLogger::HexDump(KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen); |
|
74 } |
|
75 |
|
76 inline void FHex(const TDesC8& aDes) |
|
77 { |
|
78 FHex(aDes.Ptr(), aDes.Length()); |
|
79 } |
|
80 |
|
81 #else // i.e. __FLOGGING__ undefined |
|
82 |
|
83 #ifdef _DEBUG // to quell linker warnings |
|
84 #define SDP_DEBUG(n, arg) {FDummy();} |
|
85 #define FLOG(a) {FDummy();} |
|
86 #define FTRACE(a) {FDummy();} |
|
87 inline void FDummy() |
|
88 { |
|
89 RFileLogger dummy; |
|
90 } |
|
91 #else |
|
92 #define SDP_DEBUG(n, arg) |
|
93 #define FLOG(a) |
|
94 #define FTRACE(a) |
|
95 #endif |
|
96 |
|
97 #endif // __FLOGGING__ |
|
98 |
|
99 |
|
100 #endif // DEBUG_H |