|
1 // Copyright (c) 1997-2009 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 // This file contains the class definitions and normal definitions for use by |
|
15 // the CTelLogger. |
|
16 // There are two defines that are used to determine which set of macros are to be |
|
17 // used. First, if DEBUG is defined the LOGTEXTn macros are implemented, but the |
|
18 // LOGTEXTRELn macros are not. If DEBUG is NOT defined the LOGTEXTn macros are not |
|
19 // implemented but the LOGTEXTRELn macros are. |
|
20 // All of these macros are abstractions for calls to CETelLogger::Write or |
|
21 // CETelLogger::WriteFormat. |
|
22 // |
|
23 // |
|
24 |
|
25 /** |
|
26 @file |
|
27 @internalComponent |
|
28 */ |
|
29 |
|
30 #include <f32file.h> |
|
31 |
|
32 #define __LOGGER__ |
|
33 |
|
34 #if defined (_DEBUG) |
|
35 |
|
36 #ifdef __LOGGER__ |
|
37 #define LOGTEXT(AAA) CETelLogger::Write(AAA) |
|
38 #else |
|
39 #define LOGTEXT(AAA) |
|
40 #endif |
|
41 |
|
42 #ifdef __LOGGER__ |
|
43 #define LOGTEXT2(AAA,BBB) CETelLogger::WriteFormat(TRefByValue<const TDesC8>(AAA),BBB) |
|
44 #else |
|
45 #define LOGTEXT2(AAA,BBB) |
|
46 #endif |
|
47 |
|
48 #ifdef __LOGGER__ |
|
49 #define LOGTEXT3(AAA,BBB,CCC) CETelLogger::WriteFormat(TRefByValue<const TDesC8>(AAA),BBB,CCC) |
|
50 #else |
|
51 #define LOGTEXT3(AAA,BBB,CCC) |
|
52 #endif |
|
53 |
|
54 #define LOGTEXTREL(AAA) |
|
55 #define LOGTEXTREL2(AAA,BBB) |
|
56 #define LOGTEXTREL3(AAA,BBB,CCC) |
|
57 |
|
58 #else |
|
59 |
|
60 #define LOGTEXT(AAA) |
|
61 #define LOGTEXT2(AAA,BBB) |
|
62 #define LOGTEXT3(AAA,BBB,CCC) |
|
63 |
|
64 #ifdef __LOGGER__ |
|
65 #define LOGTEXTREL(AAA) CETelLogger::Write(AAA) |
|
66 #else |
|
67 #define LOGTEXTREL(AAA) |
|
68 #endif |
|
69 |
|
70 #ifdef __LOGGER__ |
|
71 #define LOGTEXTREL2(AAA,BBB) CETelLogger::WriteFormat(TRefByValue<const TDesC8>(AAA),BBB) |
|
72 #else |
|
73 #define LOGTEXTREL2(AAA,BBB) |
|
74 #endif |
|
75 |
|
76 #ifdef __LOGGER__ |
|
77 #define LOGTEXTREL3(AAA,BBB,CCC) CETelLogger::WriteFormat(TRefByValue<const TDesC8>(AAA),BBB,CCC) |
|
78 #else |
|
79 #define LOGTEXTREL3(AAA,BBB,CCC) |
|
80 #endif |
|
81 |
|
82 #endif |
|
83 |
|
84 #ifdef __LOGGER__ |
|
85 #define LOGDESTROY() CETelLogger::Destruct() |
|
86 #else |
|
87 #define LOGDESTROY() |
|
88 #endif |
|
89 |
|
90 |
|
91 #ifndef __LOGGER_H |
|
92 #define __LOGGER_H |
|
93 |
|
94 #ifdef __LOGGER__ |
|
95 |
|
96 /** |
|
97 * This class inherits from the CBase class. It defines the methods necessary for |
|
98 * driving the logging functions. |
|
99 */ |
|
100 class CETelLogger : public CBase |
|
101 { |
|
102 public: |
|
103 static CETelLogger* NewL(); |
|
104 CETelLogger(); |
|
105 void ConstructL(); |
|
106 static void Destruct(); |
|
107 ~CETelLogger(); |
|
108 static void WriteL(const TDesC8& aText); |
|
109 static void Write(const TText8* aText); |
|
110 static void WriteFormat(TRefByValue<const TDesC8> aFmt,...); |
|
111 void WriteRecord(const TDesC8& aText); |
|
112 private: |
|
113 TBool FolderExists(); |
|
114 private: |
|
115 TBool iValid; //< flag that denotes if logging is possible. Set to True if |
|
116 //< if appropriate directory exists and the file can be opened. |
|
117 //< if False, then logging calls will exit without writing data. |
|
118 RFs iFs; //< Handle for the File Server |
|
119 RFile iFile; //< File Handle |
|
120 }; |
|
121 |
|
122 #endif // __LOGGER__ |
|
123 |
|
124 #endif // __LOGGER_H |