os/persistentdata/traceservices/commsdebugutility/SCLI/comsdbgcli.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/traceservices/commsdebugutility/SCLI/comsdbgcli.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1310 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Implements the Flogger client side
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @internalTechnology
    1.24 +*/
    1.25 +
    1.26 +#include <f32file.h>
    1.27 +#include <comms-infras/commsdebugutility.h>
    1.28 +#include "comsdbgstd.h"
    1.29 +#include <e32def.h>
    1.30 +
    1.31 +#include <utf.h>
    1.32 +
    1.33 +#define BLANK	_S("")
    1.34 +
    1.35 +const TInt KHexDumpWidth=16;			///< Number of bytes written per line when formatting as hex.
    1.36 +const TInt KNumberMessageSlots=1;       ///< Number of message slots on flogger client.no asynchronous IPC so never need more than 1 slot
    1.37 +const TInt KLowestPrintableCharacter = 32; ///< In Hex output, replace chars below space with a dot.
    1.38 +const TInt KHighestPrintableCharacter = 126; ///< In Hex output, replace chars above 7-bits with a dot.
    1.39 +
    1.40 +_LIT(KFirstFormatString,"%s%04x : ");   ///< Format string used in Hexdump to format first part: header and byte numbers.
    1.41 +_LIT(KSecondFormatString,"%02x ");      ///< Format string used in Hexdump to format mid part: each of the 16 bytes as hex
    1.42 +_LIT(KThirdFormatString,"%c");          ///< Format string used in Hexdump to format the last part: each of the 16 bytes as characters
    1.43 +_LIT(KThreeSpaces,"   ");               ///< Format string used in Hexdump to define padding between first and mid parts
    1.44 +_LIT(KTwoSpaces," ");                   ///< Format string used in Hexdump to define padding between hex and char bytes.
    1.45 +
    1.46 +_LIT8(KFirstFormatString8,"%04x : ");   ///< Format string used in Hexdump to format first part: header and byte numbers.
    1.47 +_LIT8(KSecondFormatString8,"%02x ");      ///< Format string used in Hexdump to format mid part: each of the 16 bytes as hex
    1.48 +_LIT8(KThirdFormatString8,"%c");          ///< Format string used in Hexdump to format the last part: each of the 16 bytes as characters
    1.49 +_LIT8(KThreeSpaces8,"   ");               ///< Format string used in Hexdump to define padding between first and mid parts
    1.50 +_LIT8(KTwoSpaces8," ");                   ///< Format string used in Hexdump to define padding between hex and char bytes.
    1.51 +
    1.52 +
    1.53 +
    1.54 +//
    1.55 +// RFileLogger class definition
    1.56 +//
    1.57 +
    1.58 +EXPORT_C RFileLogger::RFileLogger() : iLoggerBody(NULL)
    1.59 +/**
    1.60 + * Create a new flogger client interface object with an empty body.
    1.61 + * @internalTechnology 
    1.62 + */
    1.63 +	{}
    1.64 +
    1.65 +EXPORT_C RFileLogger::~RFileLogger()
    1.66 +/**
    1.67 + * Destructor
    1.68 + * @internalTechnology 
    1.69 + */
    1.70 +	{}
    1.71 +
    1.72 +EXPORT_C TVersion RFileLogger::Version() const
    1.73 +/**
    1.74 + * Return the client side version number
    1.75 + * @internalTechnology 
    1.76 + * @return TVersion 3-part version number: major, minor, build.
    1.77 + */
    1.78 +	{
    1.79 +
    1.80 +	return(TVersion(KFLogSrvMajorVersionNumber,KFLogSrvMinorVersionNumber,KFLogSrvBuildVersionNumber));
    1.81 +	}
    1.82 +
    1.83 +EXPORT_C TInt RFileLogger::Connect()
    1.84 +/**
    1.85 + Connect to the flogger server - default number of message slots = 1
    1.86 + @internalTechnology 
    1.87 + @return TInt indicating success code (KErrNone), KErrNoMemory if failed to allocate log body
    1.88 +         or an error from RSessionBase::CreateSession.
    1.89 +         KErrAlreadyExists if Connect has already been called.
    1.90 + */
    1.91 +	{
    1.92 +	if (iLoggerBody)
    1.93 +		{
    1.94 +		return KErrAlreadyExists;
    1.95 +		}
    1.96 +	iLoggerBody = new RFileLoggerBody;
    1.97 +	if (iLoggerBody)
    1.98 +		{
    1.99 +		TInt ret=DoConnect();
   1.100 +		if (ret==KErrNotFound)
   1.101 +			{
   1.102 +			ret=FLogger::Start();
   1.103 +			if (ret==KErrNone || ret==KErrAlreadyExists)
   1.104 +				ret=DoConnect();
   1.105 +			}
   1.106 +		if (ret != KErrNone)
   1.107 +			{
   1.108 +			// we had a problem (perhaps no memory) so kill loggerbody again
   1.109 +			delete iLoggerBody;
   1.110 +			iLoggerBody = NULL;
   1.111 +			}
   1.112 +			
   1.113 +		return ret;
   1.114 +		} 
   1.115 +	else
   1.116 +		{
   1.117 +		//OOM, so return KErrNoMemory so that OOM tests know this
   1.118 +		return KErrNoMemory;
   1.119 +		}
   1.120 +	}
   1.121 +
   1.122 +EXPORT_C void RFileLogger::Close()
   1.123 +/**
   1.124 + * Close a client side session with the flogger server.
   1.125 + * @internalTechnology 
   1.126 + * @post The client session is closed and the body of the class is deleted.
   1.127 + *       Further calls to the Write functions will fail silently until a new session is opened.
   1.128 + */
   1.129 +	{
   1.130 +	if (iLoggerBody)
   1.131 +		{
   1.132 +		iLoggerBody->Close();
   1.133 +		delete iLoggerBody;
   1.134 +		}
   1.135 +	iLoggerBody = NULL;
   1.136 +	}
   1.137 +
   1.138 +EXPORT_C void RFileLogger::SetDateAndTime(TBool /*aUseDate*/,TBool /*aUseTime*/)
   1.139 +/**
   1.140 + * Does nothing.
   1.141 + * @internalTechnology 
   1.142 + * @removed    This function no longer needed since now logging to one file and
   1.143 + *             date/time comes from system.
   1.144 + */
   1.145 +	{}
   1.146 +
   1.147 +EXPORT_C TInt RFileLogger::SetLogTags(const TDesC8& aSubsystem, const TDesC8& aComponent)
   1.148 +/**
   1.149 + * Set the two tag strings that all further writes by this client will use to
   1.150 + * idenitfy it in the log file.
   1.151 + * @internalTechnology 
   1.152 + * @param aSubsystem	Specifies the tag1 name that goes into the log file
   1.153 + * @param aComponent	specifies the tag2 name that goes into the log file
   1.154 + * @post  The client session is updated so that all future calls use this tag set.
   1.155 + *        Tags are truncated to KMaxTagLength.
   1.156 + * @return TInt indicating success code (KErrNone) or an error code.
   1.157 + * @note If an error occurs, the client connection will be silently closed to protect
   1.158 + *       the client.
   1.159 + */
   1.160 +	{
   1.161 +	TPtrC8 validSubsystem;
   1.162 +	TPtrC8 validComponent;
   1.163 +		
   1.164 +	validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
   1.165 +	validComponent.Set(aComponent.Left(KMaxTagLength));
   1.166 +	return DoSetLogTags(validSubsystem, validComponent);
   1.167 +	}
   1.168 +
   1.169 +EXPORT_C void RFileLogger::CreateLog(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/)
   1.170 +/**
   1.171 + * Sets the log tags.
   1.172 + * @internalTechnology 
   1.173 + * @removed             Not fully supported since flogger only uses one log file. Use SetLogTags instead.
   1.174 + * @param aSubsystem	Specifies the tag1 name that goes into the log file
   1.175 + * @param aComponent	specifies the tag2 name that goes into the log file
   1.176 + * @param aMode         not used
   1.177 + * @note	            This function is partially supported and is equivalent to calling SetLogTags.
   1.178 + * @see SetLogTags
   1.179 + */
   1.180 +	{
   1.181 +
   1.182 +	TNameTag narrowComponent;
   1.183 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
   1.184 +	TNameTag narrowSubsystem;
   1.185 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
   1.186 +	
   1.187 +	(void)DoSetLogTags(narrowSubsystem,narrowComponent);
   1.188 +	}
   1.189 +
   1.190 +EXPORT_C void RFileLogger::CloseLog()
   1.191 +/**
   1.192 + * Close a client side session with the flogger server.
   1.193 + * @internalTechnology 
   1.194 + * @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.
   1.195 + * @see          Close
   1.196 + */
   1.197 +	{
   1.198 +	Close();
   1.199 +	}
   1.200 +
   1.201 +EXPORT_C TBool RFileLogger::LogValid() const
   1.202 +/**
   1.203 + * Always returns ETrue.
   1.204 + * @internalTechnology 
   1.205 + * @removed  With the advent of a single log file for all clients, checking for log validity is no longer necessary.
   1.206 + * @return   ETrue always.
   1.207 + */
   1.208 +	{
   1.209 +	return ETrue;
   1.210 +	}
   1.211 +
   1.212 +EXPORT_C TInt RFileLogger::LastError() const
   1.213 +/**
   1.214 + * Always returns KErrNone
   1.215 + * @internalTechnology 
   1.216 + * @removed  Flogger no longer retains internal errors.
   1.217 + * @return   KErrNone always.
   1.218 + */
   1.219 +	{
   1.220 +	return KErrNone;
   1.221 +	}
   1.222 +
   1.223 +EXPORT_C TInt RFileLogger::ClearLog()
   1.224 +/**
   1.225 + * Request that the server empty the log file.
   1.226 + * @internalTechnology 
   1.227 + * @pre  The client requesting the log be cleared must be listed in the flogger "ini" file
   1.228 + *       as an enabled logging client. This prevents unwanted clients clearing the log.
   1.229 + *       The session with the server must be active, otherwise this will fail silently.
   1.230 + * @post A message is added to the server write queue that indicates to clear the log.
   1.231 + *       Once the message reaches the head of the queue flogger will empty the log file
   1.232 + *       and begin filling it again.
   1.233 + * @return TInt indicating success code (KErrNone) or an error code.
   1.234 + */
   1.235 +	{
   1.236 +	if (IsLogging())
   1.237 +		{
   1.238 +		__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
   1.239 +		return iLoggerBody->DoSendReceive(EClearLog, TIpcArgs());
   1.240 +		}
   1.241 +	else
   1.242 +		{
   1.243 +		return KErrNone;
   1.244 +		}
   1.245 +	}
   1.246 +
   1.247 +//
   1.248 +// 16-bit non-static writes
   1.249 +//
   1.250 +
   1.251 +EXPORT_C void RFileLogger::Write(const TDesC16& aText)
   1.252 +/**
   1.253 + * Write 16-bit aText to the log file.
   1.254 + * @internalTechnology 
   1.255 + * @pre  The client requesting to log must be listed in the flogger "ini" file
   1.256 + *       as an enabled logging client, otherwise no logging will occur.
   1.257 + *       The session with the server must be active, otherwise this will fail silently.
   1.258 + * @param aText Text to write
   1.259 + * @post The 16-bit text is converted to 8-bit text before writing, and is truncated to KLogBufferSize
   1.260 + *       if necessary.
   1.261 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.262 + @note There is no need to supply CR, LF. If these are supplied it may cause the log output to be incorrect.
   1.263 + */
   1.264 +	{
   1.265 +	if (!IsLogging())
   1.266 +		{
   1.267 +		return;
   1.268 +		}
   1.269 +
   1.270 +	TPtrC16 textValid;
   1.271 +	textValid.Set(aText.Left(KLogBufferSize));
   1.272 +	TBuf8<KLogBufferSize> buf;
   1.273 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(buf,textValid);
   1.274 +	DoWrite(buf);
   1.275 +	}
   1.276 +	
   1.277 +EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC16> aFmt,...)
   1.278 +/**
   1.279 + * Write the formatted 16-bit string aFmt to the log file
   1.280 + * @internalTechnology 
   1.281 + * @pre  The client requesting to log must be listed in the flogger "ini" file
   1.282 + *       as an enabled logging client, otherwise no logging will occur.
   1.283 + *       The session with the server must be active, otherwise this will fail silently.
   1.284 + * @param aFmt c-style format descriptor, followed by any variables required by the format.
   1.285 + * @post The 16-bit text is converted to 8-bit text before writing, and is truncated to KLogBufferSize
   1.286 + *       if necessary.
   1.287 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.288 + */
   1.289 +	{
   1.290 +	if (!IsLogging())
   1.291 +		{
   1.292 +		return;
   1.293 +		}
   1.294 +  //coverity[var_decl]
   1.295 +	VA_LIST list;
   1.296 +	VA_START(list,aFmt);
   1.297 +	//coverity[uninit_use_in_call]
   1.298 +	DoWriteFormat(aFmt,list);
   1.299 +	
   1.300 +	}
   1.301 +
   1.302 +EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
   1.303 +/**
   1.304 + * Write the formatted 16-bit string aFmt to the log file.
   1.305 + * @internalTechnology 
   1.306 + * @pre  The client requesting to log must be listed in the flogger "ini" file
   1.307 + *       as an enabled logging client, otherwise no logging will occur.
   1.308 + *       The session with the server must be active, otherwise this will fail silently.
   1.309 + * @param aFmt c-style format descriptor
   1.310 + * @param aList any variables required by the format.
   1.311 + * @post The 16-bit text is converted to 8-bit text before writing, and is truncated to KLogBufferSize
   1.312 + *       if necessary.
   1.313 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.314 + */
   1.315 +	{
   1.316 +	if (IsLogging())
   1.317 +		{
   1.318 +		DoWriteFormat(aFmt,aList);
   1.319 +		}
   1.320 +	}
   1.321 +
   1.322 +//
   1.323 +// 8-bit non-static writes
   1.324 +//
   1.325 +
   1.326 +EXPORT_C void RFileLogger::Write(const TDesC8& aText)
   1.327 +/**
   1.328 + * Write 8-bit aText to the log file.
   1.329 + * @internalTechnology 
   1.330 + * @pre  The client requesting to log must be listed in the flogger "ini" file
   1.331 + *       as an enabled logging client, otherwise no logging will occur.
   1.332 + *       The session with the server must be active, otherwise this will fail silently.
   1.333 + * @param aText  Text to log.
   1.334 + * @post The text is truncated to KLogBufferSize if necessary.
   1.335 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.336 + */
   1.337 +	{
   1.338 +	TPtrC8 textValid;
   1.339 +	textValid.Set(aText.Left(KLogBufferSize));
   1.340 +	if (IsLogging())
   1.341 +		{
   1.342 +		DoWrite(textValid);
   1.343 +		}
   1.344 +	}
   1.345 +	
   1.346 +EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC8> aFmt,...)
   1.347 +/**
   1.348 + * Write the formatted 8-bit string aFmt to the log file.
   1.349 + * @internalTechnology 
   1.350 + * @pre  The client requesting to log must be listed in the flogger "ini" file
   1.351 + *       as an enabled logging client, otherwise no logging will occur.
   1.352 + *       The session with the server must be active, otherwise this will fail silently.
   1.353 + * @param aFmt c-style format descriptor, followed by any variables required by the format.
   1.354 + * @post The text is truncated to KLogBufferSize if necessary.
   1.355 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.356 + */
   1.357 +	{
   1.358 +	if (!IsLogging())
   1.359 +		{
   1.360 +		return;
   1.361 +		}
   1.362 +  //coverity[var_decl]		
   1.363 +	VA_LIST list;
   1.364 +	VA_START(list,aFmt);
   1.365 +	//coverity[uninit_use_in_call]  
   1.366 +	DoWriteFormat(aFmt,list);
   1.367 +	}
   1.368 +
   1.369 +EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
   1.370 +/**
   1.371 + * Write the formatted 8-bit string aFmt to the log file if it is a valid file.
   1.372 + * @internalTechnology 
   1.373 + * @pre  The client requesting to log must be listed in the flogger "ini" file
   1.374 + *       as an enabled logging client, otherwise no logging will occur.
   1.375 + *       The session with the server must be active, otherwise this will fail silently.
   1.376 + * @param aFmt c-style format descriptor
   1.377 + * @param aList any variables required by the format.
   1.378 + * @post The text is truncated to KLogBufferSize if necessary.
   1.379 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.380 + */
   1.381 +	{
   1.382 +	if (IsLogging())
   1.383 +		{
   1.384 +		DoWriteFormat(aFmt,aList);
   1.385 +		}
   1.386 +	}
   1.387 +
   1.388 +EXPORT_C void RFileLogger::WriteBinary(const TDesC8& aData)
   1.389 +/**
   1.390 + * Dump arbitrary data to the log file in a binary format.
   1.391 + * @internalTechnology 
   1.392 + * @pre  The client requesting to log must be listed in the flogger "ini" file
   1.393 + *       as an enabled logging client, otherwise no logging will occur.
   1.394 + *       The session with the server must be active, otherwise this will fail silently.
   1.395 + * @param aData Descriptor of the data to be dumped
   1.396 + * @post The 8-bit binary dump is preceded in the log file by the two client tags
   1.397 + *
   1.398 + * @note Unlike all other write API's, no thread ID is written with this API.
   1.399 + */
   1.400 +	{
   1.401 +	if (IsLogging())
   1.402 +		{
   1.403 +		__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
   1.404 +		(void)iLoggerBody->DoSendReceive(EWriteBinary, TIpcArgs(&aData, aData.Length()));
   1.405 +		}
   1.406 +	}
   1.407 +
   1.408 +
   1.409 +//
   1.410 +// 16-bit static writes
   1.411 +//
   1.412 +
   1.413 +EXPORT_C void RFileLogger::Write(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC16& aText)
   1.414 +/**
   1.415 + * Static write. Write 16-bit aText to the log file if it is a valid file.
   1.416 + * @internalTechnology 
   1.417 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.418 +         as an enabled logging client, otherwise no logging will occur.
   1.419 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.420 + * @param aComponent specifies the tag2 name that goes into the log file
   1.421 + * @param aMode not used
   1.422 + * @param aText Text to write
   1.423 + * @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
   1.424 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.425 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.426 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.427 + */
   1.428 +	{
   1.429 +	// truncate tags
   1.430 +	TPtrC8 validSubsystem;
   1.431 +	TPtrC8 validComponent;
   1.432 +			
   1.433 +	validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
   1.434 +	validComponent.Set(aComponent.Left(KMaxTagLength));
   1.435 +
   1.436 +	TBuf8<KLogBufferSize> buf;
   1.437 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(buf,aText);
   1.438 +
   1.439 +	DoStaticWrite(validSubsystem, validComponent, buf);
   1.440 +	}
   1.441 +
   1.442 +EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC16> aFmt,...)
   1.443 +/**
   1.444 + * Static write. Write the formatted 16-bit string aFmt to the log file.
   1.445 + * @internalTechnology 
   1.446 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.447 +        as an enabled logging client, otherwise no logging will occur.
   1.448 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.449 + * @param aComponent specifies the tag2 name that goes into the log file
   1.450 + * @param aFmt c-style format descriptor, followed by any variables required by the format.
   1.451 + * @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
   1.452 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.453 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.454 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.455 + */
   1.456 +	{
   1.457 +	//coverity[var_decl]
   1.458 +	VA_LIST list;
   1.459 +	VA_START(list,aFmt);
   1.460 +	
   1.461 +	// truncate tags
   1.462 +	TPtrC8 validSubsystem;
   1.463 +	TPtrC8 validComponent;
   1.464 +		
   1.465 +	validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
   1.466 +	validComponent.Set(aComponent.Left(KMaxTagLength));
   1.467 +	//coverity[uninit_use_in_call]
   1.468 +	DoStaticWriteFormat(validSubsystem,validComponent,aFmt,list);
   1.469 +	}
   1.470 +
   1.471 +EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
   1.472 +/**
   1.473 + * Static write. Write the formatted 16-bit string aFmt to the log file.
   1.474 + * @internalTechnology 
   1.475 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.476 +        as an enabled logging client, otherwise no logging will occur.
   1.477 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.478 + * @param aComponent specifies the tag2 name that goes into the log file
   1.479 + * @param aFmt c-style format descriptor
   1.480 + * @param aList any variables required by the format.
   1.481 + * @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
   1.482 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.483 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.484 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.485 + */
   1.486 +	{
   1.487 +	// truncate tags
   1.488 +	TPtrC8 validSubsystem;
   1.489 +	TPtrC8 validComponent;
   1.490 +		
   1.491 +	validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
   1.492 +	validComponent.Set(aComponent.Left(KMaxTagLength));
   1.493 +	
   1.494 +	DoStaticWriteFormat(validSubsystem,validComponent,aFmt,aList);
   1.495 +	}
   1.496 +
   1.497 +//
   1.498 +// 8-bit static writes
   1.499 +//
   1.500 +
   1.501 +EXPORT_C void RFileLogger::Write(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aText)
   1.502 +/**
   1.503 + * Static write. Write 8-bit aText to the log file.
   1.504 + * @internalTechnology 
   1.505 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.506 +        as an enabled logging client, otherwise no logging will occur.
   1.507 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.508 + * @param aComponent specifies the tag2 name that goes into the log file
   1.509 + * @param aText  Text to log.
   1.510 + * @post The text is truncated to KLogBufferSize if necessary.
   1.511 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.512 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.513 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.514 + */
   1.515 +	{
   1.516 +	// truncate tags
   1.517 +	TPtrC8 validSubsystem;
   1.518 +	TPtrC8 validComponent;
   1.519 +			
   1.520 +	validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
   1.521 +	validComponent.Set(aComponent.Left(KMaxTagLength));
   1.522 +	DoStaticWrite(validSubsystem,validComponent, aText);
   1.523 +	}
   1.524 +
   1.525 +EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC8> aFmt,...)
   1.526 +/**
   1.527 + * Static write. Write the formatted 8-bit string aFmt to the log file.
   1.528 + * @internalTechnology 
   1.529 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.530 +        as an enabled logging client, otherwise no logging will occur.
   1.531 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.532 + * @param aComponent specifies the tag2 name that goes into the log file
   1.533 + * @param aFmt c-style format descriptor, followed by any variables required by the format.
   1.534 + * @post The text is truncated to KLogBufferSize if necessary.
   1.535 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.536 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.537 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.538 + */
   1.539 +
   1.540 +	{
   1.541 +	//coverity[var_decl]
   1.542 +	VA_LIST list;
   1.543 +	VA_START(list,aFmt);
   1.544 +	
   1.545 +	// truncate tags
   1.546 +	TPtrC8 validSubsystem;
   1.547 +	TPtrC8 validComponent;
   1.548 +		
   1.549 +	validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
   1.550 +	validComponent.Set(aComponent.Left(KMaxTagLength));
   1.551 +	//coverity[uninit_use_in_call]
   1.552 +	DoStaticWriteFormat(validSubsystem,validComponent,aFmt,list);
   1.553 +	}
   1.554 +
   1.555 +EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
   1.556 +/**
   1.557 + * Static write. Write the formatted 16-bit string aFmt to the log file.
   1.558 + * @internalTechnology 
   1.559 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.560 +        as an enabled logging client, otherwise no logging will occur.
   1.561 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.562 + * @param aComponent specifies the tag2 name that goes into the log file
   1.563 + * @param aFmt c-style format descriptor
   1.564 + * @param aList any variables required by the format.
   1.565 + * @post The text is truncated to KLogBufferSize if necessary.
   1.566 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.567 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.568 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.569 + */
   1.570 +	{
   1.571 +	//truncate tags
   1.572 +	TPtrC8 validSubsystem;
   1.573 +	TPtrC8 validComponent;
   1.574 +		
   1.575 +	validSubsystem.Set(aSubsystem.Left(KMaxTagLength));
   1.576 +	validComponent.Set(aComponent.Left(KMaxTagLength));
   1.577 +		
   1.578 +	DoStaticWriteFormat(validSubsystem,validComponent,aFmt,aList);
   1.579 +	}
   1.580 +
   1.581 +
   1.582 +
   1.583 +
   1.584 +
   1.585 +
   1.586 +//
   1.587 +// Removed 16-bit static writes
   1.588 +//
   1.589 +
   1.590 +EXPORT_C void RFileLogger::Write(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, const TDesC16& aText)
   1.591 +/**
   1.592 + * Static write. Write 16-bit aText to the log file if it is a valid file.
   1.593 + * @internalTechnology 
   1.594 + * @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
   1.595 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.596 +        as an enabled logging client, otherwise no logging will occur.
   1.597 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.598 + * @param aComponent specifies the tag2 name that goes into the log file
   1.599 + * @param aMode not used
   1.600 + * @param aText Text to write
   1.601 + * @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
   1.602 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.603 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.604 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.605 + */
   1.606 +	{
   1.607 +	// the convert also truncates if necessary	
   1.608 +	TNameTag narrowComponent;
   1.609 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
   1.610 +	TNameTag narrowSubsystem;
   1.611 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
   1.612 +
   1.613 +	Write(narrowSubsystem, narrowComponent, aText);
   1.614 +	}
   1.615 +
   1.616 +EXPORT_C void RFileLogger::WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode aMode, TRefByValue<const TDesC16> aFmt,...)
   1.617 +/**
   1.618 + * Static write. Write the formatted 16-bit string aFmt to the log file.
   1.619 + * @internalTechnology 
   1.620 + * @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
   1.621 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.622 +        as an enabled logging client, otherwise no logging will occur.
   1.623 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.624 + * @param aComponent specifies the tag2 name that goes into the log file
   1.625 + * @param aMode not used
   1.626 + * @param aFmt c-style format descriptor, followed by any variables required by the format.
   1.627 + * @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
   1.628 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.629 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.630 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.631 + */
   1.632 +	{
   1.633 +	// Just to remove the warning otherwise this does nothing 
   1.634 +	if (aMode == EFileLoggingModeUnknown) { }
   1.635 +	//coverity[var_decl]
   1.636 +	VA_LIST list;
   1.637 +	VA_START(list,aFmt);
   1.638 +	
   1.639 +	// the convert also truncates if necessary	
   1.640 +	TNameTag narrowComponent;
   1.641 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
   1.642 +	TNameTag narrowSubsystem;
   1.643 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
   1.644 +	//coverity[uninit_use_in_call]
   1.645 +	DoStaticWriteFormat(narrowSubsystem, narrowComponent,aFmt,list);
   1.646 +	}
   1.647 +
   1.648 +EXPORT_C void RFileLogger::WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
   1.649 +/**
   1.650 + * Static write. Write the formatted 16-bit string aFmt to the log file.
   1.651 + * @internalTechnology 
   1.652 + * @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
   1.653 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.654 +        as an enabled logging client, otherwise no logging will occur.
   1.655 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.656 + * @param aComponent specifies the tag2 name that goes into the log file
   1.657 + * @param aMode not used
   1.658 + * @param aFmt c-style format descriptor
   1.659 + * @param aList any variables required by the format.
   1.660 + * @post The text is converted to 8-bit text before writing, and truncated to KLogBufferSize if necessary.
   1.661 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.662 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.663 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.664 + */
   1.665 +	{
   1.666 +	// the convert also truncates if necessary	
   1.667 +	TNameTag narrowComponent;
   1.668 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
   1.669 +	TNameTag narrowSubsystem;
   1.670 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
   1.671 +	
   1.672 +	DoStaticWriteFormat(narrowSubsystem, narrowComponent,aFmt,aList);
   1.673 +	}
   1.674 +
   1.675 +//
   1.676 +// Removed 8-bit static writes
   1.677 +//
   1.678 +
   1.679 +EXPORT_C void RFileLogger::Write(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, const TDesC8& aText)
   1.680 +/**
   1.681 + * Static write. Write 8-bit aText to the log file.
   1.682 + * @internalTechnology 
   1.683 + * @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
   1.684 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.685 +        as an enabled logging client, otherwise no logging will occur.
   1.686 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.687 + * @param aComponent specifies the tag2 name that goes into the log file
   1.688 + * @param aMode not used
   1.689 + * @param aText  Text to log.
   1.690 + * @post The text is truncated to KLogBufferSize if necessary.
   1.691 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.692 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.693 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.694 + */
   1.695 +	{
   1.696 +	// the convert also truncates if necessary
   1.697 +	TNameTag narrowComponent;
   1.698 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
   1.699 +	TNameTag narrowSubsystem;
   1.700 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
   1.701 +	
   1.702 +	Write(narrowSubsystem, narrowComponent, aText);
   1.703 +	}
   1.704 +
   1.705 +EXPORT_C void RFileLogger::WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode aMode, TRefByValue<const TDesC8> aFmt,...)
   1.706 +/**
   1.707 + * Static write. Write the formatted 8-bit string aFmt to the log file.
   1.708 + * @internalTechnology 
   1.709 + * @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
   1.710 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.711 +        as an enabled logging client, otherwise no logging will occur.
   1.712 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.713 + * @param aComponent specifies the tag2 name that goes into the log file
   1.714 + * @param aMode not used
   1.715 + * @param aFmt c-style format descriptor, followed by any variables required by the format.
   1.716 + * @post The text is truncated to KLogBufferSize if necessary.
   1.717 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.718 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.719 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.720 + */
   1.721 +
   1.722 +	{
   1.723 +	// Just to remove the warning otherwise this does nothing 
   1.724 +	if (aMode == EFileLoggingModeUnknown) { }
   1.725 +	//coverity[var_decl]
   1.726 +	VA_LIST list;
   1.727 +	VA_START(list,aFmt);
   1.728 +	
   1.729 +	// the convert also truncates if necessary	
   1.730 +	TNameTag narrowComponent;
   1.731 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
   1.732 +	TNameTag narrowSubsystem;
   1.733 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
   1.734 +	//coverity[uninit_use_in_call]
   1.735 +	DoStaticWriteFormat(narrowSubsystem, narrowComponent, aFmt, list);
   1.736 +	}
   1.737 +
   1.738 +EXPORT_C void RFileLogger::WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
   1.739 +/**
   1.740 + * Static write. Write the formatted 16-bit string aFmt to the log file.
   1.741 + * @internalTechnology 
   1.742 + * @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
   1.743 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.744 +        as an enabled logging client, otherwise no logging will occur.
   1.745 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.746 + * @param aComponent specifies the tag2 name that goes into the log file
   1.747 + * @param aMode not used
   1.748 + * @param aFmt c-style format descriptor
   1.749 + * @param aList any variables required by the format.
   1.750 + * @post The text is truncated to KLogBufferSize if necessary.
   1.751 + *       The text is preceded in the log file by the two client tags and the client thread ID.
   1.752 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.753 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.754 + */
   1.755 +	{
   1.756 +	// the convert also truncates if necessary	
   1.757 +	TNameTag narrowComponent;
   1.758 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
   1.759 +	TNameTag narrowSubsystem;
   1.760 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
   1.761 +	
   1.762 +	DoStaticWriteFormat(narrowSubsystem, narrowComponent,aFmt,aList);
   1.763 +	}
   1.764 +
   1.765 +//
   1.766 +// Hex Dumps
   1.767 +//
   1.768 +
   1.769 +EXPORT_C void RFileLogger::HexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen)
   1.770 +/**
   1.771 + * Dump arbitrary data to the log file as a standard hex dump.
   1.772 + * @internalTechnology 
   1.773 + * @pre   The session with the server must be active, otherwise this no action is taken.
   1.774 +         The client requesting to log must be listed in the flogger "ini" file
   1.775 +        as an enabled logging client, otherwise no logging will occur.
   1.776 + * @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.
   1.777 + * @param aMargin Specify a zero-terminated string to be printed before each subsequent line. Leave as null or an empty string for no Margin.
   1.778 + * @param aPtr pointer to the data being dumped.
   1.779 + * @param aLen the number of bytes to dump
   1.780 + * @post Each line is preceded in the log file by the two client tags and the client thread ID.
   1.781 + * @note Example of aHeader/aMargin. If "aHeader" is set to "Fn Output:" and "aMargin" is set to "         ", then output would look
   1.782 + *       like (for a print of the alphabet):
   1.783 + *       TLOG	Example	20	FnOutput:0000 : 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70  abcdefghijklmnop
   1.784 + *       TLOG	Example	20	         0010 : 71 72 73 74 75 76 77 78 79 7a                    qrstuvwxyz
   1.785 + *   
   1.786 + */
   1.787 +	{
   1.788 +	if (IsLogging())
   1.789 +		{
   1.790 +		DoHexDump(aHeader,aMargin,aPtr,aLen);
   1.791 +		}
   1.792 +
   1.793 +
   1.794 +	}
   1.795 +
   1.796 +
   1.797 +
   1.798 +EXPORT_C void RFileLogger::HexDump(const TDesC8& aData, const TDesC8& aHeader)
   1.799 +/**
   1.800 + * Dump arbitrary data to the log file as a standard hex dump.
   1.801 + * @internalTechnology 
   1.802 + * @pre   The session with the server must be active, otherwise this no action is taken.
   1.803 +          The client requesting to log must be listed in the flogger "ini" file
   1.804 +        as an enabled logging client, otherwise no logging will occur.
   1.805 + * @param aData the data being dumped.
   1.806 + * @param aHeader Specify a string to be printed before the first hex line. If not supplied, no header or margin is written.
   1.807 + *        If supplied, then subsequent lines are indented to the length of aHeader.
   1.808 + * @post Each line is preceded in the log file by the two client tags and the client thread ID.
   1.809 + * @note Example of aHeader. If "aHeader" is set to "Fn Output:" then output would look
   1.810 + *       like (for a print of the alphabet):
   1.811 + *       TLOG	Example	20	FnOutput:0000 : 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70  abcdefghijklmnop
   1.812 + *       TLOG	Example	20	         0010 : 71 72 73 74 75 76 77 78 79 7a                    qrstuvwxyz
   1.813 + *   
   1.814 + */
   1.815 +	{
   1.816 +	if (IsLogging())
   1.817 +		{
   1.818 +		DoHexDump(aData,aHeader,TPtrC8(NULL,0));
   1.819 +		}
   1.820 +
   1.821 +
   1.822 +	}
   1.823 +
   1.824 +
   1.825 +
   1.826 +
   1.827 +
   1.828 +
   1.829 +EXPORT_C void RFileLogger::HexDump(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aData, const TDesC8& aHeader)
   1.830 +/**
   1.831 + * Static Write. Dump arbitrary data to the log file as a standard hex dump.
   1.832 + * @internalTechnology 
   1.833 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.834 +        as an enabled logging client, otherwise no logging will occur.
   1.835 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.836 + * @param aComponent specifies the tag2 name that goes into the log file
   1.837 + * @param aData the data being dumped.
   1.838 + * @param aHeader Specify a string to be printed before the first hex line. If not supplied, no header or Margin is written.
   1.839 + * @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.
   1.840 + * @post Each line is preceded in the log file by the two client tags and the client thread ID.
   1.841 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.842 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.843 + *       Example of aHeader/aMargin. If "aHeader" is set to "Fn Output:" and "aMargin" is set to "         ", then output would look
   1.844 + *       like (for a print of the alphabet):
   1.845 + *       TLOG	Example	20	FnOutput:0000 : 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70  abcdefghijklmnop
   1.846 + *       TLOG	Example	20	         0010 : 71 72 73 74 75 76 77 78 79 7a                    qrstuvwxyz
   1.847 + *   
   1.848 + */
   1.849 +	{
   1.850 +	RFileLogger logger;
   1.851 +	TInt ret=logger.Connect();
   1.852 +	if (ret==KErrNone)
   1.853 +		{
   1.854 +		ret = logger.SetLogTags(aSubsystem,aComponent);
   1.855 +		if (((ret == KErrNone) && logger.iLoggerBody) && logger.iLoggerBody->iLoggingOnPckg())
   1.856 +			{
   1.857 +			logger.DoHexDump(aData,aHeader,TPtrC8(NULL,0));
   1.858 +			}
   1.859 +		logger.Close();
   1.860 +		}
   1.861 +	}
   1.862 +
   1.863 +
   1.864 +
   1.865 +
   1.866 +
   1.867 +EXPORT_C void RFileLogger::HexDump(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen)
   1.868 +/**
   1.869 + * Static Write. Dump arbitrary data to the log file as a standard hex dump.
   1.870 + * @internalTechnology 
   1.871 + * @removed With the advent of a single log file for all clients, this function has been replaced by an equivalent without the aMode parameter.
   1.872 +   @pre The client requesting to log must be listed in the flogger "ini" file
   1.873 +        as an enabled logging client, otherwise no logging will occur.
   1.874 + * @param aSubsystem Specifies the tag1 name that goes into the log file
   1.875 + * @param aComponent specifies the tag2 name that goes into the log file
   1.876 + * @param aMode not used
   1.877 + * @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.
   1.878 + * @param aMargin Specify a zero-terminated string to be printed before each subsequent line. Leave as null or an empty string for no Margin.
   1.879 + * @param aPtr pointer to the data being dumped.
   1.880 + * @param aLen the number of bytes to dump
   1.881 + * @post Each line is preceded in the log file by the two client tags and the client thread ID.
   1.882 + *       "aSubsystem" and "aComponent" are each truncated to KMaxTagLength.
   1.883 + * @note This function has poor performance since it performs a full connection and disconnection to the flogger server.
   1.884 + *       Example of aHeader/aMargin. If "aHeader" is set to "Fn Output:" and "aMargin" is set to "         ", then output would look
   1.885 + *       like (for a print of the alphabet):
   1.886 + *       TLOG	Example	20	FnOutput:0000 : 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70  abcdefghijklmnop
   1.887 + *       TLOG	Example	20	         0010 : 71 72 73 74 75 76 77 78 79 7a                    qrstuvwxyz
   1.888 + *   
   1.889 + */
   1.890 +	{
   1.891 +	// the convert also truncates if necessary
   1.892 +	TNameTag narrowComponent;
   1.893 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowComponent,aComponent);
   1.894 +	TNameTag narrowSubsystem;
   1.895 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowSubsystem,aSubsystem);
   1.896 +	
   1.897 +	RFileLogger logger;
   1.898 +	TInt ret=logger.Connect();
   1.899 +	if (ret==KErrNone)
   1.900 +		{
   1.901 +		ret = logger.SetLogTags(narrowSubsystem,narrowComponent);
   1.902 +		if (((ret == KErrNone) && logger.iLoggerBody) && logger.iLoggerBody->iLoggingOnPckg())
   1.903 +			{
   1.904 +			logger.DoHexDump(aHeader,aMargin,aPtr,aLen);
   1.905 +			}
   1.906 +		logger.Close();
   1.907 +		}
   1.908 +
   1.909 +	}
   1.910 +
   1.911 +
   1.912 +EXPORT_C TInt RFileLogger::Handle() const
   1.913 +// Returns handle of session, or Null if no session.
   1.914 +	{
   1.915 +	if (iLoggerBody)
   1.916 +		{
   1.917 +		return iLoggerBody->Handle();
   1.918 +		}
   1.919 +	else
   1.920 +		{
   1.921 +		return 0;
   1.922 +		}
   1.923 +	}
   1.924 +
   1.925 +EXPORT_C TInt RFileLogger::Share() 
   1.926 +	{
   1.927 +	if (iLoggerBody)
   1.928 +		{
   1.929 +  		return iLoggerBody->ShareAuto();
   1.930 +		}
   1.931 +	return KErrSessionClosed;
   1.932 +	}
   1.933 +
   1.934 +
   1.935 +//
   1.936 +// Debug tools to check for memory leaks
   1.937 +//
   1.938 +
   1.939 +EXPORT_C void RFileLogger::__DbgShutDownServer()
   1.940 +/**
   1.941 + * Debugging Tool. Ask the flogger server to shutdown. Only valid in DEBUG builds.
   1.942 + * @internalTechnology 
   1.943 + */
   1.944 +	{
   1.945 +#ifdef _DEBUG
   1.946 +	if (iLoggerBody)
   1.947 +		(void)iLoggerBody->DoSendReceive(EShutDownServer);
   1.948 +#endif
   1.949 +	}
   1.950 +
   1.951 +EXPORT_C void RFileLogger::__DbgSetHeapFailure(TInt aFailAfter)
   1.952 +/**
   1.953 + * Debugging Tool. Ask the flogger server to set its heap failure. Only valid in DEBUG builds.
   1.954 + * @internalTechnology 
   1.955 + * @param aFailAfter The number of successful memory allocations which will occur before
   1.956 + *        a memory allocation is failed by the memory manager.
   1.957 + */
   1.958 +	{
   1.959 +#ifdef _DEBUG
   1.960 +	if (iLoggerBody)
   1.961 +		{
   1.962 +		(void)iLoggerBody->DoSendReceive(ESetHeapFailure, TIpcArgs(aFailAfter));
   1.963 +		}
   1.964 +#else
   1.965 +	(void)aFailAfter;
   1.966 +#endif
   1.967 +	}
   1.968 +
   1.969 +//
   1.970 +// Private functions
   1.971 +//
   1.972 +
   1.973 +TInt RFileLogger::DoConnect()
   1.974 +/**
   1.975 + * Connect to the flogger server
   1.976 + * @return TInt indicating success code (KErrNone) or an error code.
   1.977 + * @note: creates 1 slot: no asynchronous IPC so never need more than 1 reserved message slot.
   1.978 + @internalComponent
   1.979 + */
   1.980 +	{
   1.981 +	__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
   1.982 +	return iLoggerBody->DoCreateSession(KFLoggerServerName,Version(),KNumberMessageSlots);
   1.983 +	}
   1.984 +
   1.985 +TInt RFileLogger::DoSetLogTags(const TDesC8& aSubsystem, const TDesC8& aComponent)
   1.986 +/**
   1.987 + * Set the two tag strings that all further writes by this client will use to
   1.988 + * identify it in the log file.
   1.989 + * @param aSubsystem	Specifies the tag1 name that goes into the log file
   1.990 + * @param aComponent	specifies the tag2 name that goes into the log file
   1.991 + * @return TInt indicating success code (KErrNone), or (KErrNotFound) if
   1.992 +  the connection is not valid, or an error code from SendReceive.
   1.993 + * @note If an error occurs, the client connection will be silently closed to protect
   1.994 + *       the client.
   1.995 + */
   1.996 +	{
   1.997 +	TInt err(KErrNone);
   1.998 +	if (iLoggerBody)	//check that the connection was set up correctly
   1.999 +		{
  1.1000 +		err = iLoggerBody->DoSendReceive(ESetLogTag, TIpcArgs(&aSubsystem, &aComponent, &(iLoggerBody->iLoggingOnPckg)));
  1.1001 +		if (err !=KErrNone )
  1.1002 +			{	//Something went wrong. We need to protect the client because error can be ignored.
  1.1003 +			Close();
  1.1004 +			}
  1.1005 +		}
  1.1006 +	else
  1.1007 +		{
  1.1008 +		err = KErrNotFound;
  1.1009 +		}
  1.1010 +	return err;
  1.1011 +	}
  1.1012 +
  1.1013 +void RFileLogger::DoWrite(const TDesC8& aBuf)
  1.1014 +/**
  1.1015 + * Send to the flogger server the pre-formatted write string.
  1.1016 + * @internalTechnology 
  1.1017 + * @pre session is already open.
  1.1018 + * @param aBuf 8-bit text to be written. It must not exceed KLogBufferSize.
  1.1019 + */
  1.1020 +	{
  1.1021 +	__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
  1.1022 +	(void)iLoggerBody->DoSendReceive(EWriteToLog,TIpcArgs(&aBuf, aBuf.Length()));	
  1.1023 +	}
  1.1024 +
  1.1025 +void RFileLogger::DoWriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
  1.1026 +/**
  1.1027 + * Trim and convert format string before sending to the flogger server.
  1.1028 + * @pre session is already open.
  1.1029 + * @param aFmt c-style formatted text to be written.
  1.1030 + * @param aList any variables required by the format.
  1.1031 + * @post The final string is truncated to KLogBufferSize and converted to 8-bit.
  1.1032 + */
  1.1033 +	{
  1.1034 +	TBuf16<KLogBufferSize> wideBuf;
  1.1035 +	__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
  1.1036 +	wideBuf.AppendFormatList(aFmt, aList, &(iLoggerBody->iFlogOverflow16));
  1.1037 +	TBuf8<KLogBufferSize> narrowBuf;
  1.1038 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowBuf,wideBuf);
  1.1039 +	DoWrite(narrowBuf);
  1.1040 +	}
  1.1041 +
  1.1042 +void RFileLogger::DoWriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
  1.1043 +/**
  1.1044 + * Trim format string before sending to the flogger server.
  1.1045 + * @pre session is already open.
  1.1046 + * @param aFmt c-style formatted text to be written.
  1.1047 + * @param aList any variables required by the format.
  1.1048 + * @post The final string is truncated to KLogBufferSize.
  1.1049 + */
  1.1050 +	{
  1.1051 +	TBuf8<KLogBufferSize> buf;
  1.1052 +	__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
  1.1053 +	buf.AppendFormatList(aFmt,aList, &(iLoggerBody->iFlogOverflow8));
  1.1054 +	DoWrite(buf);
  1.1055 +	}
  1.1056 +	
  1.1057 +void RFileLogger::DoSendStaticWrite(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aText)
  1.1058 +/**
  1.1059 + * Send to the flogger server the pre-formatted write string.
  1.1060 + * @pre session is already open.
  1.1061 + *      aText is not longer than KLogBufferSize
  1.1062 + * @param aSubsystem Specifies the tag1 name that goes into the log file
  1.1063 + * @param aComponent specifies the tag2 name that goes into the log file
  1.1064 + * @param aText text to write
  1.1065 + * @post The text is only written if the tag1+tag2 combination is listed as an enabled client
  1.1066 + *       in the flogger "ini" file, otherwise no action is taken.
  1.1067 + *       The text is preceded in the log file by the two client tags and the client thread ID.
  1.1068 + */
  1.1069 +	{
  1.1070 +	__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
  1.1071 +	(void)iLoggerBody->DoSendReceive(EStaticWriteToLog,TIpcArgs(&aSubsystem, &aComponent, &aText, aText.Length()));		// ignore error
  1.1072 +	}	
  1.1073 +
  1.1074 +void RFileLogger::DoStaticWrite(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aText)
  1.1075 +/**
  1.1076 + * Send to the flogger server the pre-formatted write string.
  1.1077 + * @pre session is already open.
  1.1078 + *      aText is not longer than KLogBufferSize
  1.1079 + * @param aSubsystem Specifies the tag1 name that goes into the log file
  1.1080 + * @param aComponent specifies the tag2 name that goes into the log file
  1.1081 + * @param aText text to write
  1.1082 + * @post The text is only written if the tag1+tag2 combination is listed as an enabled client
  1.1083 + *       in the flogger "ini" file, otherwise no action is taken.
  1.1084 + *       The text is preceded in the log file by the two client tags and the client thread ID.
  1.1085 + */
  1.1086 +	{
  1.1087 +	RFileLogger logger;
  1.1088 +	TInt ret=logger.Connect();
  1.1089 +	if (ret==KErrNone)
  1.1090 +		{
  1.1091 +		TPtrC8 textValid;
  1.1092 +		textValid.Set(aText.Left(KLogBufferSize));
  1.1093 +
  1.1094 +		logger.DoSendStaticWrite(aSubsystem, aComponent, textValid);
  1.1095 +		}
  1.1096 +
  1.1097 +	logger.Close();
  1.1098 +	}	
  1.1099 +
  1.1100 +
  1.1101 +
  1.1102 +void RFileLogger::DoStaticWriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, TRefByValue<const TDesC> aFmt, VA_LIST& aList)
  1.1103 +/**
  1.1104 + * Send to the flogger server a format write string.
  1.1105 + * @param aSubsystem Specifies the tag1 name that goes into the log file
  1.1106 + * @param aComponent specifies the tag2 name that goes into the log file
  1.1107 + * @param aFmt c-style formatted text to be written.
  1.1108 + * @param aList any variables required by the format.
  1.1109 + * @post The text is only written if the tag1+tag2 combination is listed as an enabled client
  1.1110 + *       in the flogger "ini" file, otherwise no action is taken.
  1.1111 + *       If necessary, the final string is truncated to KLogBufferSize.
  1.1112 + *       The final string is converted to an 8-bit string.
  1.1113 + *       The text is preceded in the log file by the two client tags and the client thread ID.
  1.1114 + */
  1.1115 +	{
  1.1116 +	TFlogOverflow16 objFlogBody16;
  1.1117 +	TBuf<KLogBufferSize> wideBuf;
  1.1118 +	TBuf8<KLogBufferSize> narrowBuf;
  1.1119 +
  1.1120 +    wideBuf.AppendFormatList(aFmt, aList, &objFlogBody16);
  1.1121 +	CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowBuf,wideBuf);
  1.1122 +		
  1.1123 +    DoStaticWrite(aSubsystem, aComponent, narrowBuf);
  1.1124 +	}
  1.1125 +
  1.1126 +void RFileLogger::DoStaticWriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
  1.1127 +/**
  1.1128 + * Send to the flogger server a format write string.
  1.1129 + * @param aSubsystem Specifies the tag1 name that goes into the log file
  1.1130 + * @param aComponent specifies the tag2 name that goes into the log file
  1.1131 + * @param aFmt c-style formatted text to be written.
  1.1132 + * @param aList any variables required by the format.
  1.1133 + * @post The text is only written if the tag1+tag2 combination is listed as an enabled client
  1.1134 + *       in the flogger "ini" file, otherwise no action is taken.
  1.1135 + *       If necessary, the final string is truncated to KLogBufferSize.
  1.1136 + *       The text is preceded in the log file by the two client tags and the client thread ID.
  1.1137 + */	{
  1.1138 +	TFlogOverflow8 objFlogBody8;
  1.1139 +	TBuf8<KLogBufferSize> buf;
  1.1140 +	buf.AppendFormatList(aFmt, aList, &objFlogBody8);
  1.1141 +	
  1.1142 +    DoStaticWrite(aSubsystem, aComponent, buf);
  1.1143 +	}
  1.1144 +
  1.1145 +void RFileLogger::DoHexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen)
  1.1146 +/**
  1.1147 + * Static Write. Dump arbitrary data to the log file as a standard hex dump.
  1.1148 + * @pre session is already open.
  1.1149 + * @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.
  1.1150 + * @param aMargin Specify a zero-terminated string to be printed before each subsequent line. Leave as null or an empty string for no Margin.
  1.1151 + * @param aPtr pointer to the data being dumped.
  1.1152 + * @param aLen the number of bytes to dump
  1.1153 + * @post The text is only written if the tag1+tag2 combination is listed as an enabled client
  1.1154 + *       in the flogger "ini" file, otherwise no action is taken.
  1.1155 + *       Each line is preceded in the log file by the two client tags and the client thread ID.
  1.1156 + *       The data is written in lines of 16 characters.
  1.1157 + * @note Example of aHeader/aMargin. If "aHeader" is set to "Fn Output:" and "aMargin" is set to "         ", then output would look
  1.1158 + *       like (for a print of the alphabet):
  1.1159 + *       TLOG	Example	20	FnOutput:0000 : 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70  abcdefghijklmnop
  1.1160 + *       TLOG	Example	20	         0010 : 71 72 73 74 75 76 77 78 79 7a                    qrstuvwxyz
  1.1161 + *   
  1.1162 + */
  1.1163 +	{
  1.1164 +	// this delightful art-deco code lifted straight from old flogger
  1.1165 +	if (aPtr==NULL)		// nothing to do
  1.1166 +		{
  1.1167 +		return;
  1.1168 +		}
  1.1169 +
  1.1170 +	TBuf<KMaxHexDumpWidth> buf;
  1.1171 +	TBuf8<KMaxHexDumpWidth> temp;
  1.1172 +
  1.1173 +
  1.1174 +	TInt i=0;
  1.1175 +	const TText* p=aHeader;
  1.1176 +	while (aLen>0)
  1.1177 +		{
  1.1178 +		if (p==NULL)
  1.1179 +			{
  1.1180 +			p=BLANK;	// if NULL set p to a blank string
  1.1181 +			}
  1.1182 +		TInt n=(aLen>KHexDumpWidth ? KHexDumpWidth : aLen);
  1.1183 +		__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
  1.1184 +		buf.AppendFormat(KFirstFormatString,&(iLoggerBody->iFlogOverflow16),p,i);
  1.1185 +		TInt j;
  1.1186 +		for (j=0; j<n; j++)
  1.1187 +			{
  1.1188 +			buf.AppendFormat(KSecondFormatString,aPtr[i+j]);
  1.1189 +			}
  1.1190 +		while (j++<KHexDumpWidth)
  1.1191 +			{
  1.1192 +			buf.Append(KThreeSpaces);
  1.1193 +			}
  1.1194 +		buf.Append(KTwoSpaces);
  1.1195 +		for (j=0; j<n; j++)
  1.1196 +			{
  1.1197 +			buf.AppendFormat(KThirdFormatString,(aPtr[i+j]<KLowestPrintableCharacter || aPtr[i+j]>KHighestPrintableCharacter) ? KFullStopChar : aPtr[i+j]);
  1.1198 +			}
  1.1199 +		
  1.1200 +		CnvUtfConverter::ConvertFromUnicodeToUtf8(temp,buf);
  1.1201 +		DoWrite(temp);
  1.1202 +		
  1.1203 +		buf.SetLength(0);
  1.1204 +		temp.SetLength(0);
  1.1205 +		aLen-=n;
  1.1206 +		i+=n;
  1.1207 +		p=aMargin;
  1.1208 +		}
  1.1209 +	}
  1.1210 +
  1.1211 +
  1.1212 +
  1.1213 +void RFileLogger::DoHexDump(const TDesC8& aData, const TDesC8& aHeader, const TDesC8& aMargin)
  1.1214 +/**
  1.1215 + * Static Write. Dump arbitrary data to the log file as a standard hex dump.
  1.1216 + * @see RFileLogger::HexDump(const TDesC8& aData, const TDesC8& aHeader = 0)
  1.1217 + * @param aMargin - supply a margin - if left null, then a margin of spaces of equal length to "aHeader"
  1.1218 + *                  is used.
  1.1219 + * @pre session is already open.
  1.1220 + */
  1.1221 +	{
  1.1222 +	HBufC8* marginStr = NULL;
  1.1223 +	TBuf8<KMaxHexDumpWidth> buf;
  1.1224 +	TInt aRemainingLen = aData.Length();
  1.1225 +	TInt aHeaderLen = aHeader.Length();
  1.1226 +	
  1.1227 +	__ASSERT_ALWAYS(iLoggerBody,User::Panic(KFloggerPanic, EInternalConsistencyFault));
  1.1228 +	
  1.1229 +	if (aData.Length()==0)		// nothing to do
  1.1230 +		{
  1.1231 +		return;
  1.1232 +		}
  1.1233 +
  1.1234 +
  1.1235 +	if (aHeaderLen > 0)
  1.1236 +		{
  1.1237 +		
  1.1238 +		if (aMargin.Length() == 0)
  1.1239 +			{
  1.1240 +			marginStr = HBufC8::New(aHeader.Length());
  1.1241 +			if (marginStr == NULL)
  1.1242 +				{
  1.1243 +				return;		// abort if No memory
  1.1244 +				}
  1.1245 +			TPtr8 marginStrPtr(marginStr->Des());
  1.1246 +			marginStrPtr.AppendFill(' ',aHeader.Length());
  1.1247 +			}
  1.1248 +		else
  1.1249 +			{
  1.1250 +			marginStr = aMargin.Alloc();
  1.1251 +			}
  1.1252 +		}
  1.1253 +		
  1.1254 +		
  1.1255 +	
  1.1256 +	TUint blockStartPos = 0;
  1.1257 +	while (aRemainingLen>0)
  1.1258 +		{
  1.1259 +		TInt blockLength = (aRemainingLen>KHexDumpWidth ? KHexDumpWidth : aRemainingLen);
  1.1260 +		
  1.1261 +		// write the header/margin and print in hex which bytes we are about to write
  1.1262 +		if (blockStartPos == 0)
  1.1263 +			{
  1.1264 +			if (aHeaderLen > 0)
  1.1265 +				{
  1.1266 +				buf.Append(aHeader);
  1.1267 +				}
  1.1268 +			buf.AppendFormat(KFirstFormatString8,&(iLoggerBody->iFlogOverflow8), blockStartPos);
  1.1269 +			}
  1.1270 +		else
  1.1271 +			{
  1.1272 +			if (marginStr)
  1.1273 +				{
  1.1274 +				buf.Append(*marginStr);
  1.1275 +				}
  1.1276 +			buf.AppendFormat(KFirstFormatString8,&(iLoggerBody->iFlogOverflow8),blockStartPos);
  1.1277 +			}
  1.1278 +		
  1.1279 +		TInt bytePos;
  1.1280 +		// write the bytes as hex
  1.1281 +		for (bytePos = 0; bytePos < blockLength; bytePos++)
  1.1282 +			{
  1.1283 +			buf.AppendFormat(KSecondFormatString8,aData[blockStartPos + bytePos]);
  1.1284 +			}
  1.1285 +		while (bytePos++ < KHexDumpWidth)
  1.1286 +			{
  1.1287 +			buf.Append(KThreeSpaces8);
  1.1288 +			}
  1.1289 +		buf.Append(KTwoSpaces8);
  1.1290 +		// print the bytes as characters, or full stops if outside printable range
  1.1291 +		for (bytePos = 0; bytePos < blockLength; bytePos++)
  1.1292 +			{
  1.1293 +			buf.AppendFormat(KThirdFormatString8,(aData[blockStartPos + bytePos] < KLowestPrintableCharacter || aData[blockStartPos + bytePos] > KHighestPrintableCharacter) ? KFullStopChar8 : aData[blockStartPos + bytePos]);
  1.1294 +			}
  1.1295 +		
  1.1296 +		DoWrite(buf);
  1.1297 +		
  1.1298 +		buf.SetLength(0);
  1.1299 +		aRemainingLen -= blockLength;
  1.1300 +		blockStartPos += blockLength;
  1.1301 +		}
  1.1302 +	delete marginStr;
  1.1303 +	}
  1.1304 +
  1.1305 +
  1.1306 +
  1.1307 +EXPORT_C void ClientRunStubOrdinal1()
  1.1308 +/**
  1.1309 + * @removed This function has been removed because the flogsvrl dll contains the equivalent function
  1.1310 +@internalComponent
  1.1311 + */
  1.1312 +	{User::Panic(KFloggerPanic, KErrNotSupported);}
  1.1313 +