deviceupdatesui/cpqtsp/inc/ProvisioningDebug.h
changeset 18 7d11f9a6646f
equal deleted inserted replaced
4:75a71fdb4c92 18:7d11f9a6646f
       
     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 Provisioning
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef PROVISIONINGDEBUG_H
       
    21 #define PROVISIONINGDEBUG_H
       
    22 
       
    23 #include <e32debug.h> 
       
    24 
       
    25 //Examples
       
    26 //FLOG( _L( "[Provisioning] ProvisioningEngine::ConstructL:" ) );
       
    27 //FTRACE(RDebug::Print(_L("[Provisioning] ProvisioningEngine::ConstructL: 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, "Provisioning.log" );
       
    92 _LIT( KLogDirFullName, "c:\\logs\\" );
       
    93 _LIT( KLogDir, "Provisioning" );
       
    94 
       
    95 #define FLOG( a )   { FPrint(a); }
       
    96 #define FTRACE( a ) { a; }
       
    97 
       
    98 // Declare the FPrint function
       
    99 //
       
   100 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
       
   101     {
       
   102     VA_LIST list;
       
   103     VA_START( list, aFmt );
       
   104     RFileLogger::WriteFormat( KLogDir,
       
   105                               KLogFile,
       
   106                               EFileLoggingModeAppend,
       
   107                               aFmt,
       
   108                               list );
       
   109     }
       
   110 
       
   111 // ===========================================================================
       
   112 #else               // RDebug logging for target HW
       
   113 // ===========================================================================
       
   114 #include <e32svr.h>
       
   115 
       
   116 #define FLOG( a )   { RDebug::Print( a ); }
       
   117 #define FTRACE( a ) { a; }
       
   118 
       
   119 #endif //__WINS__
       
   120 
       
   121 // ===========================================================================
       
   122 #else // // No loggings --> Reduced binary size
       
   123 // ===========================================================================
       
   124 #define FLOG( a )
       
   125 #define FTRACE( a )
       
   126 
       
   127 #endif // _DEBUG
       
   128 
       
   129 #endif      // PROVISIONINGDEBUG_H
       
   130             
       
   131 // End of File