|
1 /* |
|
2 * Copyright (c) 2007 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: |
|
15 * |
|
16 */ |
|
17 #ifndef __TTRACER_H__ |
|
18 #define __TTRACER_H__ |
|
19 |
|
20 #include <e32std.h> |
|
21 #include <e32svr.h> |
|
22 #include <f32file.h> |
|
23 |
|
24 //#ifdef _DEBUG |
|
25 #define TRACER_ENABLED |
|
26 //#else |
|
27 //#undef TRACER_ENABLED |
|
28 //#endif |
|
29 |
|
30 /** Macro to initialise the tracer. Set the indentation level to zero. */ |
|
31 #ifdef TRACER_ENABLED |
|
32 #define INITTRACE TTracer t |
|
33 #else |
|
34 #define INITTRACE |
|
35 #endif |
|
36 |
|
37 /** Macro to trace the function calls. |
|
38 * @param a Text to display. Usually class::function */ |
|
39 #ifdef TRACER_ENABLED |
|
40 #define TRACE(a) TTracer t(_L(a)) |
|
41 #else |
|
42 #define TRACE(a) |
|
43 #endif |
|
44 |
|
45 /** Macro to print a string to the trace window. |
|
46 * @param a Text to print. |
|
47 */ |
|
48 #ifdef TRACER_ENABLED |
|
49 #define TRACESTR(a) TTracer::Print(_L(a)) |
|
50 #else |
|
51 #define TRACESTR |
|
52 #endif |
|
53 |
|
54 /** |
|
55 * @ingroup group_xnutils |
|
56 * |
|
57 * Class for tracing function calls. Indentation shows the call tree. |
|
58 * Also the entry and leave points are time labeled, show timing info is available. |
|
59 */ |
|
60 class TTracer |
|
61 { |
|
62 public: |
|
63 /** Initialising constructor. */ |
|
64 IMPORT_C TTracer(); |
|
65 |
|
66 /** Tracing constructor. |
|
67 * Writes time lable and "Enter: " + the given string. |
|
68 */ |
|
69 IMPORT_C TTracer(TPtrC aString); |
|
70 |
|
71 /** Destructor. |
|
72 * Writes time lable and "Leave: " + the given string. |
|
73 */ |
|
74 IMPORT_C ~TTracer(); |
|
75 |
|
76 /** Prints the given string to the trace window. |
|
77 * @param a Text to print. |
|
78 */ |
|
79 IMPORT_C static void Print(TPtrC aString); |
|
80 // static TInt Print(TRefByValue<const TDesC> aFmt,...); |
|
81 |
|
82 private: |
|
83 RFs iFs; |
|
84 |
|
85 TBuf<255> iString; |
|
86 // RFileLogger iFLogger; |
|
87 }; |
|
88 |
|
89 |
|
90 #endif // __TTRACER_H__ |