1 /* |
|
2 * Copyright (c) 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 "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: Logging macros |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef LOG_DEF__ |
|
20 #define LOG_DEF__ |
|
21 |
|
22 #define LOG_HTI_FLOW |
|
23 |
|
24 #ifdef __ENABLE_LOGGING__ |
|
25 |
|
26 #ifndef __HTI_LOG_RDEBUG__ |
|
27 |
|
28 // LOGGING TO FILE |
|
29 |
|
30 #include <flogger.h> |
|
31 _LIT(KFreeMemFormat, "Total free: %d bytes"); |
|
32 _LIT(KFreeHeapMemFormat, "Heap available: %d bytes, biggest %d bytes"); |
|
33 _LIT(KAllocHeapMemFormat, "Heap alloc: %d bytes, %d cells"); |
|
34 _LIT(KLogFolder, "hti"); |
|
35 _LIT(KLogFile, "hti_log.txt"); |
|
36 |
|
37 #define HTI_LOG_TEXT(a1) {_LIT(temp, a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);} |
|
38 #define HTI_LOG_DES(a1) {RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, (a1));} |
|
39 #define HTI_LOG_FORMAT(a1,a2) {_LIT(temp, a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, (a2));} |
|
40 #define HTI_LOG_HEX(p,l) {RFileLogger::HexDump(KLogFolder, KLogFile, EFileLoggingModeAppend, NULL, NULL, p, l);} |
|
41 |
|
42 #define HTI_LOG_FREE_MEM() {TMemoryInfoV1Buf info;UserHal::MemoryInfo(info);RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, KFreeMemFormat, info().iFreeRamInBytes);} |
|
43 #define HTI_LOG_FREE_HEAP_MEM() {TInt b;TInt free=User::Available(b);RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, KFreeHeapMemFormat, free, b);} |
|
44 #define HTI_LOG_ALLOC_HEAP_MEM() {TInt b;TInt c = User::AllocSize(b);RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, KAllocHeapMemFormat, b, c);} |
|
45 |
|
46 // define separately macros to track function flow |
|
47 #ifdef LOG_HTI_FLOW |
|
48 _LIT8(KFuncIn, "-=> %S"); |
|
49 _LIT8(KFuncOut, "<=- %S"); |
|
50 |
|
51 #define HTI_LOG_FUNC_IN(a1) {_LIT8(temp, a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, KFuncIn, &temp);} |
|
52 #define HTI_LOG_FUNC_OUT(a1) {_LIT8(temp, a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, KFuncOut, &temp);} |
|
53 |
|
54 #else |
|
55 |
|
56 #define HTI_LOG_FUNC_IN(a1) |
|
57 #define HTI_LOG_FUNC_OUT(a1) |
|
58 |
|
59 #endif // LOG_HTI_FLOW |
|
60 |
|
61 #else |
|
62 |
|
63 // LOGGING TO RDEBUG |
|
64 |
|
65 #include <e32debug.h> |
|
66 _LIT(KFreeMemFormat, "[HTI] Total free: %d bytes"); |
|
67 _LIT(KFreeHeapMemFormat, "[HTI] Heap available: %d bytes, biggest %d bytes"); |
|
68 _LIT(KAllocHeapMemFormat, "[HTI] Heap alloc: %d bytes, %d cells"); |
|
69 _LIT(KDes, "[HTI] %S"); |
|
70 _LIT(KPrefix, "[HTI] "); |
|
71 #define HTI_LOG_TEXT(a1) {_LIT(temp, a1); RDebug::Print(KDes, &temp);} |
|
72 #define HTI_LOG_DES(a1) {TBuf<128> temp;temp.Copy(a1);RDebug::Print(KDes, &temp);} |
|
73 #define HTI_LOG_FORMAT(a1,a2) {_LIT(param1, a1);TBuf<128> temp;temp.Copy(KPrefix);temp.Append(param1);RDebug::Print(temp, (a2));} |
|
74 #define HTI_LOG_HEX(p,l) |
|
75 |
|
76 #define HTI_LOG_FREE_MEM() {TMemoryInfoV1Buf info;UserHal::MemoryInfo(info);RDebug::Print(KFreeMemFormat, info().iFreeRamInBytes);} |
|
77 #define HTI_LOG_FREE_HEAP_MEM() {TInt b;TInt free=User::Available(b);RDebug::Print(KFreeHeapMemFormat, free, b);} |
|
78 #define HTI_LOG_ALLOC_HEAP_MEM() {TInt b;TInt c = User::AllocSize(b);RDebug::Print(KAllocHeapMemFormat, b, c);} |
|
79 |
|
80 //define separately macros to track function flow |
|
81 #ifdef LOG_HTI_FLOW |
|
82 _LIT(KFuncIn, "[HTI] -=> %S"); |
|
83 _LIT(KFuncOut, "[HTI] <=- %S"); |
|
84 |
|
85 #define HTI_LOG_FUNC_IN(a1) {_LIT(temp, a1); RDebug::Print(KFuncIn, &temp);} |
|
86 #define HTI_LOG_FUNC_OUT(a1) {_LIT(temp, a1); RDebug::Print(KFuncOut, &temp);} |
|
87 |
|
88 #else |
|
89 |
|
90 #define HTI_LOG_FUNC_IN(a1) |
|
91 #define HTI_LOG_FUNC_OUT(a1) |
|
92 |
|
93 #endif // LOG_HTI_FLOW |
|
94 |
|
95 #endif // __HTI_LOG_RDEBUG__ |
|
96 |
|
97 #else |
|
98 |
|
99 // NO LOGGING |
|
100 |
|
101 #define HTI_LOG_TEXT(a1) |
|
102 #define HTI_LOG_DES(a1) |
|
103 #define HTI_LOG_FORMAT(a1,a2) |
|
104 #define HTI_LOG_HEX(p,l) |
|
105 |
|
106 #define HTI_LOG_FREE_MEM() |
|
107 #define HTI_LOG_FREE_HEAP_MEM() |
|
108 #define HTI_LOG_ALLOC_HEAP_MEM() |
|
109 |
|
110 #define HTI_LOG_FUNC_IN(a1) |
|
111 #define HTI_LOG_FUNC_OUT(a1) |
|
112 |
|
113 #endif // __ENABLE_LOGGING__ |
|
114 |
|
115 #endif // LOG_DEF__ |
|