|
1 /* |
|
2 * Copyright (c) 2010 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: Easy dialing logging functions. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __EASYDIALINGLOGGER_H__ |
|
20 #define __EASYDIALINGLOGGER_H__ |
|
21 |
|
22 // Note! These macros are to be used in trace prints (legacy support). |
|
23 // To be used only in error situations and major events only ! |
|
24 // Otherwise use OST - Open System Trace |
|
25 |
|
26 #ifdef _DEBUG |
|
27 |
|
28 // #define USE_FILE_LOGGING |
|
29 |
|
30 // From this point on, internal implementation |
|
31 |
|
32 #include <e32svr.h> // for RDebug::Print |
|
33 |
|
34 #ifdef USE_FILE_LOGGING |
|
35 #include <flogger.h> |
|
36 _LIT( KLogDir, "ed" ); |
|
37 _LIT( KLogFile, "easydialing.log" ); |
|
38 #endif |
|
39 |
|
40 |
|
41 NONSHARABLE_CLASS(TOverflowTruncate) : public TDes16Overflow |
|
42 { |
|
43 public: |
|
44 void Overflow(TDes16& /*aDes*/) {} |
|
45 }; |
|
46 |
|
47 inline void DoDebugPrintF(TRefByValue<const TDesC> aFmt, VA_LIST& aList) |
|
48 { |
|
49 TBuf<200> buf; |
|
50 TOverflowTruncate overFlow; |
|
51 buf.AppendFormatList( aFmt, aList, &overFlow ); |
|
52 _LIT(KLogPrintFormat,"%S: %S"); // Log printing format |
|
53 const TDesC& thname = RThread().Name(); // With FullName more info |
|
54 RDebug::Print( KLogPrintFormat, &thname, &buf ); |
|
55 #ifdef USE_FILE_LOGGING |
|
56 RFileLogger::Write(KLogDir, KLogFile, EFileLoggingModeAppend, buf); |
|
57 #endif |
|
58 } |
|
59 |
|
60 inline void DebugPrintF(const TRefByValue<const TDesC> aFmt,...) |
|
61 { |
|
62 VA_LIST list; |
|
63 VA_START(list,aFmt); |
|
64 DoDebugPrintF(aFmt, list); |
|
65 } |
|
66 |
|
67 |
|
68 // Macros |
|
69 |
|
70 #define LOGSTRING( TEXT ) DebugPrintF( _L( TEXT ) ) |
|
71 #define LOGSTRING1( TEXT, VAR1 ) DebugPrintF( _L( TEXT ), VAR1 ) |
|
72 #define LOGSTRING2( TEXT, VAR1, VAR2 ) DebugPrintF( _L( TEXT ), VAR1, VAR2 ) |
|
73 |
|
74 #define PERF_MEASURE_START \ |
|
75 TTime startTime, endTime; \ |
|
76 startTime.HomeTime();\ |
|
77 DebugPrintF( _L("EasyDialingPlugin: Measure start..") ); |
|
78 |
|
79 |
|
80 #define PERF_MEASURE_STOP \ |
|
81 endTime.HomeTime(); \ |
|
82 TTimeIntervalMicroSeconds microsecs = endTime.MicroSecondsFrom( startTime ); \ |
|
83 TReal timeSecs=(TReal)((TReal)(microsecs.Int64())/1000); \ |
|
84 DebugPrintF( _L("EasyDialingPlugin: Measure stop, time taken %5.3f msecs"), timeSecs ); |
|
85 |
|
86 #else |
|
87 |
|
88 #define LOGSTRING( TEXT ) |
|
89 #define LOGSTRING1( TEXT, VAR1 ) |
|
90 #define LOGSTRING2( TEXT, VAR1, VAR2 ) |
|
91 |
|
92 #define PERF_MEASURE_START |
|
93 #define PERF_MEASURE_STOP |
|
94 |
|
95 #endif |
|
96 |
|
97 #endif |
|
98 |