|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: Database for MediaServer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_CUPNPCONTENTDIRECTORYDB_DEBUG_H |
|
21 #define C_CUPNPCONTENTDIRECTORYDB_DEBUG_H |
|
22 |
|
23 // Note that _DEBUG is automatically defined for debug builds |
|
24 |
|
25 // To enable file logging: please comment following #ifdef line and |
|
26 // uncomment #ifdef TRUE |
|
27 #ifdef _DEBUG |
|
28 //#ifndef TRUE // to disable logging & debug in all builds |
|
29 //#ifdef TRUE // to enable logging & debug in all builds |
|
30 |
|
31 /****************************** LOGGING ON ***********************************/ |
|
32 // INCLUDES |
|
33 #include <flogger.h> |
|
34 |
|
35 // CONSTANTS |
|
36 //_LIT(___KLogDir___, "ContentDirectoryDb"); |
|
37 _LIT(___KLogDir___, "ContentDirectoryDb"); |
|
38 _LIT(___KLogFile___, "ContentDirectoryDb.log"); |
|
39 _LIT(___KLogOpeningLine___, "INFO####ContentDirectoryDb.log file opened."); |
|
40 _LIT(___KInfoFormatString___,"INFO#%S#%S#%d#%S"); |
|
41 _LIT(______KSqlComment______,"ERROR#%S#%S#%d#%S"); |
|
42 _LIT(KSqlComment,"SQL Command:"); |
|
43 |
|
44 // MACROS |
|
45 /** Replaces the log file |
|
46 */ |
|
47 #define __LOG_OPEN() RFileLogger::Write(___KLogDir___, ___KLogFile___, EFileLoggingModeOverwrite, ___KLogOpeningLine___) |
|
48 |
|
49 /** For internal use (long comments) - do not use in the code |
|
50 */ |
|
51 #define __LOG_STRING(string) RFileLogger::Write(___KLogDir___, ___KLogFile___, EFileLoggingModeAppend, string); |
|
52 |
|
53 /** For internal use (long comments) - do not use in the code |
|
54 */ |
|
55 #define __LOG_ALL(longstring) \ |
|
56 { \ |
|
57 TInt ___iLogZ___ = 0; \ |
|
58 TInt ___amountLogZ___ = 100; \ |
|
59 while(___iLogZ___<longstring.Length()) \ |
|
60 { \ |
|
61 if(( longstring.Length()-___iLogZ___) < 100) \ |
|
62 ___amountLogZ___ = longstring.Length()-___iLogZ___; \ |
|
63 __LOG_STRING(longstring.Mid(___iLogZ___,___amountLogZ___)); \ |
|
64 ___iLogZ___+=100; \ |
|
65 } \ |
|
66 } |
|
67 |
|
68 /** Logs error - this is intended to use in the code |
|
69 * @param in_function: quoted string - name of function in which the called_function gets called, max 30 chars |
|
70 * @param called_function: quoted string - just called function, ussually it returns error_code, max 30 chars |
|
71 * @param error_code: integer - error code returned by just called function |
|
72 * @param comment: quoted string - your comment, if longer than 50 chars will be expanded to the sequent line(s) |
|
73 */ |
|
74 #define __LOG(in_function,called_function,error_code,comment) \ |
|
75 {\ |
|
76 _LIT(___KInFunction___,in_function);\ |
|
77 _LIT(___KCalledFunction___,called_function);\ |
|
78 _LIT(___KComment___,comment);\ |
|
79 TInt ___comment_max_length___ = 50;\ |
|
80 if(error_code<0)\ |
|
81 {\ |
|
82 TPtrC ___comment_part___(___KComment___().Left(___comment_max_length___));\ |
|
83 RFileLogger::WriteFormat(___KLogDir___, ___KLogFile___, EFileLoggingModeAppend, ______KSqlComment______, &___KInFunction___, &___KCalledFunction___, error_code, &___comment_part___);\ |
|
84 }\ |
|
85 else\ |
|
86 {\ |
|
87 TPtrC ___comment_part___(___KComment___().Left(___comment_max_length___));\ |
|
88 RFileLogger::WriteFormat(___KLogDir___, ___KLogFile___, EFileLoggingModeAppend, ___KInfoFormatString___, &___KInFunction___, &___KCalledFunction___, error_code, &___comment_part___);\ |
|
89 }\ |
|
90 if(___KComment___().Length()>___comment_max_length___)\ |
|
91 {\ |
|
92 TPtrC ___continuation___((___KComment___().Mid(___comment_max_length___)));\ |
|
93 __LOG_ALL(___continuation___);\ |
|
94 }\ |
|
95 } |
|
96 |
|
97 #define __LOG_INFO(in_function,called_function,error_code,comment) \ |
|
98 {\ |
|
99 _LIT(___KInFunction___,in_function);\ |
|
100 _LIT(___KCalledFunction___,called_function);\ |
|
101 _LIT(___KComment___,comment);\ |
|
102 TInt ___comment_max_length___ = 50;\ |
|
103 TPtrC ___comment_part___((___KComment___().Left(___comment_max_length___)));\ |
|
104 RFileLogger::WriteFormat(___KLogDir___, ___KLogFile___, EFileLoggingModeAppend, ___KInfoFormatString___, &___KInFunction___, &___KCalledFunction___, error_code, &___comment_part___);\ |
|
105 if(___KComment___().Length()>___comment_max_length___)\ |
|
106 {\ |
|
107 TPtrC ___continuation___((___KComment___().Mid(___comment_max_length___)));\ |
|
108 __LOG_ALL(___continuation___);\ |
|
109 }\ |
|
110 } |
|
111 |
|
112 #define __LOG_ERROR(in_function,called_function,error_code,comment) \ |
|
113 {\ |
|
114 _LIT(___KInFunction___,in_function);\ |
|
115 _LIT(___KCalledFunction___,called_function);\ |
|
116 _LIT(___KComment___,comment);\ |
|
117 TInt ___comment_max_length___ = 50;\ |
|
118 TPtrC ___comment_part___(___KComment___().Left(___comment_max_length___));\ |
|
119 RFileLogger::WriteFormat(___KLogDir___, ___KLogFile___, EFileLoggingModeAppend, ______KSqlComment______, &___KInFunction___, &___KCalledFunction___, error_code, &___comment_part___);\ |
|
120 if(___KComment___().Length()>___comment_max_length___)\ |
|
121 {\ |
|
122 TPtrC ___continuation___((___KComment___().Mid(___comment_max_length___)));\ |
|
123 __LOG_ALL(___continuation___);\ |
|
124 }\ |
|
125 } |
|
126 |
|
127 // file versions |
|
128 |
|
129 #define __LOG_OPEN_FILE(file, string) RFileLogger::Write(___KLogDir___, file, EFileLoggingModeOverwrite, string) |
|
130 |
|
131 #define __LOG_TO_FILE(file,in_function,called_function,error_code,comment) \ |
|
132 {\ |
|
133 _LIT(___KInFunction___,in_function);\ |
|
134 _LIT(___KCalledFunction___,called_function);\ |
|
135 _LIT(___KComment___,comment);\ |
|
136 TInt ___comment_max_length___ = 50;\ |
|
137 if(error_code<0)\ |
|
138 {\ |
|
139 RFileLogger::WriteFormat(___KLogDir___, file, EFileLoggingModeAppend, ______KSqlComment______, &___KInFunction___, &___KCalledFunction___, error_code, &(___KComment___().Left(___comment_max_length___)));\ |
|
140 }\ |
|
141 else\ |
|
142 {\ |
|
143 RFileLogger::WriteFormat(___KLogDir___, file, EFileLoggingModeAppend, ___KInfoFormatString___, &___KInFunction___, &___KCalledFunction___, error_code, &(___KComment___().Left(___comment_max_length___)));\ |
|
144 }\ |
|
145 if(___KComment___().Length()>___comment_max_length___)\ |
|
146 {\ |
|
147 TPtrC ___continuation___((___KComment___().Mid(___comment_max_length___)));\ |
|
148 __LOG_ALL(___continuation___);\ |
|
149 }\ |
|
150 } |
|
151 |
|
152 #define __LOG_INFO_TO_FILE(file,in_function,called_function,error_code,comment) \ |
|
153 {\ |
|
154 _LIT(___KInFunction___,in_function);\ |
|
155 _LIT(___KCalledFunction___,called_function);\ |
|
156 _LIT(___KComment___,comment);\ |
|
157 TInt ___comment_max_length___ = 50;\ |
|
158 RFileLogger::WriteFormat(___KLogDir___, ___KLogFile___, EFileLoggingModeAppend, ___KInfoFormatString___, &___KInFunction___, &___KCalledFunction___, error_code, &(___KComment___().Left(___comment_max_length___)));\ |
|
159 if(___KComment___().Length()>__comment_max_length__)\ |
|
160 {\ |
|
161 TPtrC ___continuation___((___KComment___().Mid(___comment_max_length___)));\ |
|
162 __LOG_ALL(___continuation___);\ |
|
163 }\ |
|
164 } |
|
165 |
|
166 #define __LOG_ERROR_TO_FILE(file,in_function,called_function,error_code,comment) \ |
|
167 {\ |
|
168 _LIT(___KInFunction___,in_function);\ |
|
169 _LIT(___KCalledFunction___,called_function);\ |
|
170 _LIT(___KComment___,comment);\ |
|
171 TInt ___comment_max_length___ = 50;\ |
|
172 RFileLogger::WriteFormat(___KLogDir___, ___KLogFile___, EFileLoggingModeAppend, ______KSqlComment______, &___KInFunction___, &___KCalledFunction___, error_code, &(___KComment___().Left(___comment_max_length___)));\ |
|
173 if(___KComment___().Length()>___comment_max_length___)\ |
|
174 {\ |
|
175 TPtrC ___continuation___((___KComment___().Mid(___comment_max_length___)));\ |
|
176 __LOG_ALL(___continuation___);\ |
|
177 }\ |
|
178 } |
|
179 |
|
180 |
|
181 // module specific defines |
|
182 |
|
183 /** Logs sql Command |
|
184 */ |
|
185 #define __LOG_SQL_COMMAND(in_function,called_function,error_code,command) \ |
|
186 {\ |
|
187 _LIT(___KInFunction___,in_function);\ |
|
188 _LIT(___KCalledFunction___,called_function);\ |
|
189 if(error_code < 0 )\ |
|
190 {\ |
|
191 RFileLogger::WriteFormat(___KLogDir___, ___KLogFile___, EFileLoggingModeAppend, ______KSqlComment______, &___KInFunction___, &___KCalledFunction___, error_code, &KSqlComment);\ |
|
192 __LOG_ALL(command);\ |
|
193 }\ |
|
194 else\ |
|
195 {\ |
|
196 RFileLogger::WriteFormat(___KLogDir___, ___KLogFile___, EFileLoggingModeAppend, ___KInfoFormatString___, &___KInFunction___, &___KCalledFunction___, error_code, &KSqlComment);\ |
|
197 __LOG_ALL(command);\ |
|
198 }\ |
|
199 } |
|
200 |
|
201 |
|
202 #else |
|
203 /****************************** LOGGING OFF **********************************/ |
|
204 |
|
205 #define __LOG_OPEN() |
|
206 #define __LOG_STRING(string) |
|
207 #define __LOG_ALL(longstring) |
|
208 #define __LOG(in_function,called_function,error_code,comment) |
|
209 #define __LOG_INFO(in_function,called_function,error_code,comment) |
|
210 #define __LOG_ERROR(in_function,called_function,error_code,comment) |
|
211 #define __LOG_OPEN_FILE(file, string) |
|
212 #define __LOG_TO_FILE(file,in_function,called_function,error_code,comment) |
|
213 #define __LOG_INFO_TO_FILE(file,in_function,called_function,error_code,comment) |
|
214 #define __LOG_ERROR_TO_FILE(file,in_function,called_function,error_code,comment) |
|
215 |
|
216 // module specific defines defines |
|
217 /** Logs sql Command |
|
218 */ |
|
219 #define __LOG_SQL_COMMAND(in_function,called_function,error_code,command) |
|
220 |
|
221 #endif // _DEBUG |
|
222 |
|
223 #endif // C_CUPNPCONTENTDIRECTORYDB_DEBUG_H |
|
224 |
|
225 // End of File |