usbservices_plat/usb_personality_plugin_api/tsrc/usbpersonalitypluginapitest/inc/UsbPersonalityPluginTestDebug.inl
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 *
       
    16 */
       
    17 
       
    18 #include <e32debug.h>
       
    19 
       
    20 NONSHARABLE_CLASS( TOverflowTruncate8 ) : public TDes8Overflow
       
    21     {
       
    22 public:
       
    23     void Overflow( TDes8& /*aDes*/ ) {}
       
    24     }; 
       
    25 
       
    26 NONSHARABLE_CLASS( TOverflowTruncate16 ) : public TDes16Overflow
       
    27     {
       
    28 public:
       
    29     void Overflow( TDes16& /*aDes*/ ) {}
       
    30     };
       
    31 
       
    32 _LIT8(KStifTestPrefix8, "[STIF_LOG] ");
       
    33 _LIT( KStifTestPrefix, "[STIF_LOG] ");
       
    34 _LIT8( KStifEntryPrefix8, ">>> %S" );
       
    35 _LIT8( KStifExitPrefix8, "<<< %S" );
       
    36 
       
    37 const TInt KMaxLogLineLength = 512;
       
    38 
       
    39 #define TRACE_INFO( p ) { Trace p; }
       
    40 #define TRACE_FUNC_ENTRY { TPtrC8 ptr8( ( TUint8* ) __FUNCTION__ ); Trace( KStifEntryPrefix8, &ptr8 ); }
       
    41 #define TRACE_FUNC_EXIT { TPtrC8 ptr8( ( TUint8* ) __FUNCTION__ ); Trace( KStifExitPrefix8, &ptr8 ); }
       
    42 
       
    43 void CUsbPersonalityPluginTest::Trace(TRefByValue<const TDesC8> aFmt, ...)
       
    44 	{
       
    45 	VA_LIST list;
       
    46 	VA_START( list, aFmt );
       
    47 	TOverflowTruncate8 overflow;   
       
    48 	
       
    49 	RBuf8 buf8;
       
    50 	RBuf8 bufStifLog8;
       
    51 	
       
    52 	buf8.Create( KMaxLogLineLength );
       
    53 	buf8.Append( KStifTestPrefix8 );
       
    54 	buf8.AppendFormatList( aFmt, list, &overflow );	
       
    55 	bufStifLog8.Create( KMaxLogLineLength );
       
    56 	bufStifLog8.AppendFormatList( aFmt, list, &overflow );
       
    57 			
       
    58 	RBuf16 buf16;
       
    59 	RBuf16 bufStifLog16;
       
    60 	
       
    61 	buf16.Create( KMaxLogLineLength );
       
    62 	buf16.Copy( buf8 );
       
    63 	bufStifLog16.Create( KMaxLogLineLength );
       
    64 	bufStifLog16.Copy( bufStifLog8 );
       
    65 	
       
    66 	RDebug::Print( buf16 );
       
    67 	iLog->Log( bufStifLog16 );
       
    68 	buf8.Close();
       
    69 	bufStifLog8.Close();
       
    70 	buf16.Close();
       
    71 	bufStifLog16.Close();
       
    72 	};
       
    73 
       
    74 void CUsbPersonalityPluginTest::Trace(TRefByValue<const TDesC16> aFmt, ...)
       
    75 	{
       
    76 	VA_LIST list;
       
    77 	VA_START(list,aFmt);
       
    78 	TOverflowTruncate16 overflow;
       
    79 	
       
    80 	RBuf16 buf;
       
    81 	RBuf16 bufStifLog;
       
    82 	
       
    83 	buf.Create( KMaxLogLineLength );
       
    84 	buf.Append( KStifTestPrefix );
       
    85 	buf.AppendFormatList( aFmt, list, &overflow );
       
    86 	bufStifLog.Create( KMaxLogLineLength );
       
    87 	bufStifLog.AppendFormatList( aFmt, list, &overflow );
       
    88 	
       
    89 	RDebug::Print( buf );
       
    90 	iLog->Log( bufStifLog );
       
    91 	buf.Close();
       
    92 	bufStifLog.Close();
       
    93 	};