|
1 /* |
|
2 * Copyright (c) 2009 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: Logging definitions for test module |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef LOGGING_H |
|
20 #define LOGGING_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 |
|
26 // CONSTANTS |
|
27 const TUint KError = 0x1; |
|
28 const TUint KInit = 0x2; |
|
29 const TUint KPrint = 0x4; |
|
30 const TUint KMessage = 0x10; |
|
31 const TUint KFunction = 0x20; |
|
32 const TUint KVerbose = 0x40; |
|
33 const TUint KAlways = 0xFFFFFFFF; |
|
34 const TUint KDebugLevel = ( KFunction | KPrint | KError | KMessage | KVerbose ); |
|
35 |
|
36 // Logging path |
|
37 _LIT( KMtpDataProviderTestModuleLogPath, "\\logs\\testframework\\mtp\\" ); |
|
38 // Log file |
|
39 _LIT( KMtpDataProviderTestModuleLogFile, "MtpDataProviderTestModule.txt" ); |
|
40 _LIT( KMtpDataProviderTestModuleLogFileWithTitle, "MtpDataProviderTestModule_[%S].txt" ); |
|
41 |
|
42 _LIT( KTestObserverLogFile, "TestObserver.txt" ); |
|
43 _LIT( KTestObserverLogFileWithTitle, "TestObserver_[%S].txt" ); |
|
44 |
|
45 _LIT( KFuncTraceFormat, "%S - %S" ); |
|
46 |
|
47 // MACROS |
|
48 #define __TRACING_ENABLED |
|
49 |
|
50 #ifdef __TRACING_ENABLED |
|
51 #define PRINTTESTMODULEIF |
|
52 #define PRINTTESTMODULE |
|
53 // target can be CStifLogger::ERDebug or CStifLogger::EFile |
|
54 #define TRACE_TARGET CStifLogger::EFile |
|
55 // Disable conditional expression is constant -warning |
|
56 #pragma warning( disable : 4127 ) |
|
57 |
|
58 // General tracing function |
|
59 #define __TRACE(level,p) if ( ( (level) & KDebugLevel ) && LOGGER )\ |
|
60 {LOGGER->Log p;} |
|
61 |
|
62 // Direct RDebug::Print |
|
63 #define __RDEBUG(p) if( KVerbose & KDebugLevel ){ RDebug::Print p ; } |
|
64 |
|
65 // Log function name |
|
66 #define __TRACEFUNC() if( ( KFunction & KDebugLevel ) && LOGGER ){\ |
|
67 const char* func = __FUNCTION__;\ |
|
68 TPtrC8 F((const unsigned char*)func);\ |
|
69 LOGGER->Log(F);} |
|
70 |
|
71 #define PRINT0( level, p ) __TRACE( level, ( p ) ); \ |
|
72 if ( ( level ) & KMessage ) { \ |
|
73 PRINTTESTMODULEIF( p ); } \ |
|
74 if ( ( level ) & KError ) { \ |
|
75 PRINTTESTMODULE( p ); } |
|
76 #define PRINTn( level, p ) __TRACE( level, ( p ) ); |
|
77 #define PRINTM0( p ) PRINT0( KMessage, ( _L( p ) ) ) |
|
78 #define PRINTM1( p, a ) __TRACE( KMessage, ( _L( p ), a ) ) |
|
79 #define PRINTM2( p, a, b ) __TRACE( KMessage, ( _L( p ), a, b ) ) |
|
80 #define PRINTE0( p ) PRINT0( KError, ( _L( p ) ) ) |
|
81 #define PRINTE1( p, a ) __TRACE( KError, ( _L( p ), a ) ) |
|
82 #define PRINTE2( p, a, b ) __TRACE( KError, ( _L( p ), a, b ) ) |
|
83 #define PRINTN0( p ) __TRACE( KPrint, ( _L( p ) ) ) |
|
84 #define PRINTN1( p, a ) __TRACE( KPrint, ( _L( p ), a ) ) |
|
85 #define PRINTN2( p, a, b ) __TRACE( KPrint, ( _L( p ), a, b ) ) |
|
86 #define PRINTV0( p ) __TRACE( KVerbose, ( _L( p ) ) ) |
|
87 #define PRINTV1( p, a ) __TRACE( KVerbose, ( _L( p ), a ) ) |
|
88 #define PRINTV2( p, a, b ) __TRACE( KVerbose, ( _L( p ), a, b ) ) |
|
89 #define PRINTV3( p, a, b, c ) __TRACE( KVerbose, ( _L( p ), a, b, c ) ) |
|
90 #define PRINTV4( p, a, b, c, d ) __TRACE( KVerbose, ( _L( p ), a, b, c, d ) ) |
|
91 #define PRINTF0( p ) __TRACE( KFunction, ( _L( p ) ) ) |
|
92 #define PRINTF1( p, a ) __TRACE( KFunction, ( _L( p ), a ) ) |
|
93 #define PRINTF2( p, a, b ) __TRACE( KFunction, ( _L( p ), a, b ) ) |
|
94 #define PRINTF3( p, a, b, c ) __TRACE( KFunction, ( _L( p ), a, b, c ) ) |
|
95 |
|
96 #else // __TRACING_ENABLED |
|
97 // No tracing |
|
98 #define __TRACE(level,p) |
|
99 #define __RDEBUG(p) |
|
100 #define __TRACEFUNC() |
|
101 #endif // __TRACING_ENABLED |
|
102 |
|
103 #endif // LOGGING_H |
|
104 |