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