tsrc/testtools/usbman_stub/logger/src/usblogger.cpp
branchRCL_3
changeset 92 dde4619868dc
parent 86 703a2b94c06c
child 95 55a3258355ea
equal deleted inserted replaced
86:703a2b94c06c 92:dde4619868dc
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Logging engine for USB.
       
    16 *
       
    17 */
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22 */
       
    23 
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <comms-infras/commsdebugutility.h>
       
    27 #include <usb/usblogger.h>
       
    28 
       
    29 
       
    30 #ifdef __USB_DEBUG_RDEBUG__
       
    31 #include <e32debug.h>
       
    32 const TInt KUSBLogBufferSize=255;
       
    33 class TUSBFlogOverflow8  : public TDes8Overflow
       
    34      {
       
    35 public:
       
    36      void Overflow(TDes8& /*aDes*/) { }
       
    37      };
       
    38 
       
    39 class TUSBFlogOverflow16  : public TDes16Overflow
       
    40      {
       
    41 public:
       
    42      void Overflow(TDes16& /*aDes*/) { }
       
    43      };
       
    44 void __CUsbLog_DoHexDump(const TDesC8& aCmpt, const TDesC8& aData, const TDesC8& aHeader, const TDesC8& aMargin);
       
    45 #endif //__USB_DEBUG_RDEBUG__
       
    46 
       
    47 
       
    48 
       
    49 
       
    50 #ifdef __FLOG_ACTIVE
       
    51 _LIT8(KSubsystem, "USB");
       
    52 _LIT8(KLogCmpt, "logengine");
       
    53 #endif
       
    54 
       
    55 
       
    56 NONSHARABLE_CLASS(TLogData)
       
    57 	{
       
    58 	public:
       
    59 #ifdef __FLOG_ACTIVE
       
    60 		TLogData();
       
    61 
       
    62 		void SetLogTags(const TDesC8& aCmpt);
       
    63 
       
    64 		TInt iAccessCount;
       
    65 
       
    66 		RFileLogger iLogEngine;
       
    67 		TBuf8<KMaxTagLength> iCurrentComponent;
       
    68 #endif
       
    69 	};
       
    70 
       
    71 
       
    72 #ifdef __FLOG_ACTIVE
       
    73 TLogData::TLogData()
       
    74 	: iAccessCount(0), iCurrentComponent(KNullDesC8)
       
    75 	{}
       
    76 
       
    77 void TLogData::SetLogTags(const TDesC8& aCmpt)
       
    78 	{
       
    79 	if (aCmpt != iCurrentComponent)
       
    80 		{
       
    81 		iLogEngine.SetLogTags(KSubsystem, aCmpt.Left(KMaxTagLength));
       
    82 		iCurrentComponent = aCmpt.Left(KMaxTagLength);
       
    83 		}
       
    84 	}
       
    85 #endif
       
    86 
       
    87 #define GETLOG TLogData* __logger = static_cast<TLogData*>(Dll::Tls());
       
    88 
       
    89 
       
    90 
       
    91 EXPORT_C /*static*/ TInt CUsbLog::Connect()
       
    92 	{
       
    93 #ifdef __FLOG_ACTIVE
       
    94 	GETLOG;
       
    95 
       
    96 	if (!__logger)
       
    97 		{
       
    98 
       
    99 		CUsbLog::Write(KLogCmpt, _L8("Opening new logger connection"));
       
   100 		__logger = new TLogData();
       
   101 		if (!__logger)
       
   102 			{
       
   103 			CUsbLog::Write(KLogCmpt, _L8("Opening logger connection failed, no memory"));
       
   104 			return KErrNoMemory;
       
   105 			}
       
   106 
       
   107 		__logger->iLogEngine.Connect();
       
   108 		Dll::SetTls(__logger);
       
   109 		}
       
   110 
       
   111 	__logger->iAccessCount++;
       
   112 	CUsbLog::WriteFormat(KLogCmpt, _L8("Opening -- %d instances now open"), __logger->iAccessCount);
       
   113 
       
   114 	return KErrNone;
       
   115 #else
       
   116 	return KErrNotSupported;
       
   117 #endif
       
   118 	}
       
   119 
       
   120 
       
   121 EXPORT_C /*static*/ void CUsbLog::Close()
       
   122 	{
       
   123 #ifdef __FLOG_ACTIVE
       
   124 	GETLOG;
       
   125 
       
   126 	if (__logger)
       
   127 		{
       
   128 		TInt& count = __logger->iAccessCount;
       
   129 
       
   130 		if (count)
       
   131 			{
       
   132 			count--;
       
   133 			CUsbLog::WriteFormat(KLogCmpt, _L8("Closing -- %d instance(s) left open"), count);
       
   134 			if (!count)
       
   135 				{
       
   136 				__logger->iLogEngine.Close();
       
   137 				delete __logger;
       
   138 				Dll::SetTls(NULL);
       
   139 				CUsbLog::Write(KLogCmpt, _L8("Fully closed and deleted, now flogging statically."));
       
   140 				}
       
   141 			}
       
   142 		else
       
   143 			{
       
   144 			CUsbLog::Write(KLogCmpt, _L8("Not closing -- not opened"));
       
   145 			}
       
   146 		}
       
   147 #endif
       
   148 	}
       
   149 
       
   150 
       
   151 EXPORT_C /*static*/ void CUsbLog::Write(const TDesC8& IF_FLOGGING(aCmpt), const TDesC8& IF_FLOGGING(aText))
       
   152 	{
       
   153 #ifdef __FLOG_ACTIVE
       
   154 	GETLOG;
       
   155 
       
   156 #ifdef __USB_DEBUG_RDEBUG__
       
   157 		TBuf8<KUSBLogBufferSize> buf;
       
   158 		RThread thread;
       
   159 		buf.AppendFormat(_L8("%S\t%S\t%LX\t%S\r\n"), &KSubsystem(), &aCmpt, thread.Id().Id(), &aText);
       
   160 		RDebug::RawPrint(buf);
       
   161 #endif // __USB_DEBUG_RDEBUG
       
   162 
       
   163 	if (__logger)
       
   164 		{
       
   165 		__logger->SetLogTags(aCmpt);
       
   166 		__logger->iLogEngine.Write(aText);
       
   167 		}
       
   168 	else
       
   169 		{
       
   170 		RFileLogger::Write(KSubsystem, aCmpt, aText);
       
   171 		}
       
   172 #endif
       
   173 	}
       
   174 
       
   175 
       
   176 EXPORT_C /*static*/ void CUsbLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC8> IF_FLOGGING(aFmt), ...)
       
   177 	{
       
   178 #ifdef __FLOG_ACTIVE
       
   179 	VA_LIST list;
       
   180 	VA_START(list, aFmt);
       
   181 
       
   182 	GETLOG;
       
   183 
       
   184 #ifdef __USB_DEBUG_RDEBUG__
       
   185 		TUSBFlogOverflow8 objFlogBody8;
       
   186 		TBuf8<KUSBLogBufferSize> buf;
       
   187 		RThread thread;
       
   188 		buf.AppendFormat(_L8("%S\t%S\t%LX\t"), &KSubsystem(), &aCmpt, thread.Id().Id());
       
   189 		buf.AppendFormatList(aFmt, list, &objFlogBody8);
       
   190 		buf.Append(_L8("\r\n"));
       
   191 		RDebug::RawPrint(buf);
       
   192 #endif // __USB_DEBUG_RDEBUG
       
   193 
       
   194 	if (__logger)
       
   195 		{
       
   196 		__logger->SetLogTags(aCmpt);
       
   197 		__logger->iLogEngine.WriteFormat(aFmt, list);
       
   198 		}
       
   199 	else
       
   200 		{
       
   201 		RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, list);
       
   202 		}
       
   203 #endif
       
   204 	}
       
   205 
       
   206 
       
   207 EXPORT_C /*static*/ void CUsbLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC8> IF_FLOGGING(aFmt), VA_LIST& IF_FLOGGING(aList))
       
   208 	{
       
   209 #ifdef __FLOG_ACTIVE
       
   210 	GETLOG;
       
   211 
       
   212 #ifdef __USB_DEBUG_RDEBUG__
       
   213 		TUSBFlogOverflow8 objFlogBody8;
       
   214 		TBuf8<KUSBLogBufferSize> buf;
       
   215 		RThread thread;
       
   216 		buf.AppendFormat(_L8("%S\t%S\t%LX\t"), &KSubsystem(), &aCmpt, thread.Id().Id());
       
   217 		buf.AppendFormatList(aFmt, aList, &objFlogBody8);
       
   218 		buf.Append(_L8("\r\n"));
       
   219 		RDebug::RawPrint(buf);
       
   220 #endif // __USB_DEBUG_RDEBUG
       
   221 
       
   222 	if (__logger)
       
   223 		{
       
   224 		__logger->SetLogTags(aCmpt);
       
   225 		__logger->iLogEngine.WriteFormat(aFmt, aList);
       
   226 		}
       
   227 	else
       
   228 		{
       
   229 		RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, aList);
       
   230 		}
       
   231 #endif
       
   232 	}
       
   233 
       
   234 
       
   235 EXPORT_C /*static*/ void CUsbLog::Write(const TDesC8& IF_FLOGGING(aCmpt), const TDesC16& IF_FLOGGING(aText))
       
   236 	{
       
   237 #ifdef __FLOG_ACTIVE
       
   238 	GETLOG;
       
   239 
       
   240 #ifdef __USB_DEBUG_RDEBUG__
       
   241 		TBuf16<KUSBLogBufferSize> buf;
       
   242 		buf.AppendFormat(_L16("(TDesC16): %S\r\n"), &aText);
       
   243 		RDebug::RawPrint(buf);
       
   244 #endif // __USB_DEBUG_RDEBUG
       
   245 
       
   246 	if (__logger)
       
   247 		{
       
   248 		__logger->SetLogTags(aCmpt);
       
   249 		__logger->iLogEngine.Write(aText);
       
   250 		}
       
   251 	else
       
   252 		{
       
   253 		RFileLogger::WriteFormat(KSubsystem, aCmpt, aText);
       
   254 		}
       
   255 #endif
       
   256 	}
       
   257 
       
   258 
       
   259 EXPORT_C /*static*/ void CUsbLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC16> IF_FLOGGING(aFmt), ...)
       
   260 	{
       
   261 #ifdef __FLOG_ACTIVE
       
   262 	VA_LIST list;
       
   263 	VA_START(list, aFmt);
       
   264 
       
   265 	GETLOG;
       
   266 
       
   267 #ifdef __USB_DEBUG_RDEBUG__
       
   268 		TUSBFlogOverflow16 objFlogBody16;
       
   269 		TBuf16<KUSBLogBufferSize> wideBuf;
       
   270 		wideBuf.Append(_L16("(TDesC16): "));
       
   271 		wideBuf.AppendFormatList(aFmt, list, &objFlogBody16);
       
   272 		wideBuf.Append(_L16("\r\n"));
       
   273 		RDebug::RawPrint(wideBuf);
       
   274 #endif // __USB_DEBUG_RDEBUG
       
   275 
       
   276 	if (__logger)
       
   277 		{
       
   278 		__logger->SetLogTags(aCmpt);
       
   279 		__logger->iLogEngine.WriteFormat(aFmt, list);
       
   280 		}
       
   281 	else
       
   282 		{
       
   283 		RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, list);
       
   284 		}
       
   285 #endif
       
   286 	}
       
   287 
       
   288 
       
   289 EXPORT_C /*static*/ void CUsbLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC16> IF_FLOGGING(aFmt), VA_LIST& IF_FLOGGING(aList))
       
   290 	{
       
   291 #ifdef __FLOG_ACTIVE
       
   292 	GETLOG;
       
   293 
       
   294 #ifdef __USB_DEBUG_RDEBUG__
       
   295 		TUSBFlogOverflow16 objFlogBody16;
       
   296 		TBuf16<KUSBLogBufferSize> wideBuf;
       
   297 		wideBuf.Append(_L16("(TDesC16): "));
       
   298 		wideBuf.AppendFormatList(aFmt, aList, &objFlogBody16);
       
   299 		wideBuf.Append(_L16("\r\n"));
       
   300 		RDebug::RawPrint(wideBuf);
       
   301 #endif // __USB_DEBUG_RDEBUG
       
   302 
       
   303 	if (__logger)
       
   304 		{
       
   305 		__logger->SetLogTags(aCmpt);
       
   306 		__logger->iLogEngine.WriteFormat(aFmt, aList);
       
   307 		}
       
   308 	else
       
   309 		{
       
   310 		RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, aList);
       
   311 		}
       
   312 #endif
       
   313 	}
       
   314 
       
   315 
       
   316 EXPORT_C /*static*/ void CUsbLog::HexDump(const TDesC8& IF_FLOGGING(aCmpt), const TText* IF_FLOGGING(aHeader), const TText* IF_FLOGGING(aMargin), const TUint8* IF_FLOGGING(aPtr), TInt IF_FLOGGING(aLen))
       
   317 	{
       
   318 #ifdef __FLOG_ACTIVE
       
   319 	GETLOG;
       
   320 
       
   321 #ifdef __USB_DEBUG_RDEBUG__
       
   322 	__CUsbLog_DoHexDump(aCmpt, TPtrC8(aPtr, aLen), TPtrC8(NULL,0), TPtrC8(NULL,0));
       
   323 #endif // __USB_DEBUG_RDEBUG
       
   324 
       
   325 	if (__logger)
       
   326 		{
       
   327 		__logger->SetLogTags(aCmpt);
       
   328 		__logger->iLogEngine.HexDump(aHeader, aMargin, aPtr, aLen);
       
   329 		}
       
   330 	else
       
   331 		{
       
   332 		RFileLogger::HexDump(KSubsystem, aCmpt, TPtrC8(aPtr, aLen), KNullDesC8);
       
   333 		}
       
   334 #endif
       
   335 	}
       
   336 
       
   337 
       
   338 #ifdef __USB_DEBUG_RDEBUG__
       
   339 
       
   340 #define BLANK	_S("")
       
   341 const TInt KHexDumpWidth=16;			///< Number of bytes written per line when formatting as hex.
       
   342 const TInt KLowestPrintableCharacter = 32; ///< In Hex output, replace chars below space with a dot.
       
   343 const TInt KHighestPrintableCharacter = 126; ///< In Hex output, replace chars above 7-bits with a dot.
       
   344 
       
   345 _LIT8(KFirstFormatString8,"%04x : ");   ///< Format string used in Hexdump to format first part: header and byte numbers.
       
   346 _LIT8(KSecondFormatString8,"%02x ");      ///< Format string used in Hexdump to format mid part: each of the 16 bytes as hex
       
   347 _LIT8(KThirdFormatString8,"%c");          ///< Format string used in Hexdump to format the last part: each of the 16 bytes as characters
       
   348 _LIT8(KThreeSpaces8,"   ");               ///< Format string used in Hexdump to define padding between first and mid parts
       
   349 _LIT8(KTwoSpaces8," ");                   ///< Format string used in Hexdump to define padding between hex and char bytes.
       
   350 const TText8 KFullStopChar8='.';
       
   351 
       
   352 void __CUsbLog_DoHexDump(const TDesC8& aCmpt, const TDesC8& aData, const TDesC8& aHeader, const TDesC8& aMargin)
       
   353 	{
       
   354 #ifdef __FLOG_ACTIVE
       
   355 	HBufC8* marginStr = NULL;
       
   356 	TBuf8<KMaxHexDumpWidth> buf;
       
   357 	TInt aRemainingLen = aData.Length();
       
   358 	TInt aHeaderLen = aHeader.Length();
       
   359 	TUSBFlogOverflow8 objFlogBody8;
       
   360 
       
   361 	if (aData.Length()==0)		// nothing to do
       
   362 		{
       
   363 		return;
       
   364 		}
       
   365 
       
   366 
       
   367 	if (aHeaderLen > 0)
       
   368 		{
       
   369 
       
   370 		if (aMargin.Length() == 0)
       
   371 			{
       
   372 			marginStr = HBufC8::New(aHeader.Length());
       
   373 			if (marginStr == NULL)
       
   374 				{
       
   375 				return;		// abort if No memory
       
   376 				}
       
   377 			TPtr8 marginStrPtr(marginStr->Des());
       
   378 			marginStrPtr.AppendFill(' ',aHeader.Length());
       
   379 			}
       
   380 		else
       
   381 			{
       
   382 			marginStr = aMargin.Alloc();
       
   383 			}
       
   384 		}
       
   385 
       
   386 
       
   387 
       
   388 	TUint blockStartPos = 0;
       
   389 	while (aRemainingLen>0)
       
   390 		{
       
   391 		RThread thread;
       
   392 		buf.AppendFormat(_L8("%S\t%S\t%LX\t"), &KSubsystem(), &aCmpt, thread.Id().Id());
       
   393 		TInt blockLength = (aRemainingLen>KHexDumpWidth ? KHexDumpWidth : aRemainingLen);
       
   394 
       
   395 		// write the header/margin and print in hex which bytes we are about to write
       
   396 		if (blockStartPos == 0)
       
   397 			{
       
   398 			if (aHeaderLen > 0)
       
   399 				{
       
   400 				buf.Append(aHeader);
       
   401 				}
       
   402 			buf.AppendFormat(KFirstFormatString8,&objFlogBody8, blockStartPos);
       
   403 			}
       
   404 		else
       
   405 			{
       
   406 			if (marginStr)
       
   407 				{
       
   408 				buf.Append(*marginStr);
       
   409 				}
       
   410 			buf.AppendFormat(KFirstFormatString8,&objFlogBody8,blockStartPos);
       
   411 			}
       
   412 
       
   413 		TInt bytePos;
       
   414 		// write the bytes as hex
       
   415 		for (bytePos = 0; bytePos < blockLength; bytePos++)
       
   416 			{
       
   417 			buf.AppendFormat(KSecondFormatString8,aData[blockStartPos + bytePos]);
       
   418 			}
       
   419 		while (bytePos++ < KHexDumpWidth)
       
   420 			{
       
   421 			buf.Append(KThreeSpaces8);
       
   422 			}
       
   423 		buf.Append(KTwoSpaces8);
       
   424 		// print the bytes as characters, or full stops if outside printable range
       
   425 		for (bytePos = 0; bytePos < blockLength; bytePos++)
       
   426 			{
       
   427 			buf.AppendFormat(KThirdFormatString8,(aData[blockStartPos + bytePos] < KLowestPrintableCharacter || aData[blockStartPos + bytePos] > KHighestPrintableCharacter) ? KFullStopChar8 : aData[blockStartPos + bytePos]);
       
   428 			}
       
   429 
       
   430 		buf.Append(_L8("\r\n"));
       
   431 		RDebug::RawPrint(buf);
       
   432 
       
   433 		buf.SetLength(0);
       
   434 		aRemainingLen -= blockLength;
       
   435 		blockStartPos += blockLength;
       
   436 		}
       
   437 	delete marginStr;
       
   438 #endif // __FLOG_ACTIVE
       
   439 	}
       
   440 
       
   441 
       
   442 
       
   443 #endif // __USB_DEBUG_RDEBUG
       
   444 
       
   445 
       
   446 /**
       
   447 Leave (if error) verbosely- log name of file and line number just before
       
   448 leaving.
       
   449 @param aFile The file we're leaving from.
       
   450 @param aLine The line number we're leaving from.
       
   451 @param aReason The leave code.
       
   452 */
       
   453 EXPORT_C void VerboseLeaveIfErrorL(const TDesC8& IF_FLOGGING(aCpt),
       
   454 						  char* IF_FLOGGING(aFile),
       
   455 						  TInt IF_FLOGGING(aLine),
       
   456 						  TInt aReason)
       
   457 	{
       
   458 	// only leave negative value
       
   459 	if ( aReason >= 0 )
       
   460 		{
       
   461 		return;
       
   462 		}
       
   463 
       
   464 #ifdef __FLOG_ACTIVE
       
   465 	_LIT8(KLeavePrefix, "LEAVE: ");
       
   466 
       
   467 	TPtrC8 fullFileName((const TUint8*)aFile);
       
   468 	TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
       
   469 
       
   470 	TBuf8<256> buf;
       
   471 	buf.Append(KLeavePrefix);
       
   472 	buf.AppendFormat(_L8("aReason = %d [file %S, line %d]"), aReason, &fileName,
       
   473 		aLine);
       
   474 	CUsbLog::Write(aCpt, buf);
       
   475 #endif
       
   476 
       
   477 	// finally
       
   478 	User::Leave(aReason);
       
   479 	}
       
   480 
       
   481 /**
       
   482 Leave verbosely- log name of file and line number just before
       
   483 leaving.
       
   484 @param aFile The file we're leaving from.
       
   485 @param aLine The line number we're leaving from.
       
   486 @param aReason The leave code.
       
   487 */
       
   488 EXPORT_C void VerboseLeaveL(const TDesC8& IF_FLOGGING(aCpt),
       
   489 						  char* IF_FLOGGING(aFile),
       
   490 						  TInt IF_FLOGGING(aLine),
       
   491 						  TInt aReason)
       
   492 	{
       
   493 #ifdef __FLOG_ACTIVE
       
   494 	_LIT8(KLeavePrefix, "LEAVE: ");
       
   495 
       
   496 	TPtrC8 fullFileName((const TUint8*)aFile);
       
   497 	TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
       
   498 
       
   499 	TBuf8<256> buf;
       
   500 	buf.Append(KLeavePrefix);
       
   501 	buf.AppendFormat(_L8("aReason = %d [file %S, line %d]"), aReason, &fileName,
       
   502 		aLine);
       
   503 	CUsbLog::Write(aCpt, buf);
       
   504 #endif
       
   505 
       
   506 	// finally
       
   507 	User::Leave(aReason);
       
   508 	}
       
   509 
       
   510 /**
       
   511 Panic verbosely- log name of file and line number just before panicking.
       
   512 @param aFile The file that's panicking.
       
   513 @param aLine The line number that's panicking.
       
   514 @param aReason The panic code.
       
   515 @param aPanicName The text of the panic code.
       
   516 @param aPanicCategory The panic category.
       
   517 */
       
   518 EXPORT_C void VerbosePanic(const TDesC8& IF_FLOGGING(aCpt),
       
   519 				  char* IF_FLOGGING(aFile),
       
   520 				  TInt IF_FLOGGING(aLine),
       
   521 				  TInt aPanicCode,
       
   522 				  TText8* IF_FLOGGING(aPanicName),
       
   523 				  const TDesC& aPanicCategory)
       
   524 	{
       
   525 #ifdef __FLOG_ACTIVE
       
   526 	_LIT8(KPanicPrefix, "PANIC: code ");
       
   527 
       
   528 	TPtrC8 fullFileName((const TUint8*)aFile);
       
   529 	TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
       
   530 
       
   531 	TBuf8<256> buf;
       
   532 	buf.Append(KPanicPrefix);
       
   533 	buf.AppendFormat(_L8("%d = %s [file %S, line %d]"),
       
   534 		aPanicCode,
       
   535 		aPanicName,
       
   536 		&fileName,
       
   537 		aLine);
       
   538 	CUsbLog::Write(aCpt, buf);
       
   539 #endif
       
   540 
       
   541 	// finally
       
   542 	User::Panic(aPanicCategory, aPanicCode);
       
   543 	}
       
   544 
       
   545 
       
   546 /**
       
   547 Panic the given message verbosely- log name of file and line number just
       
   548 before panicking.
       
   549 @param aMsg Message to panic.
       
   550 @param aFile The file that's panicking.
       
   551 @param aLine The line number that's panicking.
       
   552 @param aReason The panic code.
       
   553 @param aPanicName The text of the panic code.
       
   554 @param aPanicCategory The panic category.
       
   555 */
       
   556 EXPORT_C void VerboseMsgPanic(const TDesC8& IF_FLOGGING(aCpt),
       
   557 								char* IF_FLOGGING(aFile),
       
   558 								TInt  IF_FLOGGING(aLine),
       
   559 								const RMessage2& aMsg,
       
   560 								const TDesC& aCat,
       
   561 								TInt  aPanicCode)
       
   562 	{
       
   563 #ifdef __FLOG_ACTIVE
       
   564 	_LIT8(KPanicPrefix, "PANICKING CLIENT: code ");
       
   565 
       
   566 	TPtrC8 fullFileName((const TUint8*)aFile);
       
   567 	TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
       
   568 
       
   569 	TBuf8<256> buf;
       
   570 	buf.Append(KPanicPrefix);
       
   571 	buf.AppendFormat(_L8("%d [file %S, line %d]"),
       
   572 		aPanicCode,
       
   573 		&fileName,
       
   574 		aLine);
       
   575 	CUsbLog::Write(aCpt, buf);
       
   576 #endif
       
   577 	// finally
       
   578 	aMsg.Panic(aCat, aPanicCode);
       
   579 	}
       
   580 
       
   581 #ifdef __FLOG_ACTIVE
       
   582 _LIT8(KInstrumentIn, ">>%S this = [0x%08x]");
       
   583 _LIT8(KInstrumentOut, "<<%S");
       
   584 #endif
       
   585 
       
   586 EXPORT_C TFunctionLogger::TFunctionLogger(const TDesC8& IF_FLOGGING(aCpt), const TDesC8& IF_FLOGGING(aString), TAny* IF_FLOGGING(aThis))
       
   587 	{
       
   588 #ifdef __FLOG_ACTIVE
       
   589 	iCpt.Set(aCpt);
       
   590 	iString.Set(aString);
       
   591 	CUsbLog::WriteFormat(iCpt, KInstrumentIn, &iString, aThis);
       
   592 #endif
       
   593 	}
       
   594 
       
   595 EXPORT_C TFunctionLogger::~TFunctionLogger()
       
   596 	{
       
   597 #ifdef __FLOG_ACTIVE
       
   598 	CUsbLog::WriteFormat(iCpt, KInstrumentOut, &iString);
       
   599 #endif
       
   600 	}
       
   601