32
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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:
|
|
15 |
* Central place for nice debug-type macros & functions
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef SRCS_DEBUG_H
|
|
21 |
#define SRCS_DEBUG_H
|
|
22 |
|
|
23 |
#ifdef _DEBUG
|
|
24 |
|
|
25 |
// Enable this to enable memory tracing
|
|
26 |
// to SRCS
|
|
27 |
//#define MEMTRACE
|
|
28 |
|
|
29 |
// Following define is to enable OOM
|
|
30 |
// situations in SRCS
|
|
31 |
// NOTE! SHOULD NEVER BE IN RELEASES
|
|
32 |
//#define TEST_OOM
|
|
33 |
|
|
34 |
#ifdef __WINS__
|
|
35 |
|
|
36 |
// File logging for WIS
|
|
37 |
#define __FLOGGING__
|
|
38 |
|
|
39 |
#else
|
|
40 |
|
|
41 |
// Logging with RDebug for target HW
|
|
42 |
#define __CLOGGING__
|
|
43 |
//#define __FLOGGING__
|
|
44 |
|
|
45 |
|
|
46 |
#endif //__WINS__
|
|
47 |
|
|
48 |
#endif
|
|
49 |
|
|
50 |
#if defined ( __FLOGGING__ )
|
|
51 |
|
|
52 |
_LIT(KLogFile,"Srcslog.txt");
|
|
53 |
_LIT(KLogDir,"SRCS");
|
|
54 |
|
|
55 |
#include <f32file.h>
|
|
56 |
#include <flogger.h>
|
|
57 |
|
|
58 |
#define FLOG(a) {FPrint(a);}
|
|
59 |
|
|
60 |
#define FLOGHEX(value, len) {RFileLogger::HexDump(KLogDir, KLogFile, EFileLoggingModeAppend, "", " ",value, len);}
|
|
61 |
|
|
62 |
#define FTRACE(a) {a;}
|
|
63 |
// Declare the FPrint function
|
|
64 |
|
|
65 |
inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
|
|
66 |
{
|
|
67 |
VA_LIST list;
|
|
68 |
VA_START(list,aFmt);
|
|
69 |
RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
|
|
70 |
|
|
71 |
// If memory tracing is activated.
|
|
72 |
#ifdef MEMTRACE
|
|
73 |
TInt size;
|
|
74 |
User::Heap().AllocSize(size);
|
|
75 |
RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, _L("[SRCS]\tmemory\tMemory usage: %d high: %d"), size, User::Heap().Size());
|
|
76 |
#endif
|
|
77 |
}
|
|
78 |
|
|
79 |
inline void FHex(const TUint8* aPtr, TInt aLen)
|
|
80 |
{
|
|
81 |
RFileLogger::HexDump(KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen);
|
|
82 |
}
|
|
83 |
|
|
84 |
inline void FHex(const TDesC8& aDes)
|
|
85 |
{
|
|
86 |
FHex(aDes.Ptr(), aDes.Length());
|
|
87 |
}
|
|
88 |
|
|
89 |
// RDebug logging
|
|
90 |
#elif defined(__CLOGGING__)
|
|
91 |
|
|
92 |
#include <e32svr.h>
|
|
93 |
|
|
94 |
#define FLOG(a) {RDebug::Print(a);}
|
|
95 |
|
|
96 |
#define FLOGHEX(a)
|
|
97 |
|
|
98 |
#define FTRACE(a) {a;}
|
|
99 |
|
|
100 |
// Declare the FPrint function
|
|
101 |
|
|
102 |
inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
|
|
103 |
{
|
|
104 |
VA_LIST list;
|
|
105 |
VA_START(list,aFmt);
|
|
106 |
TInt tmpInt = VA_ARG(list, TInt);
|
|
107 |
TInt tmpInt2 = VA_ARG(list, TInt);
|
|
108 |
TInt tmpInt3 = VA_ARG(list, TInt);
|
|
109 |
VA_END(list);
|
|
110 |
RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3);
|
|
111 |
}
|
|
112 |
|
|
113 |
|
|
114 |
#else // No loggings --> reduced code size
|
|
115 |
#define FLOG(a)
|
|
116 |
#define FLOGHEX(a)
|
|
117 |
#define FTRACE(a)
|
|
118 |
|
|
119 |
#endif //_DEBUG
|
|
120 |
|
|
121 |
#endif // SRCS_DEBUG_H
|