Telephony/ctsydispatchlayer/exportinc/ltsylogger.h
changeset 21 ab1d0f4d2aa4
equal deleted inserted replaced
20:4a8d14a1a8ca 21:ab1d0f4d2aa4
       
     1 // Copyright (c) 2008-2010 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 // CommsDebugUtil logging support for the CTSY Dispatcher.
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalAll 
       
    23 */
       
    24 
       
    25 #ifndef __LTSYLOGGER_H_
       
    26 #define __LTSYLOGGER_H_
       
    27 
       
    28 #include <e32base.h>
       
    29 
       
    30 #ifdef OST_TRACE_COMPILER_IN_USE
       
    31 
       
    32 _LIT8(KTsySubSystem, "tsy");
       
    33 _LIT8(KTsyCompnt, "ctsydis");
       
    34 
       
    35 	/** Macros to log function entry and exit */
       
    36 	//#define TSYLOGENTRYEXIT(aFunc) 	TLogEntryExit __logger((aFunc), KTsyCompnt)
       
    37 	
       
    38 	//#define TSYLOGENTRYEXITARGS(aFunc, aFmt, ARGS...) 	TLogEntryExit __logger((aFunc), KTsyCompnt, (aFmt), ##ARGS); 
       
    39 
       
    40 	#define TSYLOGENTRYEXIT 	/*lint -save -e40*/	TLogEntryExit __logger(TPtrC8((const TUint8*)__PRETTY_FUNCTION__), KTsyCompnt)/*lint -restore*/
       
    41 	
       
    42 	// N.B. The function name does not need to be specified
       
    43 	#define TSYLOGENTRYEXITARGS(aFmt, ARGS...) 	/*lint -save -e40*/ TLogEntryExit __logger(TPtrC8((const TUint8*)__PRETTY_FUNCTION__), KTsyCompnt, (aFmt), ##ARGS)/*lint -restore*/
       
    44 
       
    45 	#define TSYLOGSETEXITERR(aErr) 	__logger.SetExitErrorCode( aErr )
       
    46 
       
    47 
       
    48 /**
       
    49 Automatic class that logs function entry and exit
       
    50 */
       
    51 class TLogEntryExit
       
    52 	{
       
    53 public:
       
    54 	IMPORT_C TLogEntryExit(const TDesC8& aFnName, const TDesC8& aLayer);
       
    55 	IMPORT_C TLogEntryExit(const TDesC8& aFnName, const TDesC8& aLayer, TRefByValue<const TDesC8> aFmt, ...);
       
    56 	IMPORT_C TLogEntryExit(const TDesC8& aFnName, const TDesC8& aLayer, TRefByValue<const TDesC16> aFmt, ...);
       
    57 	IMPORT_C ~TLogEntryExit();
       
    58 	inline TInt SetExitErrorCode(TInt aErr);
       
    59 private:
       
    60 	TPtrC8 iFnName;
       
    61 	TPtrC8 iLayer;
       
    62 	TInt   iErr;
       
    63 	}; // class TLogEntryExit
       
    64 
       
    65 /** 
       
    66 Set the error that will be logged at function exit
       
    67 
       
    68 @param aErr error code to log
       
    69 @return the given error code. This is to allow to pipe the function call
       
    70 */
       
    71 TInt TLogEntryExit::SetExitErrorCode(TInt aErr)
       
    72 	{
       
    73 	return iErr = aErr;
       
    74 	}
       
    75 	
       
    76 	
       
    77 	
       
    78 #else // _DEBUG
       
    79 
       
    80 	#define TSYLOGENTRYEXIT
       
    81 	#define TSYLOGENTRYEXITARGS(aFunc, aFmt, ARGS...)
       
    82 	#define TSYLOGSETEXITERR(aErr)	aErr // So that we don't lose the return code in UREL!
       
    83 
       
    84 	
       
    85 /**
       
    86 Stub class for urel builds, required for exports.
       
    87 */
       
    88 class TLogEntryExit
       
    89 	{
       
    90 public:
       
    91 	IMPORT_C TLogEntryExit(const TDesC8& aFnName, const TDesC8& aLayer);
       
    92 	IMPORT_C TLogEntryExit(const TDesC8& aFnName, const TDesC8& aLayer, TRefByValue<const TDesC8> aFmt, ...);
       
    93 	IMPORT_C TLogEntryExit(const TDesC8& aFnName, const TDesC8& aLayer, TRefByValue<const TDesC16> aFmt, ...);
       
    94 	IMPORT_C ~TLogEntryExit();
       
    95 	};
       
    96 
       
    97 
       
    98 
       
    99 #endif // _DEBUG
       
   100 
       
   101 #endif // __LTSYLOGGER_H_