fotaapplication/fotacustcmds/inc/fotastartupDebug.h
author hgs
Tue, 13 Jul 2010 09:51:41 +0530
changeset 51 2e64dc50f295
permissions -rw-r--r--
201025_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     1
/*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     2
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     3
* All rights reserved.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     8
*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     9
* Initial Contributors:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    11
*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    12
* Contributors:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    13
*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    14
* Description:   This file defines logging macros for Fotastartupextension log
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    15
*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    16
*/
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    17
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    18
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    19
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    20
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    21
#ifndef FOTASTARTUPDEBUG_H
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    22
#define FOTASTARTUPDEBUG_H
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    23
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    24
#include <e32debug.h> 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    25
#include <f32file.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    26
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    27
//Examples
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    28
//FLOG( _L( "[fotastartupextensionplugin] CFotaStartupExtensionPlugIn::NewL:" ) );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    29
//FTRACE(RDebug::Print(_L("[fotastartupextensionplugin] fotastartupextensionplugin::NewL: err (%d)"), err));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    30
#ifdef _DEBUG
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    31
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    32
const TInt KBTHexDumpWidth=16;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    33
const TInt KBTLogBufferSize=100;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    34
const TText KFullStopChar='.';
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    35
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    36
_LIT(KBTFirstFormatString,"%04x: ");
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    37
_LIT(KBTSecondFormatString,"%02x ");
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    38
_LIT(KBTThirdFormatString,"%c");
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    39
_LIT(KBTThreeSpaces,"   ");
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    40
_LIT(KBTSeparator," ");
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    41
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    42
inline void HexDump(const TUint8* aPtr, TInt aLen)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    43
    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    44
	if( aPtr != NULL )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    45
	    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    46
    	TBuf<KBTLogBufferSize> line;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    47
	    TInt i = 0;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    48
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    49
    	while (aLen>0)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    50
    		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    51
    		TInt n = (aLen>KBTHexDumpWidth ? KBTHexDumpWidth : aLen);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    52
    		line.AppendFormat(KBTFirstFormatString,i);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    53
    		TInt j;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    54
    		for (j=0; j<n; j++)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    55
    			line.AppendFormat(KBTSecondFormatString,aPtr[i+j]);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    56
    		while (j++<KBTHexDumpWidth)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    57
    			line.Append(KBTThreeSpaces);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    58
    		line.Append(KBTSeparator);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    59
    		for (j=0; j<n; j++)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    60
    			line.AppendFormat(KBTThirdFormatString,(aPtr[i+j]<32 || aPtr[i+j]>126 || aPtr[i+j]==37) ? KFullStopChar : aPtr[i+j]);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    61
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    62
    		RDebug::Print(line);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    63
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    64
            line.Zero();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    65
    		aLen-=n;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    66
    		i+=n;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    67
    	    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    68
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    69
    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    70
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    71
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    72
// ===========================================================================
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    73
#ifdef __WINS__     // File logging for WINS
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    74
// ===========================================================================
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    75
#include <e32std.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    76
#include <f32file.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    77
#include <flogger.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    78
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    79
_LIT( KLogFile, "fotacustcmds.log" );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    80
_LIT( KLogDirFullName, "c:\\logs\\" );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    81
_LIT( KLogDir, "fota" );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    82
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    83
#define FLOG( a )   { FPrint(a); }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    84
#define FTRACE( a ) { a; }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    85
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    86
// Declare the FPrint function
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    87
//
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    88
inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    89
    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    90
    VA_LIST list;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    91
    VA_START( list, aFmt );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    92
    RFileLogger::WriteFormat( KLogDir,
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    93
                              KLogFile,
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    94
                              EFileLoggingModeAppend,
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    95
                              aFmt,
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    96
                              list );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    97
    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    98
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    99
// ===========================================================================
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   100
#else               // RDebug logging for target HW
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   101
// ===========================================================================
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   102
/*#include <e32svr.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   103
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   104
#define FLOG( a )   { RDebug::Print( a ); }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   105
#define FTRACE( a ) { a; }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   106
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   107
*/
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   108
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   109
///////////////////////////////
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   110
#include <e32std.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   111
#include <f32file.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   112
#include <flogger.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   113
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   114
_LIT( KLogFile, "fotacustcmds.log" );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   115
_LIT( KLogDirFullName, "c:\\logs\\" );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   116
_LIT( KLogDir, "fota" );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   117
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   118
#define FLOG( a )   { FPrint(a); }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   119
#define FTRACE( a ) { a; }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   120
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   121
// Declare the FPrint function
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   122
//
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   123
inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   124
    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   125
    VA_LIST list;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   126
    VA_START( list, aFmt );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   127
    RFileLogger::WriteFormat( KLogDir,
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   128
                              KLogFile,
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   129
                              EFileLoggingModeAppend,
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   130
                              aFmt,
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   131
                              list );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   132
    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   133
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   134
////////////////////////////////
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   135
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   136
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   137
#endif //__WINS__
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   138
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   139
// ===========================================================================
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   140
#else // // No loggings --> Reduced binary size
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   141
// ===========================================================================
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   142
#define FLOG( a )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   143
#define FTRACE( a )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   144
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   145
#endif // _DEBUG
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   146
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   147
/////////  ///////////////////////
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   148
inline void LOGX(TInt aSource)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   149
	{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   150
		HBufC *iMyBufNumber = HBufC::NewLC(255);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   151
   		TPtr bufNumberPtr(iMyBufNumber->Des());
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   152
   		bufNumberPtr.FillZ();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   153
   		bufNumberPtr.AppendFormat(_L("%d"),aSource);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   154
    	FLOG(iMyBufNumber->Des());
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   155
    	CleanupStack::PopAndDestroy();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   156
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   157
/////////  ///////////////////////
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   158
	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   159
#endif      // FOTASTARTUP_H
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   160
            
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   161
// End of File