omacpadapters/accesspointadapter/Inc/ProvisioningDebug.h
changeset 42 aa33c2cb9a50
equal deleted inserted replaced
41:c742e1129640 42:aa33c2cb9a50
       
     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 
       
    21 
       
    22 
       
    23 #ifndef PROVISIONINGDEBUG_H
       
    24 #define PROVISIONINGDEBUG_H
       
    25 
       
    26 #include <e32debug.h> 
       
    27 #include <f32file.h>
       
    28 
       
    29 //Examples
       
    30 //FLOG( _L( "[Provisioning] ProvisioningEngine::ConstructL:" ) );
       
    31 //FTRACE(RDebug::Print(_L("[Provisioning] ProvisioningEngine::ConstructL: err (%d)"), err));
       
    32 #ifdef _DEBUG
       
    33 
       
    34 const TInt KBTHexDumpWidth=16;
       
    35 const TInt KBTLogBufferSize=100;
       
    36 const TText KFullStopChar='.';
       
    37 
       
    38 _LIT(KBTFirstFormatString,"%04x: ");
       
    39 _LIT(KBTSecondFormatString,"%02x ");
       
    40 _LIT(KBTThirdFormatString,"%c");
       
    41 _LIT(KBTThreeSpaces,"   ");
       
    42 _LIT(KBTSeparator," ");
       
    43 
       
    44 inline void HexDump(const TUint8* aPtr, TInt aLen)
       
    45     {
       
    46 	if( aPtr != NULL )
       
    47 	    {
       
    48     	TBuf<KBTLogBufferSize> line;
       
    49 	    TInt i = 0;
       
    50 
       
    51     	while (aLen>0)
       
    52     		{
       
    53     		TInt n = (aLen>KBTHexDumpWidth ? KBTHexDumpWidth : aLen);
       
    54     		line.AppendFormat(KBTFirstFormatString,i);
       
    55     		TInt j;
       
    56     		for (j=0; j<n; j++)
       
    57     			line.AppendFormat(KBTSecondFormatString,aPtr[i+j]);
       
    58     		while (j++<KBTHexDumpWidth)
       
    59     			line.Append(KBTThreeSpaces);
       
    60     		line.Append(KBTSeparator);
       
    61     		for (j=0; j<n; j++)
       
    62     			line.AppendFormat(KBTThirdFormatString,(aPtr[i+j]<32 || aPtr[i+j]>126 || aPtr[i+j]==37) ? KFullStopChar : aPtr[i+j]);
       
    63 
       
    64     		RDebug::Print(line);
       
    65 
       
    66             line.Zero();
       
    67     		aLen-=n;
       
    68     		i+=n;
       
    69     	    }
       
    70         }
       
    71     }
       
    72 
       
    73 
       
    74 // ------------------------------------------
       
    75 
       
    76 inline void FHex(const TUint8* aPtr, TInt aLen)
       
    77     {
       
    78     HexDump( aPtr, aLen );
       
    79     }
       
    80 
       
    81 // ------------------------------------------
       
    82 
       
    83 inline void FHex(const TDesC8& aDes)
       
    84     {
       
    85 	RFs fs;
       
    86 	RFile file;
       
    87 	_LIT( TmpOutputName, "C:\\provisioning.wbxml" );
       
    88 	fs.Connect();
       
    89 	CleanupClosePushL(fs);
       
    90 	//if( aFile.Open(aFileSession, TmpOutputName(), EFileShareAny|EFileWrite) == KErrNone )
       
    91 	file.Replace(fs, TmpOutputName(), EFileShareAny|EFileWrite);
       
    92 	CleanupClosePushL(file);
       
    93 	TInt pos(0);
       
    94 	file.Seek(ESeekEnd, pos);
       
    95 //	HBufC8* tmp = HBufC8::NewLC(line.Size());
       
    96 //	TPtr8 ptr = tmp->Des();
       
    97 //	ptr.Copy(line);
       
    98 	TInt result = file.Write(aDes);
       
    99 	CleanupStack::PopAndDestroy(2); // file,  fs
       
   100 ///////////////////////////////////////////////////
       
   101 
       
   102 //    HexDump(aDes.Ptr(), aDes.Length());
       
   103     }
       
   104 
       
   105 // ===========================================================================
       
   106 #ifdef __WINS__     // File logging for WINS
       
   107 // ===========================================================================
       
   108 #include <e32std.h>
       
   109 #include <f32file.h>
       
   110 #include <flogger.h>
       
   111 
       
   112 _LIT( KLogFile, "Provisioning.log" );
       
   113 _LIT( KLogDirFullName, "c:\\logs\\" );
       
   114 _LIT( KLogDir, "Provisioning" );
       
   115 
       
   116 #define FLOG( a )   { FPrint(a); }
       
   117 #define FTRACE( a ) { a; }
       
   118 
       
   119 // Declare the FPrint function
       
   120 //
       
   121 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
       
   122     {
       
   123     VA_LIST list;
       
   124     VA_START( list, aFmt );
       
   125     RFileLogger::WriteFormat( KLogDir,
       
   126                               KLogFile,
       
   127                               EFileLoggingModeAppend,
       
   128                               aFmt,
       
   129                               list );
       
   130     }
       
   131 
       
   132 // ===========================================================================
       
   133 #else               // RDebug logging for target HW
       
   134 // ===========================================================================
       
   135 /*#include <e32svr.h>
       
   136 
       
   137 #define FLOG( a )   { RDebug::Print( a ); }
       
   138 #define FTRACE( a ) { a; }
       
   139 
       
   140 */
       
   141 
       
   142 //////////////MIKA///////////////
       
   143 #include <e32std.h>
       
   144 #include <f32file.h>
       
   145 #include <flogger.h>
       
   146 
       
   147 _LIT( KLogFile, "Provisioning.log" );
       
   148 _LIT( KLogDirFullName, "c:\\logs\\" );
       
   149 _LIT( KLogDir, "Provisioning" );
       
   150 
       
   151 #define FLOG( a )   { FPrint(a); }
       
   152 #define FTRACE( a ) { a; }
       
   153 
       
   154 // Declare the FPrint function
       
   155 //
       
   156 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
       
   157     {
       
   158     VA_LIST list;
       
   159     VA_START( list, aFmt );
       
   160     RFileLogger::WriteFormat( KLogDir,
       
   161                               KLogFile,
       
   162                               EFileLoggingModeAppend,
       
   163                               aFmt,
       
   164                               list );
       
   165     }
       
   166 
       
   167 //////////////MIKA///////////////
       
   168 
       
   169 
       
   170 #endif //__WINS__
       
   171 
       
   172 // ===========================================================================
       
   173 #else // // No loggings --> Reduced binary size
       
   174 // ===========================================================================
       
   175 #define FLOG( a )
       
   176 #define FTRACE( a )
       
   177 
       
   178 #endif // _DEBUG
       
   179 
       
   180 ///////// Kailash ///////////////////////
       
   181 inline void LOGX(TInt aSource)
       
   182 	{
       
   183 		HBufC *iMyBufNumber = HBufC::NewLC(255);
       
   184    		TPtr bufNumberPtr(iMyBufNumber->Des());
       
   185    		bufNumberPtr.FillZ();
       
   186    		bufNumberPtr.AppendFormat(_L("%d"),aSource);
       
   187     	FLOG(iMyBufNumber->Des());
       
   188     	CleanupStack::PopAndDestroy();
       
   189 	}
       
   190 ///////// Kailash ///////////////////////
       
   191 	
       
   192 #endif      // PROVISIONINGDEBUG_H
       
   193             
       
   194 // End of File