voipplugins/voipadapters/provisioningfile/inc/wpprovisioningfiledebug.h
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2005 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:  This file defines logging macros for provisioningfile
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef WPPROVISIONINGFILEDEBUG_H
       
    21 #define WPPROVISIONINGFILEDEBUG_H
       
    22 
       
    23 #include <e32debug.h> 
       
    24 
       
    25 //Examples
       
    26 //FLOG( "[ComponentName] ClassName::MethodName:" );
       
    27 //FTRACE(RDebug::Print(_L("[ComponentName] ClassName::MethodName: err (%d)"), err));
       
    28 #ifdef _DEBUG
       
    29 
       
    30 const TInt KBTHexDumpWidth=16;
       
    31 const TInt KBTLogBufferSize=100;
       
    32 const TText KFullStopChar='.';
       
    33 
       
    34 _LIT(KBTFirstFormatString,"%04x: ");
       
    35 _LIT(KBTSecondFormatString,"%02x ");
       
    36 _LIT(KBTThirdFormatString,"%c");
       
    37 _LIT(KBTThreeSpaces,"   ");
       
    38 _LIT(KBTSeparator," ");
       
    39 
       
    40 inline void HexDump(const TUint8* aPtr, TInt aLen)
       
    41     {
       
    42 	if( aPtr != NULL )
       
    43 	    {
       
    44     	TBuf<KBTLogBufferSize> line;
       
    45 	    TInt i = 0;
       
    46 
       
    47     	while (aLen>0)
       
    48     		{
       
    49     		TInt n = (aLen>KBTHexDumpWidth ? KBTHexDumpWidth : aLen);
       
    50     		line.AppendFormat(KBTFirstFormatString,i);
       
    51     		TInt j;
       
    52     		for (j=0; j<n; j++)
       
    53     			line.AppendFormat(KBTSecondFormatString,aPtr[i+j]);
       
    54     		while (j++<KBTHexDumpWidth)
       
    55     			line.Append(KBTThreeSpaces);
       
    56     		line.Append(KBTSeparator);
       
    57     		for (j=0; j<n; j++)
       
    58     			line.AppendFormat(KBTThirdFormatString,(aPtr[i+j]<32 || aPtr[i+j]>126 || aPtr[i+j]==37) ? KFullStopChar : aPtr[i+j]);
       
    59 
       
    60     		RDebug::Print(line);
       
    61 
       
    62             line.Zero();
       
    63     		aLen-=n;
       
    64     		i+=n;
       
    65     	    }
       
    66         }
       
    67     }
       
    68 
       
    69 
       
    70 // ------------------------------------------
       
    71 
       
    72 inline void FHex(const TUint8* aPtr, TInt aLen)
       
    73     {
       
    74     HexDump( aPtr, aLen );
       
    75     }
       
    76 
       
    77 // ------------------------------------------
       
    78 
       
    79 inline void FHex(const TDesC8& aDes)
       
    80     {
       
    81     HexDump(aDes.Ptr(), aDes.Length());
       
    82     }
       
    83 
       
    84 // ===========================================================================
       
    85 #ifdef __WINS__     // File logging for WINS
       
    86 // ===========================================================================
       
    87 #include <e32std.h>
       
    88 #include <f32file.h>
       
    89 #include <flogger.h>
       
    90 
       
    91 _LIT( KLogFile, "voipadapters.log" );
       
    92 _LIT( KLogDirFullName, "c:\\logs\\" );
       
    93 _LIT( KLogDir, "voipadapters" );
       
    94 
       
    95 #define FLOG( a )   { FPrint( _L( a ) ); }
       
    96 #define FLOG2( a,b )  { FPrint( _L( a ), b ); }
       
    97 #define FTRACE( a ) { a; }
       
    98 
       
    99 // Declare the FPrint function
       
   100 //
       
   101 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
       
   102     {
       
   103     VA_LIST list;
       
   104     VA_START( list, aFmt );
       
   105     RFileLogger::WriteFormat( KLogDir,
       
   106                               KLogFile,
       
   107                               EFileLoggingModeAppend,
       
   108                               aFmt,
       
   109                               list );
       
   110     }
       
   111 
       
   112 // ===========================================================================
       
   113 #else               // RDebug logging for target HW
       
   114 // ===========================================================================
       
   115 #include <e32svr.h>
       
   116 
       
   117 #define FLOG( a )   { RDebug::Print( _L( a ) ); }
       
   118 #define FLOG2(a,b)  { RDebug::Print( _L( a ), b ); }
       
   119 #define FTRACE( a ) { a; }
       
   120 
       
   121 #endif //__WINS__
       
   122 
       
   123 // ===========================================================================
       
   124 #else // // No loggings --> Reduced binary size
       
   125 // ===========================================================================
       
   126 #define FLOG( a )
       
   127 #define FLOG2( a, b )
       
   128 #define FTRACE( a )
       
   129 
       
   130 #endif // _DEBUG
       
   131 
       
   132 #endif      // WPPROVISIONINGFILEDEBUG_H
       
   133             
       
   134 // End of File