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