|
1 /* |
|
2 * Copyright (c) 2010 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: Easy dialing test application. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __EDTADEBUGPRINT_H__ |
|
20 #define __EDTADEBUGPRINT_H__ |
|
21 |
|
22 // If you want file logging, uncomment the next define. |
|
23 |
|
24 #ifdef _DEBUG |
|
25 // #define USE_FILE_LOGGING |
|
26 #endif // _DEBUG |
|
27 |
|
28 #ifdef USE_FILE_LOGGING |
|
29 #include <flogger.h> |
|
30 _LIT( KLogDir, "ed" ); |
|
31 _LIT( KLogFile, "edta.log" ); |
|
32 #endif |
|
33 |
|
34 |
|
35 // From this point on, internal implementation |
|
36 |
|
37 NONSHARABLE_CLASS(TOverflowTruncate) : public TDes16Overflow |
|
38 { |
|
39 public: |
|
40 void Overflow(TDes16& /*aDes*/) {} |
|
41 }; |
|
42 |
|
43 inline void DoDebugPrintF(TRefByValue<const TDesC> aFmt, VA_LIST& aList) |
|
44 { |
|
45 TBuf<200> buf; |
|
46 TOverflowTruncate overFlow; |
|
47 buf.AppendFormatList( aFmt, aList, &overFlow ); |
|
48 _LIT(KLogPrintFormat,"%S: %S"); // Log printing format |
|
49 const TDesC& thname = RThread().Name(); // FullName |
|
50 RDebug::Print( KLogPrintFormat, &thname, &buf ); |
|
51 #ifdef USE_FILE_LOGGING |
|
52 RFileLogger::Write(KLogDir, KLogFile, EFileLoggingModeAppend, buf); |
|
53 #endif |
|
54 } |
|
55 |
|
56 inline void DebugPrintF(const TRefByValue<const TDesC> aFmt,...) |
|
57 { |
|
58 VA_LIST list; |
|
59 VA_START(list,aFmt); |
|
60 DoDebugPrintF(aFmt, list); |
|
61 } |
|
62 |
|
63 |
|
64 #ifdef _DEBUG |
|
65 |
|
66 // These macros are to be used in debug prints |
|
67 #define DEBUGPRINT(x) DebugPrintF(x) |
|
68 #define DEBUGPRINT_2(x,y) DebugPrintF(x,y) |
|
69 #define DEBUGPRINT_3(x,y,z) DebugPrintF(x,y,z) |
|
70 #define DEBUGPRINT_4(x,y,z,a) DebugPrintF(x,y,z,a) |
|
71 |
|
72 #else // _DEBUG |
|
73 |
|
74 #define DEBUGPRINT(x) |
|
75 #define DEBUGPRINT_2(x,y) |
|
76 #define DEBUGPRINT_3(x,y,z) |
|
77 #define DEBUGPRINT_4(x,y,z,a) |
|
78 |
|
79 #endif // _DEBUG |
|
80 |
|
81 #endif // __EDTADEBUGPRINT_H__ |
|
82 |
|
83 // End of file |