sl@0
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Implements the Flogger client side
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@file
|
sl@0
|
20 |
@internalTechnology
|
sl@0
|
21 |
*/
|
sl@0
|
22 |
|
sl@0
|
23 |
#include <f32file.h>
|
sl@0
|
24 |
#include <comms-infras/commsdebugutility.h>
|
sl@0
|
25 |
#include "comsdbgstd.h"
|
sl@0
|
26 |
#include <e32def.h>
|
sl@0
|
27 |
|
sl@0
|
28 |
#include <utf.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
#define BLANK _S("")
|
sl@0
|
31 |
|
sl@0
|
32 |
const TInt KHexDumpWidth=16; ///< Number of bytes written per line when formatting as hex.
|
sl@0
|
33 |
const TInt KNumberMessageSlots=1; ///< Number of message slots on flogger client.no asynchronous IPC so never need more than 1 slot
|
sl@0
|
34 |
const TInt KLowestPrintableCharacter = 32; ///< In Hex output, replace chars below space with a dot.
|
sl@0
|
35 |
const TInt KHighestPrintableCharacter = 126; ///< In Hex output, replace chars above 7-bits with a dot.
|
sl@0
|
36 |
|
sl@0
|
37 |
_LIT(KFirstFormatString,"%s%04x : "); ///< Format string used in Hexdump to format first part: header and byte numbers.
|
sl@0
|
38 |
_LIT(KSecondFormatString,"%02x "); ///< Format string used in Hexdump to format mid part: each of the 16 bytes as hex
|
sl@0
|
39 |
_LIT(KThirdFormatString,"%c"); ///< Format string used in Hexdump to format the last part: each of the 16 bytes as characters
|
sl@0
|
40 |
_LIT(KThreeSpaces," "); ///< Format string used in Hexdump to define padding between first and mid parts
|
sl@0
|
41 |
_LIT(KTwoSpaces," "); ///< Format string used in Hexdump to define padding between hex and char bytes.
|
sl@0
|
42 |
|
sl@0
|
43 |
_LIT8(KFirstFormatString8,"%04x : "); ///< Format string used in Hexdump to format first part: header and byte numbers.
|
sl@0
|
44 |
_LIT8(KSecondFormatString8,"%02x "); ///< Format string used in Hexdump to format mid part: each of the 16 bytes as hex
|
sl@0
|
45 |
_LIT8(KThirdFormatString8,"%c"); ///< Format string used in Hexdump to format the last part: each of the 16 bytes as characters
|
sl@0
|
46 |
_LIT8(KThreeSpaces8," "); ///< Format string used in Hexdump to define padding between first and mid parts
|
sl@0
|
47 |
_LIT8(KTwoSpaces8," "); ///< Format string used in Hexdump to define padding between hex and char bytes.
|
sl@0
|
48 |
|
sl@0
|
49 |
|
sl@0
|
50 |
|
sl@0
|
51 |
//
|
sl@0
|
52 |
// RFileLogger class definition
|
sl@0
|
53 |
//
|
sl@0
|
54 |
|
sl@0
|
55 |
EXPORT_C RFileLogger::RFileLogger() : iLoggerBody(NULL)
|
sl@0
|
56 |
/**
|
sl@0
|
57 |
* Create a new flogger client interface object with an empty body.
|
sl@0
|
58 |
* @internalTechnology
|
sl@0
|
59 |
*/
|
sl@0
|
60 |
{}
|
sl@0
|
61 |
|
sl@0
|
62 |
EXPORT_C RFileLogger::~RFileLogger()
|
sl@0
|
63 |
/**
|
sl@0
|
64 |
* Destructor
|
sl@0
|
65 |
* @internalTechnology
|
sl@0
|
66 |
*/
|
sl@0
|
67 |
{}
|
sl@0
|
68 |
|
sl@0
|
69 |
EXPORT_C TVersion RFileLogger::Version() const
|
sl@0
|
70 |
/**
|
sl@0
|
71 |
* Return the client side version number
|
sl@0
|
72 |
* @internalTechnology
|
sl@0
|
73 |
* @return TVersion 3-part version number: major, minor, build.
|
sl@0
|
74 |
*/
|
sl@0
|
75 |
{
|
sl@0
|
76 |
|
sl@0
|
77 |
return(TVersion(KFLogSrvMajorVersionNumber,KFLogSrvMinorVersionNumber,KFLogSrvBuildVersionNumber));
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
EXPORT_C TInt RFileLogger::Connect()
|
sl@0
|
81 |
/**
|
sl@0
|
82 |
Connect to the flogger server - default number of message slots = 1
|
sl@0
|
83 |
@internalTechnology
|
sl@0
|
84 |
@return TInt indicating success code (KErrNone), KErrNoMemory if failed to allocate log body
|
sl@0
|
85 |
or an error from RSessionBase::CreateSession.
|
sl@0
|
86 |
KErrAlreadyExists if Connect has already been called.
|
sl@0
|
87 |
*/
|
sl@0
|
88 |
{
|
sl@0
|
89 |
if (iLoggerBody)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
return KErrAlreadyExists;
|
sl@0
|
92 |
}
|
sl@0
|
93 |
iLoggerBody = new RFileLoggerBody;
|
sl@0
|
94 |
if (iLoggerBody)
|
sl@0
|
95 |
{
|
sl@0
|
96 |
TInt ret=DoConnect();
|
sl@0
|
97 |
if (ret==KErrNotFound)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
ret=FLogger::Start();
|
sl@0
|
100 |
if (ret==KErrNone || ret==KErrAlreadyExists)
|
sl@0
|
101 |
ret=DoConnect();
|
sl@0
|
102 |
}
|
sl@0
|
103 |
if (ret != KErrNone)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
// we had a problem (perhaps no memory) so kill loggerbody again
|
sl@0
|
106 |
delete iLoggerBody;
|
sl@0
|
107 |
iLoggerBody = NULL;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
return ret;
|
sl@0
|
111 |
}
|
sl@0
|
112 |
else
|
sl@0
|
113 |
{
|
sl@0
|
114 |
//OOM, so return KErrNoMemory so that OOM tests know this
|
sl@0
|
115 |
return KErrNoMemory;
|
sl@0
|
116 |
}
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
EXPORT_C void RFileLogger::Close()
|
sl@0
|
120 |
/**
|
sl@0
|
121 |
* Close a client side session with the flogger server.
|
sl@0
|
122 |
* @internalTechnology
|
sl@0
|
123 |
* @post The client session is closed and the body of the class is deleted.
|
sl@0
|
124 |
* Further calls to the Write functions will fail silently until a new session is opened.
|
sl@0
|
125 |
*/
|
sl@0
|
126 |
{
|
sl@0
|
127 |
if (iLoggerBody)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
iLoggerBody->Close();
|
sl@0
|
130 |
delete iLoggerBody;
|
sl@0
|
131 |
}
|
sl@0
|
132 |
iLoggerBody = NULL;
|
sl@0
|
133 |
}
|
sl@0
|
134 |
|
sl@0
|
135 |
EXPORT_C void RFileLogger::SetDateAndTime(TBool /*aUseDate*/,TBool /*aUseTime*/)
|
sl@0
|
136 |
/**
|
sl@0
|
137 |
* Does nothing.
|
sl@0
|
138 |
* @internalTechnology
|
sl@0
|
139 |
* @removed This function no longer needed since now logging to one file and
|
sl@0
|
140 |
* date/time comes from system.
|
sl@0
|
141 |
*/
|
sl@0
|
142 |
{}
|
sl@0
|
143 |
|
sl@0
|
144 |
EXPORT_C TInt RFileLogger::SetLogTags(const TDesC8& aSubsystem, const TDesC8& aComponent)
|
sl@0
|
145 |
/**
|
sl@0
|
146 |
* Set the two tag strings that all further writes by this client will use to
|
sl@0
|
147 |
* idenitfy it in the log file.
|
sl@0
|
148 |
* @internalTechnology
|
sl@0
|
149 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
150 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
151 |
* @post The client session is updated so that all future calls use this tag set.
|
sl@0
|
152 |
* Tags are truncated to KMaxTagLength.
|
sl@0
|
153 |
* @return TInt indicating success code (KErrNone) or an error code.
|
sl@0
|
154 |
* @note If an error occurs, the client connection will be silently closed to protect
|
sl@0
|
155 |
* the client.
|
sl@0
|
156 |
*/
|
sl@0
|
157 |
{
|
sl@0
|
158 |
TPtrC8 validSubsystem;
|
sl@0
|
159 |
TPtrC8 validComponent;
|
sl@0
|
160 |
|
sl@0
|
161 |
validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
|
sl@0
|
162 |
validComponent.Set(aComponent.Left(KMaxTagLength));
|
sl@0
|
163 |
return DoSetLogTags(validSubsystem, validComponent);
|
sl@0
|
164 |
}
|
sl@0
|
165 |
|
sl@0
|
166 |
EXPORT_C void RFileLogger::CreateLog(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/)
|
sl@0
|
167 |
/**
|
sl@0
|
168 |
* Sets the log tags.
|
sl@0
|
169 |
* @internalTechnology
|
sl@0
|
170 |
* @removed Not fully supported since flogger only uses one log file. Use SetLogTags instead.
|
sl@0
|
171 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
172 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
173 |
* @param aMode not used
|
sl@0
|
174 |
* @note This function is partially supported and is equivalent to calling SetLogTags.
|
sl@0
|
175 |
* @see SetLogTags
|
sl@0
|
176 |
*/
|
sl@0
|
177 |
{
|
sl@0
|
178 |
|
sl@0
|
179 |
TNameTag narrowComponent;
|
sl@0
|
180 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
|
sl@0
|
181 |
TNameTag narrowSubsystem;
|
sl@0
|
182 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
|
sl@0
|
183 |
|
sl@0
|
184 |
(void)DoSetLogTags(narrowSubsystem,narrowComponent);
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
EXPORT_C void RFileLogger::CloseLog()
|
sl@0
|
188 |
/**
|
sl@0
|
189 |
* Close a client side session with the flogger server.
|
sl@0
|
190 |
* @internalTechnology
|
sl@0
|
191 |
* @deprecated With the advent of a single log file for all clients, closing the log file is no longer necessary. Use Close to close the session.
|
sl@0
|
192 |
* @see Close
|
sl@0
|
193 |
*/
|
sl@0
|
194 |
{
|
sl@0
|
195 |
Close();
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
EXPORT_C TBool RFileLogger::LogValid() const
|
sl@0
|
199 |
/**
|
sl@0
|
200 |
* Always returns ETrue.
|
sl@0
|
201 |
* @internalTechnology
|
sl@0
|
202 |
* @removed With the advent of a single log file for all clients, checking for log validity is no longer necessary.
|
sl@0
|
203 |
* @return ETrue always.
|
sl@0
|
204 |
*/
|
sl@0
|
205 |
{
|
sl@0
|
206 |
return ETrue;
|
sl@0
|
207 |
}
|
sl@0
|
208 |
|
sl@0
|
209 |
EXPORT_C TInt RFileLogger::LastError() const
|
sl@0
|
210 |
/**
|
sl@0
|
211 |
* Always returns KErrNone
|
sl@0
|
212 |
* @internalTechnology
|
sl@0
|
213 |
* @removed Flogger no longer retains internal errors.
|
sl@0
|
214 |
* @return KErrNone always.
|
sl@0
|
215 |
*/
|
sl@0
|
216 |
{
|
sl@0
|
217 |
return KErrNone;
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
EXPORT_C TInt RFileLogger::ClearLog()
|
sl@0
|
221 |
/**
|
sl@0
|
222 |
* Request that the server empty the log file.
|
sl@0
|
223 |
* @internalTechnology
|
sl@0
|
224 |
* @pre The client requesting the log be cleared must be listed in the flogger "ini" file
|
sl@0
|
225 |
* as an enabled logging client. This prevents unwanted clients clearing the log.
|
sl@0
|
226 |
* The session with the server must be active, otherwise this will fail silently.
|
sl@0
|
227 |
* @post A message is added to the server write queue that indicates to clear the log.
|
sl@0
|
228 |
* Once the message reaches the head of the queue flogger will empty the log file
|
sl@0
|
229 |
* and begin filling it again.
|
sl@0
|
230 |
* @return TInt indicating success code (KErrNone) or an error code.
|
sl@0
|
231 |
*/
|
sl@0
|
232 |
{
|
sl@0
|
233 |
if (IsLogging())
|
sl@0
|
234 |
{
|
sl@0
|
235 |
__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
|
sl@0
|
236 |
return iLoggerBody->DoSendReceive(EClearLog, TIpcArgs());
|
sl@0
|
237 |
}
|
sl@0
|
238 |
else
|
sl@0
|
239 |
{
|
sl@0
|
240 |
return KErrNone;
|
sl@0
|
241 |
}
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|
sl@0
|
244 |
//
|
sl@0
|
245 |
// 16-bit non-static writes
|
sl@0
|
246 |
//
|
sl@0
|
247 |
|
sl@0
|
248 |
EXPORT_C void RFileLogger::Write(const TDesC16& aText)
|
sl@0
|
249 |
/**
|
sl@0
|
250 |
* Write 16-bit aText to the log file.
|
sl@0
|
251 |
* @internalTechnology
|
sl@0
|
252 |
* @pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
253 |
* as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
254 |
* The session with the server must be active, otherwise this will fail silently.
|
sl@0
|
255 |
* @param aText Text to write
|
sl@0
|
256 |
* @post The 16-bit text is converted to 8-bit text before writing, and is truncated to KLogBufferSize
|
sl@0
|
257 |
* if necessary.
|
sl@0
|
258 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
259 |
@note There is no need to supply CR, LF. If these are supplied it may cause the log output to be incorrect.
|
sl@0
|
260 |
*/
|
sl@0
|
261 |
{
|
sl@0
|
262 |
if (!IsLogging())
|
sl@0
|
263 |
{
|
sl@0
|
264 |
return;
|
sl@0
|
265 |
}
|
sl@0
|
266 |
|
sl@0
|
267 |
TPtrC16 textValid;
|
sl@0
|
268 |
textValid.Set(aText.Left(KLogBufferSize));
|
sl@0
|
269 |
TBuf8<KLogBufferSize> buf;
|
sl@0
|
270 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(buf,textValid);
|
sl@0
|
271 |
DoWrite(buf);
|
sl@0
|
272 |
}
|
sl@0
|
273 |
|
sl@0
|
274 |
EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC16> aFmt,...)
|
sl@0
|
275 |
/**
|
sl@0
|
276 |
* Write the formatted 16-bit string aFmt to the log file
|
sl@0
|
277 |
* @internalTechnology
|
sl@0
|
278 |
* @pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
279 |
* as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
280 |
* The session with the server must be active, otherwise this will fail silently.
|
sl@0
|
281 |
* @param aFmt c-style format descriptor, followed by any variables required by the format.
|
sl@0
|
282 |
* @post The 16-bit text is converted to 8-bit text before writing, and is truncated to KLogBufferSize
|
sl@0
|
283 |
* if necessary.
|
sl@0
|
284 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
285 |
*/
|
sl@0
|
286 |
{
|
sl@0
|
287 |
if (!IsLogging())
|
sl@0
|
288 |
{
|
sl@0
|
289 |
return;
|
sl@0
|
290 |
}
|
sl@0
|
291 |
//coverity[var_decl]
|
sl@0
|
292 |
VA_LIST list;
|
sl@0
|
293 |
VA_START(list,aFmt);
|
sl@0
|
294 |
//coverity[uninit_use_in_call]
|
sl@0
|
295 |
DoWriteFormat(aFmt,list);
|
sl@0
|
296 |
|
sl@0
|
297 |
}
|
sl@0
|
298 |
|
sl@0
|
299 |
EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
|
sl@0
|
300 |
/**
|
sl@0
|
301 |
* Write the formatted 16-bit string aFmt to the log file.
|
sl@0
|
302 |
* @internalTechnology
|
sl@0
|
303 |
* @pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
304 |
* as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
305 |
* The session with the server must be active, otherwise this will fail silently.
|
sl@0
|
306 |
* @param aFmt c-style format descriptor
|
sl@0
|
307 |
* @param aList any variables required by the format.
|
sl@0
|
308 |
* @post The 16-bit text is converted to 8-bit text before writing, and is truncated to KLogBufferSize
|
sl@0
|
309 |
* if necessary.
|
sl@0
|
310 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
311 |
*/
|
sl@0
|
312 |
{
|
sl@0
|
313 |
if (IsLogging())
|
sl@0
|
314 |
{
|
sl@0
|
315 |
DoWriteFormat(aFmt,aList);
|
sl@0
|
316 |
}
|
sl@0
|
317 |
}
|
sl@0
|
318 |
|
sl@0
|
319 |
//
|
sl@0
|
320 |
// 8-bit non-static writes
|
sl@0
|
321 |
//
|
sl@0
|
322 |
|
sl@0
|
323 |
EXPORT_C void RFileLogger::Write(const TDesC8& aText)
|
sl@0
|
324 |
/**
|
sl@0
|
325 |
* Write 8-bit aText to the log file.
|
sl@0
|
326 |
* @internalTechnology
|
sl@0
|
327 |
* @pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
328 |
* as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
329 |
* The session with the server must be active, otherwise this will fail silently.
|
sl@0
|
330 |
* @param aText Text to log.
|
sl@0
|
331 |
* @post The text is truncated to KLogBufferSize if necessary.
|
sl@0
|
332 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
333 |
*/
|
sl@0
|
334 |
{
|
sl@0
|
335 |
TPtrC8 textValid;
|
sl@0
|
336 |
textValid.Set(aText.Left(KLogBufferSize));
|
sl@0
|
337 |
if (IsLogging())
|
sl@0
|
338 |
{
|
sl@0
|
339 |
DoWrite(textValid);
|
sl@0
|
340 |
}
|
sl@0
|
341 |
}
|
sl@0
|
342 |
|
sl@0
|
343 |
EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC8> aFmt,...)
|
sl@0
|
344 |
/**
|
sl@0
|
345 |
* Write the formatted 8-bit string aFmt to the log file.
|
sl@0
|
346 |
* @internalTechnology
|
sl@0
|
347 |
* @pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
348 |
* as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
349 |
* The session with the server must be active, otherwise this will fail silently.
|
sl@0
|
350 |
* @param aFmt c-style format descriptor, followed by any variables required by the format.
|
sl@0
|
351 |
* @post The text is truncated to KLogBufferSize if necessary.
|
sl@0
|
352 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
353 |
*/
|
sl@0
|
354 |
{
|
sl@0
|
355 |
if (!IsLogging())
|
sl@0
|
356 |
{
|
sl@0
|
357 |
return;
|
sl@0
|
358 |
}
|
sl@0
|
359 |
//coverity[var_decl]
|
sl@0
|
360 |
VA_LIST list;
|
sl@0
|
361 |
VA_START(list,aFmt);
|
sl@0
|
362 |
//coverity[uninit_use_in_call]
|
sl@0
|
363 |
DoWriteFormat(aFmt,list);
|
sl@0
|
364 |
}
|
sl@0
|
365 |
|
sl@0
|
366 |
EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
|
sl@0
|
367 |
/**
|
sl@0
|
368 |
* Write the formatted 8-bit string aFmt to the log file if it is a valid file.
|
sl@0
|
369 |
* @internalTechnology
|
sl@0
|
370 |
* @pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
371 |
* as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
372 |
* The session with the server must be active, otherwise this will fail silently.
|
sl@0
|
373 |
* @param aFmt c-style format descriptor
|
sl@0
|
374 |
* @param aList any variables required by the format.
|
sl@0
|
375 |
* @post The text is truncated to KLogBufferSize if necessary.
|
sl@0
|
376 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
377 |
*/
|
sl@0
|
378 |
{
|
sl@0
|
379 |
if (IsLogging())
|
sl@0
|
380 |
{
|
sl@0
|
381 |
DoWriteFormat(aFmt,aList);
|
sl@0
|
382 |
}
|
sl@0
|
383 |
}
|
sl@0
|
384 |
|
sl@0
|
385 |
EXPORT_C void RFileLogger::WriteBinary(const TDesC8& aData)
|
sl@0
|
386 |
/**
|
sl@0
|
387 |
* Dump arbitrary data to the log file in a binary format.
|
sl@0
|
388 |
* @internalTechnology
|
sl@0
|
389 |
* @pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
390 |
* as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
391 |
* The session with the server must be active, otherwise this will fail silently.
|
sl@0
|
392 |
* @param aData Descriptor of the data to be dumped
|
sl@0
|
393 |
* @post The 8-bit binary dump is preceded in the log file by the two client tags
|
sl@0
|
394 |
*
|
sl@0
|
395 |
* @note Unlike all other write API's, no thread ID is written with this API.
|
sl@0
|
396 |
*/
|
sl@0
|
397 |
{
|
sl@0
|
398 |
if (IsLogging())
|
sl@0
|
399 |
{
|
sl@0
|
400 |
__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
|
sl@0
|
401 |
(void)iLoggerBody->DoSendReceive(EWriteBinary, TIpcArgs(&aData, aData.Length()));
|
sl@0
|
402 |
}
|
sl@0
|
403 |
}
|
sl@0
|
404 |
|
sl@0
|
405 |
|
sl@0
|
406 |
//
|
sl@0
|
407 |
// 16-bit static writes
|
sl@0
|
408 |
//
|
sl@0
|
409 |
|
sl@0
|
410 |
EXPORT_C void RFileLogger::Write(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC16& aText)
|
sl@0
|
411 |
/**
|
sl@0
|
412 |
* Static write. Write 16-bit aText to the log file if it is a valid file.
|
sl@0
|
413 |
* @internalTechnology
|
sl@0
|
414 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
415 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
416 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
417 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
418 |
* @param aMode not used
|
sl@0
|
419 |
* @param aText Text to write
|
sl@0
|
420 |
* @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
|
sl@0
|
421 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
422 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
423 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
424 |
*/
|
sl@0
|
425 |
{
|
sl@0
|
426 |
// truncate tags
|
sl@0
|
427 |
TPtrC8 validSubsystem;
|
sl@0
|
428 |
TPtrC8 validComponent;
|
sl@0
|
429 |
|
sl@0
|
430 |
validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
|
sl@0
|
431 |
validComponent.Set(aComponent.Left(KMaxTagLength));
|
sl@0
|
432 |
|
sl@0
|
433 |
TBuf8<KLogBufferSize> buf;
|
sl@0
|
434 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(buf,aText);
|
sl@0
|
435 |
|
sl@0
|
436 |
DoStaticWrite(validSubsystem, validComponent, buf);
|
sl@0
|
437 |
}
|
sl@0
|
438 |
|
sl@0
|
439 |
EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC16> aFmt,...)
|
sl@0
|
440 |
/**
|
sl@0
|
441 |
* Static write. Write the formatted 16-bit string aFmt to the log file.
|
sl@0
|
442 |
* @internalTechnology
|
sl@0
|
443 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
444 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
445 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
446 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
447 |
* @param aFmt c-style format descriptor, followed by any variables required by the format.
|
sl@0
|
448 |
* @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
|
sl@0
|
449 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
450 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
451 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
452 |
*/
|
sl@0
|
453 |
{
|
sl@0
|
454 |
//coverity[var_decl]
|
sl@0
|
455 |
VA_LIST list;
|
sl@0
|
456 |
VA_START(list,aFmt);
|
sl@0
|
457 |
|
sl@0
|
458 |
// truncate tags
|
sl@0
|
459 |
TPtrC8 validSubsystem;
|
sl@0
|
460 |
TPtrC8 validComponent;
|
sl@0
|
461 |
|
sl@0
|
462 |
validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
|
sl@0
|
463 |
validComponent.Set(aComponent.Left(KMaxTagLength));
|
sl@0
|
464 |
//coverity[uninit_use_in_call]
|
sl@0
|
465 |
DoStaticWriteFormat(validSubsystem,validComponent,aFmt,list);
|
sl@0
|
466 |
}
|
sl@0
|
467 |
|
sl@0
|
468 |
EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
|
sl@0
|
469 |
/**
|
sl@0
|
470 |
* Static write. Write the formatted 16-bit string aFmt to the log file.
|
sl@0
|
471 |
* @internalTechnology
|
sl@0
|
472 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
473 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
474 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
475 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
476 |
* @param aFmt c-style format descriptor
|
sl@0
|
477 |
* @param aList any variables required by the format.
|
sl@0
|
478 |
* @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
|
sl@0
|
479 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
480 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
481 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
482 |
*/
|
sl@0
|
483 |
{
|
sl@0
|
484 |
// truncate tags
|
sl@0
|
485 |
TPtrC8 validSubsystem;
|
sl@0
|
486 |
TPtrC8 validComponent;
|
sl@0
|
487 |
|
sl@0
|
488 |
validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
|
sl@0
|
489 |
validComponent.Set(aComponent.Left(KMaxTagLength));
|
sl@0
|
490 |
|
sl@0
|
491 |
DoStaticWriteFormat(validSubsystem,validComponent,aFmt,aList);
|
sl@0
|
492 |
}
|
sl@0
|
493 |
|
sl@0
|
494 |
//
|
sl@0
|
495 |
// 8-bit static writes
|
sl@0
|
496 |
//
|
sl@0
|
497 |
|
sl@0
|
498 |
EXPORT_C void RFileLogger::Write(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aText)
|
sl@0
|
499 |
/**
|
sl@0
|
500 |
* Static write. Write 8-bit aText to the log file.
|
sl@0
|
501 |
* @internalTechnology
|
sl@0
|
502 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
503 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
504 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
505 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
506 |
* @param aText Text to log.
|
sl@0
|
507 |
* @post The text is truncated to KLogBufferSize if necessary.
|
sl@0
|
508 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
509 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
510 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
511 |
*/
|
sl@0
|
512 |
{
|
sl@0
|
513 |
// truncate tags
|
sl@0
|
514 |
TPtrC8 validSubsystem;
|
sl@0
|
515 |
TPtrC8 validComponent;
|
sl@0
|
516 |
|
sl@0
|
517 |
validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
|
sl@0
|
518 |
validComponent.Set(aComponent.Left(KMaxTagLength));
|
sl@0
|
519 |
DoStaticWrite(validSubsystem,validComponent, aText);
|
sl@0
|
520 |
}
|
sl@0
|
521 |
|
sl@0
|
522 |
EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC8> aFmt,...)
|
sl@0
|
523 |
/**
|
sl@0
|
524 |
* Static write. Write the formatted 8-bit string aFmt to the log file.
|
sl@0
|
525 |
* @internalTechnology
|
sl@0
|
526 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
527 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
528 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
529 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
530 |
* @param aFmt c-style format descriptor, followed by any variables required by the format.
|
sl@0
|
531 |
* @post The text is truncated to KLogBufferSize if necessary.
|
sl@0
|
532 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
533 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
534 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
535 |
*/
|
sl@0
|
536 |
|
sl@0
|
537 |
{
|
sl@0
|
538 |
//coverity[var_decl]
|
sl@0
|
539 |
VA_LIST list;
|
sl@0
|
540 |
VA_START(list,aFmt);
|
sl@0
|
541 |
|
sl@0
|
542 |
// truncate tags
|
sl@0
|
543 |
TPtrC8 validSubsystem;
|
sl@0
|
544 |
TPtrC8 validComponent;
|
sl@0
|
545 |
|
sl@0
|
546 |
validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
|
sl@0
|
547 |
validComponent.Set(aComponent.Left(KMaxTagLength));
|
sl@0
|
548 |
//coverity[uninit_use_in_call]
|
sl@0
|
549 |
DoStaticWriteFormat(validSubsystem,validComponent,aFmt,list);
|
sl@0
|
550 |
}
|
sl@0
|
551 |
|
sl@0
|
552 |
EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
|
sl@0
|
553 |
/**
|
sl@0
|
554 |
* Static write. Write the formatted 16-bit string aFmt to the log file.
|
sl@0
|
555 |
* @internalTechnology
|
sl@0
|
556 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
557 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
558 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
559 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
560 |
* @param aFmt c-style format descriptor
|
sl@0
|
561 |
* @param aList any variables required by the format.
|
sl@0
|
562 |
* @post The text is truncated to KLogBufferSize if necessary.
|
sl@0
|
563 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
564 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
565 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
566 |
*/
|
sl@0
|
567 |
{
|
sl@0
|
568 |
//truncate tags
|
sl@0
|
569 |
TPtrC8 validSubsystem;
|
sl@0
|
570 |
TPtrC8 validComponent;
|
sl@0
|
571 |
|
sl@0
|
572 |
validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
|
sl@0
|
573 |
validComponent.Set(aComponent.Left(KMaxTagLength));
|
sl@0
|
574 |
|
sl@0
|
575 |
DoStaticWriteFormat(validSubsystem,validComponent,aFmt,aList);
|
sl@0
|
576 |
}
|
sl@0
|
577 |
|
sl@0
|
578 |
|
sl@0
|
579 |
|
sl@0
|
580 |
|
sl@0
|
581 |
|
sl@0
|
582 |
|
sl@0
|
583 |
//
|
sl@0
|
584 |
// Removed 16-bit static writes
|
sl@0
|
585 |
//
|
sl@0
|
586 |
|
sl@0
|
587 |
EXPORT_C void RFileLogger::Write(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, const TDesC16& aText)
|
sl@0
|
588 |
/**
|
sl@0
|
589 |
* Static write. Write 16-bit aText to the log file if it is a valid file.
|
sl@0
|
590 |
* @internalTechnology
|
sl@0
|
591 |
* @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
|
sl@0
|
592 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
593 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
594 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
595 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
596 |
* @param aMode not used
|
sl@0
|
597 |
* @param aText Text to write
|
sl@0
|
598 |
* @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
|
sl@0
|
599 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
600 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
601 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
602 |
*/
|
sl@0
|
603 |
{
|
sl@0
|
604 |
// the convert also truncates if necessary
|
sl@0
|
605 |
TNameTag narrowComponent;
|
sl@0
|
606 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
|
sl@0
|
607 |
TNameTag narrowSubsystem;
|
sl@0
|
608 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
|
sl@0
|
609 |
|
sl@0
|
610 |
Write(narrowSubsystem, narrowComponent, aText);
|
sl@0
|
611 |
}
|
sl@0
|
612 |
|
sl@0
|
613 |
EXPORT_C void RFileLogger::WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode aMode, TRefByValue<const TDesC16> aFmt,...)
|
sl@0
|
614 |
/**
|
sl@0
|
615 |
* Static write. Write the formatted 16-bit string aFmt to the log file.
|
sl@0
|
616 |
* @internalTechnology
|
sl@0
|
617 |
* @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
|
sl@0
|
618 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
619 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
620 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
621 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
622 |
* @param aMode not used
|
sl@0
|
623 |
* @param aFmt c-style format descriptor, followed by any variables required by the format.
|
sl@0
|
624 |
* @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
|
sl@0
|
625 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
626 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
627 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
628 |
*/
|
sl@0
|
629 |
{
|
sl@0
|
630 |
// Just to remove the warning otherwise this does nothing
|
sl@0
|
631 |
if (aMode == EFileLoggingModeUnknown) { }
|
sl@0
|
632 |
//coverity[var_decl]
|
sl@0
|
633 |
VA_LIST list;
|
sl@0
|
634 |
VA_START(list,aFmt);
|
sl@0
|
635 |
|
sl@0
|
636 |
// the convert also truncates if necessary
|
sl@0
|
637 |
TNameTag narrowComponent;
|
sl@0
|
638 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
|
sl@0
|
639 |
TNameTag narrowSubsystem;
|
sl@0
|
640 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
|
sl@0
|
641 |
//coverity[uninit_use_in_call]
|
sl@0
|
642 |
DoStaticWriteFormat(narrowSubsystem, narrowComponent,aFmt,list);
|
sl@0
|
643 |
}
|
sl@0
|
644 |
|
sl@0
|
645 |
EXPORT_C void RFileLogger::WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
|
sl@0
|
646 |
/**
|
sl@0
|
647 |
* Static write. Write the formatted 16-bit string aFmt to the log file.
|
sl@0
|
648 |
* @internalTechnology
|
sl@0
|
649 |
* @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
|
sl@0
|
650 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
651 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
652 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
653 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
654 |
* @param aMode not used
|
sl@0
|
655 |
* @param aFmt c-style format descriptor
|
sl@0
|
656 |
* @param aList any variables required by the format.
|
sl@0
|
657 |
* @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
|
sl@0
|
658 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
659 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
660 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
661 |
*/
|
sl@0
|
662 |
{
|
sl@0
|
663 |
// the convert also truncates if necessary
|
sl@0
|
664 |
TNameTag narrowComponent;
|
sl@0
|
665 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
|
sl@0
|
666 |
TNameTag narrowSubsystem;
|
sl@0
|
667 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
|
sl@0
|
668 |
|
sl@0
|
669 |
DoStaticWriteFormat(narrowSubsystem, narrowComponent,aFmt,aList);
|
sl@0
|
670 |
}
|
sl@0
|
671 |
|
sl@0
|
672 |
//
|
sl@0
|
673 |
// Removed 8-bit static writes
|
sl@0
|
674 |
//
|
sl@0
|
675 |
|
sl@0
|
676 |
EXPORT_C void RFileLogger::Write(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, const TDesC8& aText)
|
sl@0
|
677 |
/**
|
sl@0
|
678 |
* Static write. Write 8-bit aText to the log file.
|
sl@0
|
679 |
* @internalTechnology
|
sl@0
|
680 |
* @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
|
sl@0
|
681 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
682 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
683 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
684 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
685 |
* @param aMode not used
|
sl@0
|
686 |
* @param aText Text to log.
|
sl@0
|
687 |
* @post The text is truncated to KLogBufferSize if necessary.
|
sl@0
|
688 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
689 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
690 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
691 |
*/
|
sl@0
|
692 |
{
|
sl@0
|
693 |
// the convert also truncates if necessary
|
sl@0
|
694 |
TNameTag narrowComponent;
|
sl@0
|
695 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
|
sl@0
|
696 |
TNameTag narrowSubsystem;
|
sl@0
|
697 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
|
sl@0
|
698 |
|
sl@0
|
699 |
Write(narrowSubsystem, narrowComponent, aText);
|
sl@0
|
700 |
}
|
sl@0
|
701 |
|
sl@0
|
702 |
EXPORT_C void RFileLogger::WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode aMode, TRefByValue<const TDesC8> aFmt,...)
|
sl@0
|
703 |
/**
|
sl@0
|
704 |
* Static write. Write the formatted 8-bit string aFmt to the log file.
|
sl@0
|
705 |
* @internalTechnology
|
sl@0
|
706 |
* @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
|
sl@0
|
707 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
708 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
709 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
710 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
711 |
* @param aMode not used
|
sl@0
|
712 |
* @param aFmt c-style format descriptor, followed by any variables required by the format.
|
sl@0
|
713 |
* @post The text is truncated to KLogBufferSize if necessary.
|
sl@0
|
714 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
715 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
716 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
717 |
*/
|
sl@0
|
718 |
|
sl@0
|
719 |
{
|
sl@0
|
720 |
// Just to remove the warning otherwise this does nothing
|
sl@0
|
721 |
if (aMode == EFileLoggingModeUnknown) { }
|
sl@0
|
722 |
//coverity[var_decl]
|
sl@0
|
723 |
VA_LIST list;
|
sl@0
|
724 |
VA_START(list,aFmt);
|
sl@0
|
725 |
|
sl@0
|
726 |
// the convert also truncates if necessary
|
sl@0
|
727 |
TNameTag narrowComponent;
|
sl@0
|
728 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
|
sl@0
|
729 |
TNameTag narrowSubsystem;
|
sl@0
|
730 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
|
sl@0
|
731 |
//coverity[uninit_use_in_call]
|
sl@0
|
732 |
DoStaticWriteFormat(narrowSubsystem, narrowComponent, aFmt, list);
|
sl@0
|
733 |
}
|
sl@0
|
734 |
|
sl@0
|
735 |
EXPORT_C void RFileLogger::WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
|
sl@0
|
736 |
/**
|
sl@0
|
737 |
* Static write. Write the formatted 16-bit string aFmt to the log file.
|
sl@0
|
738 |
* @internalTechnology
|
sl@0
|
739 |
* @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
|
sl@0
|
740 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
741 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
742 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
743 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
744 |
* @param aMode not used
|
sl@0
|
745 |
* @param aFmt c-style format descriptor
|
sl@0
|
746 |
* @param aList any variables required by the format.
|
sl@0
|
747 |
* @post The text is truncated to KLogBufferSize if necessary.
|
sl@0
|
748 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
749 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
750 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
751 |
*/
|
sl@0
|
752 |
{
|
sl@0
|
753 |
// the convert also truncates if necessary
|
sl@0
|
754 |
TNameTag narrowComponent;
|
sl@0
|
755 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
|
sl@0
|
756 |
TNameTag narrowSubsystem;
|
sl@0
|
757 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
|
sl@0
|
758 |
|
sl@0
|
759 |
DoStaticWriteFormat(narrowSubsystem, narrowComponent,aFmt,aList);
|
sl@0
|
760 |
}
|
sl@0
|
761 |
|
sl@0
|
762 |
//
|
sl@0
|
763 |
// Hex Dumps
|
sl@0
|
764 |
//
|
sl@0
|
765 |
|
sl@0
|
766 |
EXPORT_C void RFileLogger::HexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen)
|
sl@0
|
767 |
/**
|
sl@0
|
768 |
* Dump arbitrary data to the log file as a standard hex dump.
|
sl@0
|
769 |
* @internalTechnology
|
sl@0
|
770 |
* @pre The session with the server must be active, otherwise this no action is taken.
|
sl@0
|
771 |
The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
772 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
773 |
* @param aHeader Specify a zero-terminated string to be printed before the first hex line. Leave as null or an empty string for no header.
|
sl@0
|
774 |
* @param aMargin Specify a zero-terminated string to be printed before each subsequent line. Leave as null or an empty string for no Margin.
|
sl@0
|
775 |
* @param aPtr pointer to the data being dumped.
|
sl@0
|
776 |
* @param aLen the number of bytes to dump
|
sl@0
|
777 |
* @post Each line is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
778 |
* @note Example of aHeader/aMargin. If "aHeader" is set to "Fn Output:" and "aMargin" is set to " ", then output would look
|
sl@0
|
779 |
* like (for a print of the alphabet):
|
sl@0
|
780 |
* TLOG Example 20 FnOutput:0000 : 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 abcdefghijklmnop
|
sl@0
|
781 |
* TLOG Example 20 0010 : 71 72 73 74 75 76 77 78 79 7a qrstuvwxyz
|
sl@0
|
782 |
*
|
sl@0
|
783 |
*/
|
sl@0
|
784 |
{
|
sl@0
|
785 |
if (IsLogging())
|
sl@0
|
786 |
{
|
sl@0
|
787 |
DoHexDump(aHeader,aMargin,aPtr,aLen);
|
sl@0
|
788 |
}
|
sl@0
|
789 |
|
sl@0
|
790 |
|
sl@0
|
791 |
}
|
sl@0
|
792 |
|
sl@0
|
793 |
|
sl@0
|
794 |
|
sl@0
|
795 |
EXPORT_C void RFileLogger::HexDump(const TDesC8& aData, const TDesC8& aHeader)
|
sl@0
|
796 |
/**
|
sl@0
|
797 |
* Dump arbitrary data to the log file as a standard hex dump.
|
sl@0
|
798 |
* @internalTechnology
|
sl@0
|
799 |
* @pre The session with the server must be active, otherwise this no action is taken.
|
sl@0
|
800 |
The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
801 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
802 |
* @param aData the data being dumped.
|
sl@0
|
803 |
* @param aHeader Specify a string to be printed before the first hex line. If not supplied, no header or margin is written.
|
sl@0
|
804 |
* If supplied, then subsequent lines are indented to the length of aHeader.
|
sl@0
|
805 |
* @post Each line is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
806 |
* @note Example of aHeader. If "aHeader" is set to "Fn Output:" then output would look
|
sl@0
|
807 |
* like (for a print of the alphabet):
|
sl@0
|
808 |
* TLOG Example 20 FnOutput:0000 : 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 abcdefghijklmnop
|
sl@0
|
809 |
* TLOG Example 20 0010 : 71 72 73 74 75 76 77 78 79 7a qrstuvwxyz
|
sl@0
|
810 |
*
|
sl@0
|
811 |
*/
|
sl@0
|
812 |
{
|
sl@0
|
813 |
if (IsLogging())
|
sl@0
|
814 |
{
|
sl@0
|
815 |
DoHexDump(aData,aHeader,TPtrC8(NULL,0));
|
sl@0
|
816 |
}
|
sl@0
|
817 |
|
sl@0
|
818 |
|
sl@0
|
819 |
}
|
sl@0
|
820 |
|
sl@0
|
821 |
|
sl@0
|
822 |
|
sl@0
|
823 |
|
sl@0
|
824 |
|
sl@0
|
825 |
|
sl@0
|
826 |
EXPORT_C void RFileLogger::HexDump(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aData, const TDesC8& aHeader)
|
sl@0
|
827 |
/**
|
sl@0
|
828 |
* Static Write. Dump arbitrary data to the log file as a standard hex dump.
|
sl@0
|
829 |
* @internalTechnology
|
sl@0
|
830 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
831 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
832 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
833 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
834 |
* @param aData the data being dumped.
|
sl@0
|
835 |
* @param aHeader Specify a string to be printed before the first hex line. If not supplied, no header or Margin is written.
|
sl@0
|
836 |
* @param aMargin Specify a string to be printed before each subsequent line. If not supplied, a string of spaces equal to the length of aHeader is used.
|
sl@0
|
837 |
* @post Each line is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
838 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
839 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
840 |
* Example of aHeader/aMargin. If "aHeader" is set to "Fn Output:" and "aMargin" is set to " ", then output would look
|
sl@0
|
841 |
* like (for a print of the alphabet):
|
sl@0
|
842 |
* TLOG Example 20 FnOutput:0000 : 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 abcdefghijklmnop
|
sl@0
|
843 |
* TLOG Example 20 0010 : 71 72 73 74 75 76 77 78 79 7a qrstuvwxyz
|
sl@0
|
844 |
*
|
sl@0
|
845 |
*/
|
sl@0
|
846 |
{
|
sl@0
|
847 |
RFileLogger logger;
|
sl@0
|
848 |
TInt ret=logger.Connect();
|
sl@0
|
849 |
if (ret==KErrNone)
|
sl@0
|
850 |
{
|
sl@0
|
851 |
ret = logger.SetLogTags(aSubsystem,aComponent);
|
sl@0
|
852 |
if (((ret == KErrNone) && logger.iLoggerBody) && logger.iLoggerBody->iLoggingOnPckg())
|
sl@0
|
853 |
{
|
sl@0
|
854 |
logger.DoHexDump(aData,aHeader,TPtrC8(NULL,0));
|
sl@0
|
855 |
}
|
sl@0
|
856 |
logger.Close();
|
sl@0
|
857 |
}
|
sl@0
|
858 |
}
|
sl@0
|
859 |
|
sl@0
|
860 |
|
sl@0
|
861 |
|
sl@0
|
862 |
|
sl@0
|
863 |
|
sl@0
|
864 |
EXPORT_C void RFileLogger::HexDump(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen)
|
sl@0
|
865 |
/**
|
sl@0
|
866 |
* Static Write. Dump arbitrary data to the log file as a standard hex dump.
|
sl@0
|
867 |
* @internalTechnology
|
sl@0
|
868 |
* @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
|
sl@0
|
869 |
@pre The client requesting to log must be listed in the flogger "ini" file
|
sl@0
|
870 |
as an enabled logging client, otherwise no logging will occur.
|
sl@0
|
871 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
872 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
873 |
* @param aMode not used
|
sl@0
|
874 |
* @param aHeader Specify a zero-terminated string to be printed before the first hex line. Leave as null or an empty string for no header.
|
sl@0
|
875 |
* @param aMargin Specify a zero-terminated string to be printed before each subsequent line. Leave as null or an empty string for no Margin.
|
sl@0
|
876 |
* @param aPtr pointer to the data being dumped.
|
sl@0
|
877 |
* @param aLen the number of bytes to dump
|
sl@0
|
878 |
* @post Each line is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
879 |
* "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
|
sl@0
|
880 |
* @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
|
sl@0
|
881 |
* Example of aHeader/aMargin. If "aHeader" is set to "Fn Output:" and "aMargin" is set to " ", then output would look
|
sl@0
|
882 |
* like (for a print of the alphabet):
|
sl@0
|
883 |
* TLOG Example 20 FnOutput:0000 : 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 abcdefghijklmnop
|
sl@0
|
884 |
* TLOG Example 20 0010 : 71 72 73 74 75 76 77 78 79 7a qrstuvwxyz
|
sl@0
|
885 |
*
|
sl@0
|
886 |
*/
|
sl@0
|
887 |
{
|
sl@0
|
888 |
// the convert also truncates if necessary
|
sl@0
|
889 |
TNameTag narrowComponent;
|
sl@0
|
890 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
|
sl@0
|
891 |
TNameTag narrowSubsystem;
|
sl@0
|
892 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
|
sl@0
|
893 |
|
sl@0
|
894 |
RFileLogger logger;
|
sl@0
|
895 |
TInt ret=logger.Connect();
|
sl@0
|
896 |
if (ret==KErrNone)
|
sl@0
|
897 |
{
|
sl@0
|
898 |
ret = logger.SetLogTags(narrowSubsystem,narrowComponent);
|
sl@0
|
899 |
if (((ret == KErrNone) && logger.iLoggerBody) && logger.iLoggerBody->iLoggingOnPckg())
|
sl@0
|
900 |
{
|
sl@0
|
901 |
logger.DoHexDump(aHeader,aMargin,aPtr,aLen);
|
sl@0
|
902 |
}
|
sl@0
|
903 |
logger.Close();
|
sl@0
|
904 |
}
|
sl@0
|
905 |
|
sl@0
|
906 |
}
|
sl@0
|
907 |
|
sl@0
|
908 |
|
sl@0
|
909 |
EXPORT_C TInt RFileLogger::Handle() const
|
sl@0
|
910 |
// Returns handle of session, or Null if no session.
|
sl@0
|
911 |
{
|
sl@0
|
912 |
if (iLoggerBody)
|
sl@0
|
913 |
{
|
sl@0
|
914 |
return iLoggerBody->Handle();
|
sl@0
|
915 |
}
|
sl@0
|
916 |
else
|
sl@0
|
917 |
{
|
sl@0
|
918 |
return 0;
|
sl@0
|
919 |
}
|
sl@0
|
920 |
}
|
sl@0
|
921 |
|
sl@0
|
922 |
EXPORT_C TInt RFileLogger::Share()
|
sl@0
|
923 |
{
|
sl@0
|
924 |
if (iLoggerBody)
|
sl@0
|
925 |
{
|
sl@0
|
926 |
return iLoggerBody->ShareAuto();
|
sl@0
|
927 |
}
|
sl@0
|
928 |
return KErrSessionClosed;
|
sl@0
|
929 |
}
|
sl@0
|
930 |
|
sl@0
|
931 |
|
sl@0
|
932 |
//
|
sl@0
|
933 |
// Debug tools to check for memory leaks
|
sl@0
|
934 |
//
|
sl@0
|
935 |
|
sl@0
|
936 |
EXPORT_C void RFileLogger::__DbgShutDownServer()
|
sl@0
|
937 |
/**
|
sl@0
|
938 |
* Debugging Tool. Ask the flogger server to shutdown. Only valid in DEBUG builds.
|
sl@0
|
939 |
* @internalTechnology
|
sl@0
|
940 |
*/
|
sl@0
|
941 |
{
|
sl@0
|
942 |
#ifdef _DEBUG
|
sl@0
|
943 |
if (iLoggerBody)
|
sl@0
|
944 |
(void)iLoggerBody->DoSendReceive(EShutDownServer);
|
sl@0
|
945 |
#endif
|
sl@0
|
946 |
}
|
sl@0
|
947 |
|
sl@0
|
948 |
EXPORT_C void RFileLogger::__DbgSetHeapFailure(TInt aFailAfter)
|
sl@0
|
949 |
/**
|
sl@0
|
950 |
* Debugging Tool. Ask the flogger server to set its heap failure. Only valid in DEBUG builds.
|
sl@0
|
951 |
* @internalTechnology
|
sl@0
|
952 |
* @param aFailAfter The number of successful memory allocations which will occur before
|
sl@0
|
953 |
* a memory allocation is failed by the memory manager.
|
sl@0
|
954 |
*/
|
sl@0
|
955 |
{
|
sl@0
|
956 |
#ifdef _DEBUG
|
sl@0
|
957 |
if (iLoggerBody)
|
sl@0
|
958 |
{
|
sl@0
|
959 |
(void)iLoggerBody->DoSendReceive(ESetHeapFailure, TIpcArgs(aFailAfter));
|
sl@0
|
960 |
}
|
sl@0
|
961 |
#else
|
sl@0
|
962 |
(void)aFailAfter;
|
sl@0
|
963 |
#endif
|
sl@0
|
964 |
}
|
sl@0
|
965 |
|
sl@0
|
966 |
//
|
sl@0
|
967 |
// Private functions
|
sl@0
|
968 |
//
|
sl@0
|
969 |
|
sl@0
|
970 |
TInt RFileLogger::DoConnect()
|
sl@0
|
971 |
/**
|
sl@0
|
972 |
* Connect to the flogger server
|
sl@0
|
973 |
* @return TInt indicating success code (KErrNone) or an error code.
|
sl@0
|
974 |
* @note: creates 1 slot: no asynchronous IPC so never need more than 1 reserved message slot.
|
sl@0
|
975 |
@internalComponent
|
sl@0
|
976 |
*/
|
sl@0
|
977 |
{
|
sl@0
|
978 |
__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
|
sl@0
|
979 |
return iLoggerBody->DoCreateSession(KFLoggerServerName,Version(),KNumberMessageSlots);
|
sl@0
|
980 |
}
|
sl@0
|
981 |
|
sl@0
|
982 |
TInt RFileLogger::DoSetLogTags(const TDesC8& aSubsystem, const TDesC8& aComponent)
|
sl@0
|
983 |
/**
|
sl@0
|
984 |
* Set the two tag strings that all further writes by this client will use to
|
sl@0
|
985 |
* identify it in the log file.
|
sl@0
|
986 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
987 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
988 |
* @return TInt indicating success code (KErrNone), or (KErrNotFound) if
|
sl@0
|
989 |
the connection is not valid, or an error code from SendReceive.
|
sl@0
|
990 |
* @note If an error occurs, the client connection will be silently closed to protect
|
sl@0
|
991 |
* the client.
|
sl@0
|
992 |
*/
|
sl@0
|
993 |
{
|
sl@0
|
994 |
TInt err(KErrNone);
|
sl@0
|
995 |
if (iLoggerBody) //check that the connection was set up correctly
|
sl@0
|
996 |
{
|
sl@0
|
997 |
err = iLoggerBody->DoSendReceive(ESetLogTag, TIpcArgs(&aSubsystem, &aComponent, &(iLoggerBody->iLoggingOnPckg)));
|
sl@0
|
998 |
if (err !=KErrNone )
|
sl@0
|
999 |
{ //Something went wrong. We need to protect the client because error can be ignored.
|
sl@0
|
1000 |
Close();
|
sl@0
|
1001 |
}
|
sl@0
|
1002 |
}
|
sl@0
|
1003 |
else
|
sl@0
|
1004 |
{
|
sl@0
|
1005 |
err = KErrNotFound;
|
sl@0
|
1006 |
}
|
sl@0
|
1007 |
return err;
|
sl@0
|
1008 |
}
|
sl@0
|
1009 |
|
sl@0
|
1010 |
void RFileLogger::DoWrite(const TDesC8& aBuf)
|
sl@0
|
1011 |
/**
|
sl@0
|
1012 |
* Send to the flogger server the pre-formatted write string.
|
sl@0
|
1013 |
* @internalTechnology
|
sl@0
|
1014 |
* @pre session is already open.
|
sl@0
|
1015 |
* @param aBuf 8-bit text to be written. It must not exceed KLogBufferSize.
|
sl@0
|
1016 |
*/
|
sl@0
|
1017 |
{
|
sl@0
|
1018 |
__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
|
sl@0
|
1019 |
(void)iLoggerBody->DoSendReceive(EWriteToLog,TIpcArgs(&aBuf, aBuf.Length()));
|
sl@0
|
1020 |
}
|
sl@0
|
1021 |
|
sl@0
|
1022 |
void RFileLogger::DoWriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
|
sl@0
|
1023 |
/**
|
sl@0
|
1024 |
* Trim and convert format string before sending to the flogger server.
|
sl@0
|
1025 |
* @pre session is already open.
|
sl@0
|
1026 |
* @param aFmt c-style formatted text to be written.
|
sl@0
|
1027 |
* @param aList any variables required by the format.
|
sl@0
|
1028 |
* @post The final string is truncated to KLogBufferSize and converted to 8-bit.
|
sl@0
|
1029 |
*/
|
sl@0
|
1030 |
{
|
sl@0
|
1031 |
TBuf16<KLogBufferSize> wideBuf;
|
sl@0
|
1032 |
__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
|
sl@0
|
1033 |
wideBuf.AppendFormatList(aFmt, aList, &(iLoggerBody->iFlogOverflow16));
|
sl@0
|
1034 |
TBuf8<KLogBufferSize> narrowBuf;
|
sl@0
|
1035 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowBuf,wideBuf);
|
sl@0
|
1036 |
DoWrite(narrowBuf);
|
sl@0
|
1037 |
}
|
sl@0
|
1038 |
|
sl@0
|
1039 |
void RFileLogger::DoWriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
|
sl@0
|
1040 |
/**
|
sl@0
|
1041 |
* Trim format string before sending to the flogger server.
|
sl@0
|
1042 |
* @pre session is already open.
|
sl@0
|
1043 |
* @param aFmt c-style formatted text to be written.
|
sl@0
|
1044 |
* @param aList any variables required by the format.
|
sl@0
|
1045 |
* @post The final string is truncated to KLogBufferSize.
|
sl@0
|
1046 |
*/
|
sl@0
|
1047 |
{
|
sl@0
|
1048 |
TBuf8<KLogBufferSize> buf;
|
sl@0
|
1049 |
__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
|
sl@0
|
1050 |
buf.AppendFormatList(aFmt,aList, &(iLoggerBody->iFlogOverflow8));
|
sl@0
|
1051 |
DoWrite(buf);
|
sl@0
|
1052 |
}
|
sl@0
|
1053 |
|
sl@0
|
1054 |
void RFileLogger::DoSendStaticWrite(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aText)
|
sl@0
|
1055 |
/**
|
sl@0
|
1056 |
* Send to the flogger server the pre-formatted write string.
|
sl@0
|
1057 |
* @pre session is already open.
|
sl@0
|
1058 |
* aText is not longer than KLogBufferSize
|
sl@0
|
1059 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
1060 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
1061 |
* @param aText text to write
|
sl@0
|
1062 |
* @post The text is only written if the tag1+tag2 combination is listed as an enabled client
|
sl@0
|
1063 |
* in the flogger "ini" file, otherwise no action is taken.
|
sl@0
|
1064 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
1065 |
*/
|
sl@0
|
1066 |
{
|
sl@0
|
1067 |
__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
|
sl@0
|
1068 |
(void)iLoggerBody->DoSendReceive(EStaticWriteToLog,TIpcArgs(&aSubsystem, &aComponent, &aText, aText.Length())); // ignore error
|
sl@0
|
1069 |
}
|
sl@0
|
1070 |
|
sl@0
|
1071 |
void RFileLogger::DoStaticWrite(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aText)
|
sl@0
|
1072 |
/**
|
sl@0
|
1073 |
* Send to the flogger server the pre-formatted write string.
|
sl@0
|
1074 |
* @pre session is already open.
|
sl@0
|
1075 |
* aText is not longer than KLogBufferSize
|
sl@0
|
1076 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
1077 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
1078 |
* @param aText text to write
|
sl@0
|
1079 |
* @post The text is only written if the tag1+tag2 combination is listed as an enabled client
|
sl@0
|
1080 |
* in the flogger "ini" file, otherwise no action is taken.
|
sl@0
|
1081 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
1082 |
*/
|
sl@0
|
1083 |
{
|
sl@0
|
1084 |
RFileLogger logger;
|
sl@0
|
1085 |
TInt ret=logger.Connect();
|
sl@0
|
1086 |
if (ret==KErrNone)
|
sl@0
|
1087 |
{
|
sl@0
|
1088 |
TPtrC8 textValid;
|
sl@0
|
1089 |
textValid.Set(aText.Left(KLogBufferSize));
|
sl@0
|
1090 |
|
sl@0
|
1091 |
logger.DoSendStaticWrite(aSubsystem, aComponent, textValid);
|
sl@0
|
1092 |
}
|
sl@0
|
1093 |
|
sl@0
|
1094 |
logger.Close();
|
sl@0
|
1095 |
}
|
sl@0
|
1096 |
|
sl@0
|
1097 |
|
sl@0
|
1098 |
|
sl@0
|
1099 |
void RFileLogger::DoStaticWriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, TRefByValue<const TDesC> aFmt, VA_LIST& aList)
|
sl@0
|
1100 |
/**
|
sl@0
|
1101 |
* Send to the flogger server a format write string.
|
sl@0
|
1102 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
1103 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
1104 |
* @param aFmt c-style formatted text to be written.
|
sl@0
|
1105 |
* @param aList any variables required by the format.
|
sl@0
|
1106 |
* @post The text is only written if the tag1+tag2 combination is listed as an enabled client
|
sl@0
|
1107 |
* in the flogger "ini" file, otherwise no action is taken.
|
sl@0
|
1108 |
* If necessary, the final string is truncated to KLogBufferSize.
|
sl@0
|
1109 |
* The final string is converted to an 8-bit string.
|
sl@0
|
1110 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
1111 |
*/
|
sl@0
|
1112 |
{
|
sl@0
|
1113 |
TFlogOverflow16 objFlogBody16;
|
sl@0
|
1114 |
TBuf<KLogBufferSize> wideBuf;
|
sl@0
|
1115 |
TBuf8<KLogBufferSize> narrowBuf;
|
sl@0
|
1116 |
|
sl@0
|
1117 |
wideBuf.AppendFormatList(aFmt, aList, &objFlogBody16);
|
sl@0
|
1118 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowBuf,wideBuf);
|
sl@0
|
1119 |
|
sl@0
|
1120 |
DoStaticWrite(aSubsystem, aComponent, narrowBuf);
|
sl@0
|
1121 |
}
|
sl@0
|
1122 |
|
sl@0
|
1123 |
void RFileLogger::DoStaticWriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
|
sl@0
|
1124 |
/**
|
sl@0
|
1125 |
* Send to the flogger server a format write string.
|
sl@0
|
1126 |
* @param aSubsystem Specifies the tag1 name that goes into the log file
|
sl@0
|
1127 |
* @param aComponent specifies the tag2 name that goes into the log file
|
sl@0
|
1128 |
* @param aFmt c-style formatted text to be written.
|
sl@0
|
1129 |
* @param aList any variables required by the format.
|
sl@0
|
1130 |
* @post The text is only written if the tag1+tag2 combination is listed as an enabled client
|
sl@0
|
1131 |
* in the flogger "ini" file, otherwise no action is taken.
|
sl@0
|
1132 |
* If necessary, the final string is truncated to KLogBufferSize.
|
sl@0
|
1133 |
* The text is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
1134 |
*/ {
|
sl@0
|
1135 |
TFlogOverflow8 objFlogBody8;
|
sl@0
|
1136 |
TBuf8<KLogBufferSize> buf;
|
sl@0
|
1137 |
buf.AppendFormatList(aFmt, aList, &objFlogBody8);
|
sl@0
|
1138 |
|
sl@0
|
1139 |
DoStaticWrite(aSubsystem, aComponent, buf);
|
sl@0
|
1140 |
}
|
sl@0
|
1141 |
|
sl@0
|
1142 |
void RFileLogger::DoHexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen)
|
sl@0
|
1143 |
/**
|
sl@0
|
1144 |
* Static Write. Dump arbitrary data to the log file as a standard hex dump.
|
sl@0
|
1145 |
* @pre session is already open.
|
sl@0
|
1146 |
* @param aHeader Specify a zero-terminated string to be printed before the first hex line. Leave as null or an empty string for no header.
|
sl@0
|
1147 |
* @param aMargin Specify a zero-terminated string to be printed before each subsequent line. Leave as null or an empty string for no Margin.
|
sl@0
|
1148 |
* @param aPtr pointer to the data being dumped.
|
sl@0
|
1149 |
* @param aLen the number of bytes to dump
|
sl@0
|
1150 |
* @post The text is only written if the tag1+tag2 combination is listed as an enabled client
|
sl@0
|
1151 |
* in the flogger "ini" file, otherwise no action is taken.
|
sl@0
|
1152 |
* Each line is preceded in the log file by the two client tags and the client thread ID.
|
sl@0
|
1153 |
* The data is written in lines of 16 characters.
|
sl@0
|
1154 |
* @note Example of aHeader/aMargin. If "aHeader" is set to "Fn Output:" and "aMargin" is set to " ", then output would look
|
sl@0
|
1155 |
* like (for a print of the alphabet):
|
sl@0
|
1156 |
* TLOG Example 20 FnOutput:0000 : 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 abcdefghijklmnop
|
sl@0
|
1157 |
* TLOG Example 20 0010 : 71 72 73 74 75 76 77 78 79 7a qrstuvwxyz
|
sl@0
|
1158 |
*
|
sl@0
|
1159 |
*/
|
sl@0
|
1160 |
{
|
sl@0
|
1161 |
// this delightful art-deco code lifted straight from old flogger
|
sl@0
|
1162 |
if (aPtr==NULL) // nothing to do
|
sl@0
|
1163 |
{
|
sl@0
|
1164 |
return;
|
sl@0
|
1165 |
}
|
sl@0
|
1166 |
|
sl@0
|
1167 |
TBuf<KMaxHexDumpWidth> buf;
|
sl@0
|
1168 |
TBuf8<KMaxHexDumpWidth> temp;
|
sl@0
|
1169 |
|
sl@0
|
1170 |
|
sl@0
|
1171 |
TInt i=0;
|
sl@0
|
1172 |
const TText* p=aHeader;
|
sl@0
|
1173 |
while (aLen>0)
|
sl@0
|
1174 |
{
|
sl@0
|
1175 |
if (p==NULL)
|
sl@0
|
1176 |
{
|
sl@0
|
1177 |
p=BLANK; // if NULL set p to a blank string
|
sl@0
|
1178 |
}
|
sl@0
|
1179 |
TInt n=(aLen>KHexDumpWidth ? KHexDumpWidth : aLen);
|
sl@0
|
1180 |
__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
|
sl@0
|
1181 |
buf.AppendFormat(KFirstFormatString,&(iLoggerBody->iFlogOverflow16),p,i);
|
sl@0
|
1182 |
TInt j;
|
sl@0
|
1183 |
for (j=0; j<n; j++)
|
sl@0
|
1184 |
{
|
sl@0
|
1185 |
buf.AppendFormat(KSecondFormatString,aPtr[i+j]);
|
sl@0
|
1186 |
}
|
sl@0
|
1187 |
while (j++<KHexDumpWidth)
|
sl@0
|
1188 |
{
|
sl@0
|
1189 |
buf.Append(KThreeSpaces);
|
sl@0
|
1190 |
}
|
sl@0
|
1191 |
buf.Append(KTwoSpaces);
|
sl@0
|
1192 |
for (j=0; j<n; j++)
|
sl@0
|
1193 |
{
|
sl@0
|
1194 |
buf.AppendFormat(KThirdFormatString,(aPtr[i+j]<KLowestPrintableCharacter || aPtr[i+j]>KHighestPrintableCharacter) ? KFullStopChar : aPtr[i+j]);
|
sl@0
|
1195 |
}
|
sl@0
|
1196 |
|
sl@0
|
1197 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(temp,buf);
|
sl@0
|
1198 |
DoWrite(temp);
|
sl@0
|
1199 |
|
sl@0
|
1200 |
buf.SetLength(0);
|
sl@0
|
1201 |
temp.SetLength(0);
|
sl@0
|
1202 |
aLen-=n;
|
sl@0
|
1203 |
i+=n;
|
sl@0
|
1204 |
p=aMargin;
|
sl@0
|
1205 |
}
|
sl@0
|
1206 |
}
|
sl@0
|
1207 |
|
sl@0
|
1208 |
|
sl@0
|
1209 |
|
sl@0
|
1210 |
void RFileLogger::DoHexDump(const TDesC8& aData, const TDesC8& aHeader, const TDesC8& aMargin)
|
sl@0
|
1211 |
/**
|
sl@0
|
1212 |
* Static Write. Dump arbitrary data to the log file as a standard hex dump.
|
sl@0
|
1213 |
* @see RFileLogger::HexDump(const TDesC8& aData, const TDesC8& aHeader = 0)
|
sl@0
|
1214 |
* @param aMargin - supply a margin - if left null, then a margin of spaces of equal length to "aHeader"
|
sl@0
|
1215 |
* is used.
|
sl@0
|
1216 |
* @pre session is already open.
|
sl@0
|
1217 |
*/
|
sl@0
|
1218 |
{
|
sl@0
|
1219 |
HBufC8* marginStr = NULL;
|
sl@0
|
1220 |
TBuf8<KMaxHexDumpWidth> buf;
|
sl@0
|
1221 |
TInt aRemainingLen = aData.Length();
|
sl@0
|
1222 |
TInt aHeaderLen = aHeader.Length();
|
sl@0
|
1223 |
|
sl@0
|
1224 |
__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
|
sl@0
|
1225 |
|
sl@0
|
1226 |
if (aData.Length()==0) // nothing to do
|
sl@0
|
1227 |
{
|
sl@0
|
1228 |
return;
|
sl@0
|
1229 |
}
|
sl@0
|
1230 |
|
sl@0
|
1231 |
|
sl@0
|
1232 |
if (aHeaderLen > 0)
|
sl@0
|
1233 |
{
|
sl@0
|
1234 |
|
sl@0
|
1235 |
if (aMargin.Length() == 0)
|
sl@0
|
1236 |
{
|
sl@0
|
1237 |
marginStr = HBufC8::New(aHeader.Length());
|
sl@0
|
1238 |
if (marginStr == NULL)
|
sl@0
|
1239 |
{
|
sl@0
|
1240 |
return; // abort if No memory
|
sl@0
|
1241 |
}
|
sl@0
|
1242 |
TPtr8 marginStrPtr(marginStr->Des());
|
sl@0
|
1243 |
marginStrPtr.AppendFill(' ',aHeader.Length());
|
sl@0
|
1244 |
}
|
sl@0
|
1245 |
else
|
sl@0
|
1246 |
{
|
sl@0
|
1247 |
marginStr = aMargin.Alloc();
|
sl@0
|
1248 |
}
|
sl@0
|
1249 |
}
|
sl@0
|
1250 |
|
sl@0
|
1251 |
|
sl@0
|
1252 |
|
sl@0
|
1253 |
TUint blockStartPos = 0;
|
sl@0
|
1254 |
while (aRemainingLen>0)
|
sl@0
|
1255 |
{
|
sl@0
|
1256 |
TInt blockLength = (aRemainingLen>KHexDumpWidth ? KHexDumpWidth : aRemainingLen);
|
sl@0
|
1257 |
|
sl@0
|
1258 |
// write the header/margin and print in hex which bytes we are about to write
|
sl@0
|
1259 |
if (blockStartPos == 0)
|
sl@0
|
1260 |
{
|
sl@0
|
1261 |
if (aHeaderLen > 0)
|
sl@0
|
1262 |
{
|
sl@0
|
1263 |
buf.Append(aHeader);
|
sl@0
|
1264 |
}
|
sl@0
|
1265 |
buf.AppendFormat(KFirstFormatString8,&(iLoggerBody->iFlogOverflow8), blockStartPos);
|
sl@0
|
1266 |
}
|
sl@0
|
1267 |
else
|
sl@0
|
1268 |
{
|
sl@0
|
1269 |
if (marginStr)
|
sl@0
|
1270 |
{
|
sl@0
|
1271 |
buf.Append(*marginStr);
|
sl@0
|
1272 |
}
|
sl@0
|
1273 |
buf.AppendFormat(KFirstFormatString8,&(iLoggerBody->iFlogOverflow8),blockStartPos);
|
sl@0
|
1274 |
}
|
sl@0
|
1275 |
|
sl@0
|
1276 |
TInt bytePos;
|
sl@0
|
1277 |
// write the bytes as hex
|
sl@0
|
1278 |
for (bytePos = 0; bytePos < blockLength; bytePos++)
|
sl@0
|
1279 |
{
|
sl@0
|
1280 |
buf.AppendFormat(KSecondFormatString8,aData[blockStartPos + bytePos]);
|
sl@0
|
1281 |
}
|
sl@0
|
1282 |
while (bytePos++ < KHexDumpWidth)
|
sl@0
|
1283 |
{
|
sl@0
|
1284 |
buf.Append(KThreeSpaces8);
|
sl@0
|
1285 |
}
|
sl@0
|
1286 |
buf.Append(KTwoSpaces8);
|
sl@0
|
1287 |
// print the bytes as characters, or full stops if outside printable range
|
sl@0
|
1288 |
for (bytePos = 0; bytePos < blockLength; bytePos++)
|
sl@0
|
1289 |
{
|
sl@0
|
1290 |
buf.AppendFormat(KThirdFormatString8,(aData[blockStartPos + bytePos] < KLowestPrintableCharacter || aData[blockStartPos + bytePos] > KHighestPrintableCharacter) ? KFullStopChar8 : aData[blockStartPos + bytePos]);
|
sl@0
|
1291 |
}
|
sl@0
|
1292 |
|
sl@0
|
1293 |
DoWrite(buf);
|
sl@0
|
1294 |
|
sl@0
|
1295 |
buf.SetLength(0);
|
sl@0
|
1296 |
aRemainingLen -= blockLength;
|
sl@0
|
1297 |
blockStartPos += blockLength;
|
sl@0
|
1298 |
}
|
sl@0
|
1299 |
delete marginStr;
|
sl@0
|
1300 |
}
|
sl@0
|
1301 |
|
sl@0
|
1302 |
|
sl@0
|
1303 |
|
sl@0
|
1304 |
EXPORT_C void ClientRunStubOrdinal1()
|
sl@0
|
1305 |
/**
|
sl@0
|
1306 |
* @removed This function has been removed because the flogsvrl dll contains the equivalent function
|
sl@0
|
1307 |
@internalComponent
|
sl@0
|
1308 |
*/
|
sl@0
|
1309 |
{User::Panic(KFloggerPanic, KErrNotSupported);}
|
sl@0
|
1310 |
|