|
1 /* |
|
2 * Copyright (c) 2006-2009 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 the License "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: |
|
15 * This header contains definitions for logging commands. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 @internalComponent |
|
25 */ |
|
26 |
|
27 #ifndef __OCSP_LOG_H__ |
|
28 #define __OCSP_LOG_H__ |
|
29 |
|
30 #include <e32debug.h> |
|
31 |
|
32 namespace OCSP |
|
33 { |
|
34 |
|
35 #ifdef _DEBUG |
|
36 |
|
37 #define DEBUG_PRINTF(a) {OCSP::DebugPrintf(__LINE__, __FILE__, a);} |
|
38 #define DEBUG_PRINTF2(a, b) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b);} |
|
39 #define DEBUG_PRINTF3(a, b, c) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c);} |
|
40 #define DEBUG_PRINTF4(a, b, c, d) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c, d);} |
|
41 #define DEBUG_PRINTF5(a, b, c, d, e) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c, d, e);} |
|
42 |
|
43 #define DEBUG_CODE_SECTION(a) TRAP_IGNORE({ a; }) |
|
44 |
|
45 // UTF-8 overload of the DebufPrintf method. Should be used by default, |
|
46 // since it's cheaper both in CPU cycles and stack space. |
|
47 |
|
48 inline void DebugPrintf(TInt aLine, char* aFile, TRefByValue<const TDesC8> aFormat, ...) |
|
49 { |
|
50 VA_LIST list; |
|
51 VA_START(list, aFormat); |
|
52 |
|
53 TTime now; |
|
54 now.HomeTime(); |
|
55 |
|
56 TBuf8<1024> buffer; |
|
57 _LIT8(KSwiLogPrefix, "[OCSP] "); |
|
58 _LIT8(KSwiLineFileFormat, "%Ld Line: % 5d, File: %s -- "); |
|
59 buffer.Append(KSwiLogPrefix); |
|
60 buffer.AppendFormat(KSwiLineFileFormat, now.Int64(), aLine, aFile); |
|
61 buffer.AppendFormatList(aFormat, list); |
|
62 buffer.Append(_L8("\r\n")); |
|
63 |
|
64 RDebug::RawPrint(buffer); |
|
65 |
|
66 VA_END(list); |
|
67 } |
|
68 |
|
69 // Unicode DebufPrintf overload |
|
70 |
|
71 inline void DebugPrintf(TInt aLine, char* aFile, TRefByValue<const TDesC16> aFormat, ...) |
|
72 { |
|
73 VA_LIST list; |
|
74 VA_START(list, aFormat); |
|
75 |
|
76 TTime now; |
|
77 now.HomeTime(); |
|
78 |
|
79 TBuf8<256> header; |
|
80 _LIT8(KSwiLogPrefix, "[SWI] "); |
|
81 _LIT8(KSwiLineFileFormat, "%Ld Line: % 5d, File: %s -- "); |
|
82 header.Append(KSwiLogPrefix); |
|
83 header.AppendFormat(KSwiLineFileFormat, now.Int64(), aLine, aFile); |
|
84 |
|
85 TBuf<1024> buffer; |
|
86 buffer.Copy(header); |
|
87 buffer.AppendFormatList(aFormat, list); |
|
88 buffer.Append(_L("\r\n")); |
|
89 |
|
90 RDebug::RawPrint(buffer); |
|
91 |
|
92 VA_END(list); |
|
93 } |
|
94 |
|
95 #else |
|
96 |
|
97 #define DEBUG_PRINTF(a) |
|
98 #define DEBUG_PRINTF2(a, b) |
|
99 #define DEBUG_PRINTF3(a, b, c) |
|
100 #define DEBUG_PRINTF4(a, b, c, d) |
|
101 #define DEBUG_PRINTF5(a, b, c, d, e) |
|
102 |
|
103 #define DEBUG_CODE_SECTION(a) |
|
104 |
|
105 #endif |
|
106 |
|
107 |
|
108 } // namespace Swi |
|
109 |
|
110 #endif // __OCSP_LOG_H__ |