1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/ctsy/tflogger.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,138 @@
1.4 +/*
1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +#ifndef __TFLOGGER_H__
1.24 +#define __TFLOGGER_H__
1.25 +
1.26 +// CONSTANTS
1.27 +#ifndef _DEBUG
1.28 +
1.29 +// UREL BUILD:
1.30 +#define TF_LOGGING_METHOD 0 // No logging in UREL builds
1.31 +
1.32 +#else
1.33 +
1.34 +// UDEB BUILD:
1.35 +#define TF_LOGGING_METHOD 3 // 0 = No logging,
1.36 + // 1 = Flogger,
1.37 + // 2 = RDebug
1.38 + // 3 = CommsDebug
1.39 +#endif
1.40 +
1.41 +
1.42 +#if TF_LOGGING_METHOD > 0
1.43 +#define TF_LOGGING_ENABLED // This is for backward compatibility
1.44 +#endif
1.45 +
1.46 +// FUNCTION PROTOTYPES
1.47 +#if TF_LOGGING_METHOD == 1 // Flogger
1.48 +
1.49 +#include <flogger.h>
1.50 +_LIT(KTfLogFolder,"TF");
1.51 +_LIT(KTfLogFile,"TFLOG.TXT");
1.52 +
1.53 +#elif TF_LOGGING_METHOD == 2 // RDebug
1.54 +
1.55 +#include <e32svr.h>
1.56 +
1.57 +#elif TF_LOGGING_METHOD == 3 // CommsDebug
1.58 +
1.59 +#include <comms-infras/commsdebugutility.h>
1.60 +
1.61 +#endif
1.62 +
1.63 +
1.64 +/*
1.65 +-----------------------------------------------------------------------------
1.66 +
1.67 + LOGGING MACROs
1.68 +
1.69 + USE THESE MACROS IN YOUR CODE !
1.70 +
1.71 +-----------------------------------------------------------------------------
1.72 +*/
1.73 +
1.74 +#if TF_LOGGING_METHOD == 1 // Flogger
1.75 +
1.76 +#define TFLOGTEXT(AAA) RFileLogger::Write(KTfLogFolder(),KTfLogFile(),EFileLoggingModeAppend, AAA)
1.77 +#define TFLOGSTRING(AAA) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RFileLogger::Write(KTfLogFolder(),KTfLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0)
1.78 +#define TFLOGSTRING2(AAA,BBB) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KTfLogFolder(),KTfLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); } while (0)
1.79 +#define TFLOGSTRING3(AAA,BBB,CCC) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KTfLogFolder(),KTfLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); } while (0)
1.80 +#define TFLOGSTRING4(AAA,BBB,CCC,DDD) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KTfLogFolder(),KTfLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); } while (0)
1.81 +
1.82 +
1.83 +#elif TF_LOGGING_METHOD == 2 // RDebug
1.84 +
1.85 +#define TFLOGTEXT(AAA) RDebug::Print(AAA)
1.86 +#define TFLOGSTRING(AAA) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0)
1.87 +#define TFLOGSTRING2(AAA,BBB) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0)
1.88 +#define TFLOGSTRING3(AAA,BBB,CCC) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0)
1.89 +#define TFLOGSTRING4(AAA,BBB,CCC,DDD) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0)
1.90 +
1.91 +
1.92 +#elif TF_LOGGING_METHOD == 3 // CommsDebug
1.93 +_LIT8(KTSYSubSystem, "tsy");
1.94 +#ifdef TF_SAT_LOGGING
1.95 +_LIT8(KTSYCompnt, "sattsy");
1.96 +#else
1.97 +_LIT8(KTSYCompnt, "ctsy");
1.98 +#endif
1.99 +
1.100 +#define TFLOGTEXT(AAA) __FLOG_STATIC0(KTSYSubSystem,KTrpCompnt,(AAA))
1.101 +#define TFLOGSTRING(AAA) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); __FLOG_STATIC0(KTSYSubSystem,KTSYCompnt, tempLogDes); } while (0)
1.102 +#define TFLOGSTRING2(AAA,BBB) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); __FLOG_STATIC1(KTSYSubSystem,KTSYCompnt, tempLogDes, BBB); } while (0)
1.103 +#define TFLOGSTRING3(AAA,BBB,CCC) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); __FLOG_STATIC2(KTSYSubSystem,KTSYCompnt, tempLogDes, BBB, CCC); } while (0)
1.104 +#define TFLOGSTRING4(AAA,BBB,CCC,DDD) /*lint --e{717}, --e{1534} */ do { _LIT(tempLogDes,AAA); __FLOG_STATIC3(KTSYSubSystem,KTSYCompnt, tempLogDes, BBB, CCC, DDD); } while (0)
1.105 +
1.106 +#else // TF_LOGGING_METHOD == 0 or invalid
1.107 +
1.108 +#define TFLOGTEXT(AAA) // Example: TFLOGTEXT(own_desc);
1.109 +#define TFLOGSTRING(AAA) // Example: TFLOGSTRING("Test");
1.110 +#define TFLOGSTRING2(AAA,BBB) // Example: TFLOGSTRING("Test %i", aValue);
1.111 +#define TFLOGSTRING3(AAA,BBB,CCC) // Example: TFLOGSTRING("Test %i %i", aValue1, aValue2);
1.112 +#define TFLOGSTRING4(AAA,BBB,CCC,DDD) // Example: TFLOGSTRING("Test %i %i %i", aValue1, aValue2, aValue3);
1.113 +
1.114 +#endif // TF_LOGGING_METHOD
1.115 +
1.116 +#if TF_LOGGING_METHOD == 1 || TF_LOGGING_METHOD == 2
1.117 +
1.118 +// Note, #x and __FILE__ must be stored to char string first, making them 16bit
1.119 +// strings with _LIT will not work in all compilers.
1.120 +
1.121 +#define TF_ASSERT(x) /*lint --e{717} */ do { if (!(x)) { const TUint8 tempX8[] = #x; \
1.122 + TBuf<sizeof(tempX8)> tempX; \
1.123 + tempX.Copy(TPtrC8(tempX8)); const TUint8 tempF8[] = __FILE__; TBuf<sizeof(tempF8)> tempF;\
1.124 + tempF.Copy(TPtrC8(tempF8)); \
1.125 + TFLOGSTRING4("TSY: ASSERT FAILED: %S, file %S, line %d", &tempX, &tempF, __LINE__ ); } } while(0)
1.126 +
1.127 +#define TF_ASSERT_NOT_REACHED() /*lint --e{717} */ do { const TUint8 tempF8[] = __FILE__;\
1.128 + TBuf<sizeof(tempF8)> tempF; tempF.Copy(TPtrC8(tempF8));\
1.129 + TFLOGSTRING3("TSY: ASSERT FAILED: unreachable code, file %S, line %d", &tempF, __LINE__ ); } while (0)
1.130 +
1.131 +#else // TF_LOGGING_METHOD == 0 or invalid
1.132 +
1.133 +#define TF_ASSERT(x)
1.134 +#define TF_ASSERT_NOT_REACHED()
1.135 +
1.136 +#endif // TF_LOGGING_METHOD == 1 || TF_LOGGING_METHOD == 2
1.137 +
1.138 +
1.139 +#endif // __TFLOGGER_H__
1.140 +
1.141 +// End of File