telephonyprotocols/rawipnif/inc/bttlog.h
branchRCL_3
changeset 20 07a122eea281
equal deleted inserted replaced
19:630d2f34d719 20:07a122eea281
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Defines logger for RawIP NIF.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #ifndef BTTLOG_H__
       
    23 #define BTTLOG_H__
       
    24 
       
    25 #include <comms-infras/commsdebugutility.h>
       
    26 
       
    27 #if defined(__FLOG_ACTIVE) || defined(__DEBUGRAWIPSERIALPORT__)
       
    28 // Uncomment any of these macros if you want logging.
       
    29 // -> BTT_LOG_1 : For general logging
       
    30 // -> BTT_LOG_2 : For error and warning logging
       
    31 // -> BTT_LOG_3 : For IP packet information
       
    32 #define	__BTT_LOG_1__ 1
       
    33 //#define __BTT_LOG_2__ 1
       
    34 //#define __BTT_LOG_3__ 1
       
    35 #endif
       
    36 
       
    37 #ifdef __BTT_LOG_1__
       
    38 #define _LOG_L1C1(AAA)						iTheLogger->Write(AAA)
       
    39 #define _LOG_L1C2(AAA, BBB)					iTheLogger->WriteFormat(AAA, BBB)
       
    40 #define _LOG_L1C3(AAA, BBB, CCC)			iTheLogger->WriteFormat(AAA, BBB, CCC)
       
    41 #define _LOG_L1C4(AAA, BBB, CCC, DDD)		iTheLogger->WriteFormat(AAA, BBB, CCC, DDD)
       
    42 #define _LOG_L1C5(AAA, BBB, CCC, DDD, EEE)	iTheLogger->WriteFormat(AAA, BBB, CCC, DDD, EEE)
       
    43 #else
       
    44 #define _LOG_L1C1(AAA)
       
    45 #define _LOG_L1C2(AAA, BBB)
       
    46 #define _LOG_L1C3(AAA, BBB, CCC)
       
    47 #define _LOG_L1C4(AAA, BBB, CCC, DDD)
       
    48 #define _LOG_L1C5(AAA, BBB, CCC, DDD, EEE)  
       
    49 #endif // __BTT_LOG_1__
       
    50 
       
    51 #ifdef __BTT_LOG_2__
       
    52 #define _LOG_L2C1(AAA)						iTheLogger->Write(AAA)
       
    53 #define _LOG_L2C2(AAA, BBB)					iTheLogger->WriteFormat(AAA, BBB)
       
    54 #define _LOG_L2C3(AAA, BBB, CCC)			iTheLogger->WriteFormat(AAA, BBB, CCC)
       
    55 #define _LOG_L2C4(AAA, BBB, CCC, DDD)		iTheLogger->WriteFormat(AAA, BBB, CCC, DDD)
       
    56 #define _LOG_L2C5(AAA, BBB, CCC, DDD, EEE)	iTheLogger->WriteFormat(AAA, BBB, CCC, DDD, EEE)
       
    57 #else
       
    58 #define _LOG_L2C1(AAA)
       
    59 #define _LOG_L2C2(AAA, BBB)
       
    60 #define _LOG_L2C3(AAA, BBB, CCC)
       
    61 #define _LOG_L2C4(AAA, BBB, CCC, DDD)
       
    62 #define _LOG_L2C5(AAA, BBB, CCC, DDD, EEE)  
       
    63 #endif // __BTT_LOG_2__
       
    64 
       
    65 #ifdef __BTT_LOG_3__
       
    66 #define _LOG_L3C1(AAA)						iTheLogger->Write(AAA)
       
    67 #define _LOG_L3C2(AAA, BBB)					iTheLogger->WriteFormat(AAA, BBB)
       
    68 #define _LOG_L3C3(AAA, BBB, CCC)			iTheLogger->WriteFormat(AAA, BBB, CCC)
       
    69 #define _LOG_L3C4(AAA, BBB, CCC, DDD)		iTheLogger->WriteFormat(AAA, BBB, CCC, DDD)
       
    70 #define _LOG_L3C5(AAA, BBB, CCC, DDD, EEE)	iTheLogger->WriteFormat(AAA, BBB, CCC, DDD, EEE)
       
    71 #else
       
    72 #define _LOG_L3C1(AAA)
       
    73 #define _LOG_L3C2(AAA, BBB)
       
    74 #define _LOG_L3C3(AAA, BBB, CCC)
       
    75 #define _LOG_L3C4(AAA, BBB, CCC, DDD)
       
    76 #define _LOG_L3C5(AAA, BBB, CCC, DDD, EEE)  
       
    77 #endif // __BTT_LOG_3__
       
    78 
       
    79 #ifdef __BTT_LOG_1__
       
    80 #ifndef __BTT_LOGGING__
       
    81 #define __BTT_LOGGING__
       
    82 #endif
       
    83 #endif
       
    84 
       
    85 #ifdef __BTT_LOG_2__ 
       
    86 #ifndef __BTT_LOGGING__
       
    87 #define __BTT_LOGGING__
       
    88 #endif
       
    89 #endif
       
    90 
       
    91 #ifdef __BTT_LOG_3__ 
       
    92 #ifndef __BTT_LOGGING__
       
    93 #define __BTT_LOGGING__
       
    94 #endif
       
    95 #endif
       
    96 
       
    97 #ifdef __BTT_LOGGING__
       
    98 #define _BTT_LEAVEIFERROR(a)	iTheLogger->VerboseLeaveL(__FILE__, __LINE__, a)
       
    99 #define _BTT_PANIC(CAT,	CODE)	iTheLogger->VerbosePanic(__FILE__, __LINE__, CODE, (TText8*)#CODE, CAT)
       
   100 #else
       
   101 #define _BTT_LEAVEIFERROR(a)	User::LeaveIfError(a)
       
   102 #define _BTT_PANIC(CAT, CODE)	User::Panic(CAT, CODE)
       
   103 #endif // __BTT_LOGGING__
       
   104 
       
   105 /**
       
   106  * static class containing methods for logging
       
   107  * text to a logfile.
       
   108  */
       
   109 class CBttLogger : public CBase
       
   110 	{
       
   111 public:
       
   112 	static CBttLogger* NewL(const TDesC8& aTag, const TDesC8& aFileName, const TUint32 aInstanceId);
       
   113 	~CBttLogger();
       
   114 
       
   115 public:
       
   116 	void Write(const TDesC8& aText);
       
   117 	void WriteFormat(TRefByValue<const TDesC8> aFmt, ...);
       
   118 	void VerboseLeaveL(char* aFile, TInt aLine, TInt aReason);
       
   119 	void VerbosePanic(char* aFile, 
       
   120 		TInt aLine, 
       
   121 		TInt aPanicCode, 
       
   122 		TText8* aPanicName,
       
   123 		const TDesC& aPanicCategory);
       
   124 
       
   125 protected:
       
   126 	CBttLogger();
       
   127 	void ConstructL(const TDesC8& aSubDir, const TDesC8& aFileName, const TUint32 aInstanceId);
       
   128 
       
   129 private:
       
   130     class TLogIgnoreOverflow8 : public TDes8Overflow
       
   131         {
       
   132         public:
       
   133             void Overflow(TDes8& /*aDes*/) { }
       
   134         };
       
   135 
       
   136 private: // owned
       
   137 
       
   138 	TUint32 iInstanceId;
       
   139 	__FLOG_DECLARATION_MEMBER;
       
   140 	};
       
   141 
       
   142 #endif // BTTLOG_H__