|
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 "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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __TFLOGGER_H__ |
|
21 #define __TFLOGGER_H__ |
|
22 |
|
23 // CONSTANTS |
|
24 #ifndef _DEBUG |
|
25 |
|
26 // UREL BUILD: |
|
27 #define TF_LOGGING_METHOD 0 // No logging in UREL builds |
|
28 |
|
29 #else |
|
30 |
|
31 // UDEB BUILD: |
|
32 #define TF_LOGGING_METHOD 3 // 0 = No logging, |
|
33 // 1 = Flogger, |
|
34 // 2 = RDebug |
|
35 // 3 = CommsDebug |
|
36 #endif |
|
37 |
|
38 |
|
39 #if TF_LOGGING_METHOD > 0 |
|
40 #define TF_LOGGING_ENABLED // This is for backward compatibility |
|
41 #endif |
|
42 |
|
43 // FUNCTION PROTOTYPES |
|
44 #if TF_LOGGING_METHOD == 1 // Flogger |
|
45 |
|
46 #include <flogger.h> |
|
47 _LIT(KTfLogFolder,"TF"); |
|
48 _LIT(KTfLogFile,"TFLOG.TXT"); |
|
49 |
|
50 #elif TF_LOGGING_METHOD == 2 // RDebug |
|
51 |
|
52 #include <e32svr.h> |
|
53 |
|
54 #elif TF_LOGGING_METHOD == 3 // CommsDebug |
|
55 |
|
56 #include <comms-infras/commsdebugutility.h> |
|
57 |
|
58 #endif |
|
59 |
|
60 |
|
61 /* |
|
62 ----------------------------------------------------------------------------- |
|
63 |
|
64 LOGGING MACROs |
|
65 |
|
66 USE THESE MACROS IN YOUR CODE ! |
|
67 |
|
68 ----------------------------------------------------------------------------- |
|
69 */ |
|
70 |
|
71 #if TF_LOGGING_METHOD == 1 // Flogger |
|
72 |
|
73 #define TFLOGTEXT(AAA) RFileLogger::Write(KTfLogFolder(),KTfLogFile(),EFileLoggingModeAppend, AAA) |
|
74 #define TFLOGSTRING(AAA) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RFileLogger::Write(KTfLogFolder(),KTfLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) |
|
75 #define TFLOGSTRING2(AAA,BBB) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KTfLogFolder(),KTfLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); } while (0) |
|
76 #define TFLOGSTRING3(AAA,BBB,CCC) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KTfLogFolder(),KTfLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); } while (0) |
|
77 #define TFLOGSTRING4(AAA,BBB,CCC,DDD) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KTfLogFolder(),KTfLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); } while (0) |
|
78 |
|
79 |
|
80 #elif TF_LOGGING_METHOD == 2 // RDebug |
|
81 |
|
82 #define TFLOGTEXT(AAA) RDebug::Print(AAA) |
|
83 #define TFLOGSTRING(AAA) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0) |
|
84 #define TFLOGSTRING2(AAA,BBB) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0) |
|
85 #define TFLOGSTRING3(AAA,BBB,CCC) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0) |
|
86 #define TFLOGSTRING4(AAA,BBB,CCC,DDD) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0) |
|
87 |
|
88 |
|
89 #elif TF_LOGGING_METHOD == 3 // CommsDebug |
|
90 _LIT8(KTSYSubSystem, "tsy"); |
|
91 #ifdef TF_SAT_LOGGING |
|
92 _LIT8(KTSYCompnt, "sattsy"); |
|
93 #else |
|
94 _LIT8(KTSYCompnt, "ctsy"); |
|
95 #endif |
|
96 |
|
97 #define TFLOGTEXT(AAA) __FLOG_STATIC0(KTSYSubSystem,KTrpCompnt,(AAA)) |
|
98 #define TFLOGSTRING(AAA) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); __FLOG_STATIC0(KTSYSubSystem,KTSYCompnt, tempLogDes); } while (0) |
|
99 #define TFLOGSTRING2(AAA,BBB) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); __FLOG_STATIC1(KTSYSubSystem,KTSYCompnt, tempLogDes, BBB); } while (0) |
|
100 #define TFLOGSTRING3(AAA,BBB,CCC) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); __FLOG_STATIC2(KTSYSubSystem,KTSYCompnt, tempLogDes, BBB, CCC); } while (0) |
|
101 #define TFLOGSTRING4(AAA,BBB,CCC,DDD) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); __FLOG_STATIC3(KTSYSubSystem,KTSYCompnt, tempLogDes, BBB, CCC, DDD); } while (0) |
|
102 |
|
103 #else // TF_LOGGING_METHOD == 0 or invalid |
|
104 |
|
105 #define TFLOGTEXT(AAA) // Example: TFLOGTEXT(own_desc); |
|
106 #define TFLOGSTRING(AAA) // Example: TFLOGSTRING("Test"); |
|
107 #define TFLOGSTRING2(AAA,BBB) // Example: TFLOGSTRING("Test %i", aValue); |
|
108 #define TFLOGSTRING3(AAA,BBB,CCC) // Example: TFLOGSTRING("Test %i %i", aValue1, aValue2); |
|
109 #define TFLOGSTRING4(AAA,BBB,CCC,DDD) // Example: TFLOGSTRING("Test %i %i %i", aValue1, aValue2, aValue3); |
|
110 |
|
111 #endif // TF_LOGGING_METHOD |
|
112 |
|
113 #if TF_LOGGING_METHOD == 1 || TF_LOGGING_METHOD == 2 |
|
114 |
|
115 // Note, #x and __FILE__ must be stored to char string first, making them 16bit |
|
116 // strings with _LIT will not work in all compilers. |
|
117 |
|
118 #define TF_ASSERT(x) /*lint --e{717} */ do { if (!(x)) { const TUint8 tempX8[] = #x; \ |
|
119 TBuf<sizeof(tempX8)> tempX; \ |
|
120 tempX.Copy(TPtrC8(tempX8)); const TUint8 tempF8[] = __FILE__; TBuf<sizeof(tempF8)> tempF;\ |
|
121 tempF.Copy(TPtrC8(tempF8)); \ |
|
122 TFLOGSTRING4("TSY: ASSERT FAILED: %S, file %S, line %d", &tempX, &tempF, __LINE__ ); } } while(0) |
|
123 |
|
124 #define TF_ASSERT_NOT_REACHED() /*lint --e{717} */ do { const TUint8 tempF8[] = __FILE__;\ |
|
125 TBuf<sizeof(tempF8)> tempF; tempF.Copy(TPtrC8(tempF8));\ |
|
126 TFLOGSTRING3("TSY: ASSERT FAILED: unreachable code, file %S, line %d", &tempF, __LINE__ ); } while (0) |
|
127 |
|
128 #else // TF_LOGGING_METHOD == 0 or invalid |
|
129 |
|
130 #define TF_ASSERT(x) |
|
131 #define TF_ASSERT_NOT_REACHED() |
|
132 |
|
133 #endif // TF_LOGGING_METHOD == 1 || TF_LOGGING_METHOD == 2 |
|
134 |
|
135 |
|
136 #endif // __TFLOGGER_H__ |
|
137 |
|
138 // End of File |