|
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: This module contains implementation of COutput |
|
15 * class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include "Output.h" |
|
22 #include "FileOutput.h" |
|
23 #include "NullOutput.h" |
|
24 #include "LoggerOverFlow.h" |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 // None |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 // None |
|
31 |
|
32 // CONSTANTS |
|
33 // None |
|
34 |
|
35 // MACROS |
|
36 // None |
|
37 |
|
38 // LOCAL CONSTANTS AND MACROS |
|
39 // None |
|
40 |
|
41 // MODULE DATA STRUCTURES |
|
42 // None |
|
43 |
|
44 // LOCAL FUNCTION PROTOTYPES |
|
45 // None |
|
46 |
|
47 // FORWARD DECLARATIONS |
|
48 // None |
|
49 |
|
50 // ==================== LOCAL FUNCTIONS ======================================= |
|
51 // None |
|
52 |
|
53 // ================= MEMBER FUNCTIONS ========================================= |
|
54 |
|
55 /* |
|
56 ------------------------------------------------------------------------------- |
|
57 |
|
58 Class: COutput |
|
59 |
|
60 Method: COutput |
|
61 |
|
62 Description: Default constructor |
|
63 |
|
64 C++ default constructor can NOT contain any code, that |
|
65 might leave. |
|
66 |
|
67 Parameters: None |
|
68 |
|
69 Return Values: None |
|
70 |
|
71 Errors/Exceptions: None |
|
72 |
|
73 Status: Approved |
|
74 |
|
75 ------------------------------------------------------------------------------- |
|
76 */ |
|
77 COutput::COutput() |
|
78 { |
|
79 |
|
80 } |
|
81 |
|
82 /* |
|
83 ------------------------------------------------------------------------------- |
|
84 |
|
85 Class: COutput |
|
86 |
|
87 Method: NewL |
|
88 |
|
89 Description: Two-phased constructor. |
|
90 |
|
91 NOTE: At the moment there is only one output module implemented |
|
92 |
|
93 Parameters: const TDesC& aTestPath: in: Path to logged information |
|
94 const TDesC& aTestFile: in: Log name for information |
|
95 TLoggerType aLoggerType: in: Log file type |
|
96 TOutput aOutput: in: Output source |
|
97 TBool aOverWrite: in: Indicator to file overwrite |
|
98 TBool aWithTimeStamp: in: Indicator to time stamp |
|
99 TBool aWithLineBreak: in: Indicator to line break |
|
100 TBool aWithEventRanking: in: Indicator to event ranking |
|
101 TBool aThreadIdToLogFile: in: Indicator to thread id adding to |
|
102 end of the log file |
|
103 TBool aCreateLogDir: in: Indicator to directory creation |
|
104 TInt aStaticBufferSize |
|
105 TBool aUnicode: in: Indicator if file has to be in unicode format |
|
106 |
|
107 Return Values: COutput*: pointer to COutput object |
|
108 |
|
109 Errors/Exceptions: Leaves if called CFileOutput::NewL method fails |
|
110 |
|
111 Status: Proposal |
|
112 |
|
113 ------------------------------------------------------------------------------- |
|
114 */ |
|
115 COutput* COutput::NewL( const TDesC& aTestPath, |
|
116 const TDesC& aTestFile, |
|
117 CStifLogger::TLoggerType aLoggerType, |
|
118 CStifLogger::TOutput aOutput, |
|
119 TBool aOverWrite, |
|
120 TBool aWithTimeStamp, |
|
121 TBool aWithLineBreak, |
|
122 TBool aWithEventRanking, |
|
123 TBool aThreadIdToLogFile, |
|
124 TBool aCreateLogDir, |
|
125 TInt aStaticBufferSize, |
|
126 TBool aUnicode ) |
|
127 { |
|
128 |
|
129 if ( aOutput == CStifLogger::EFile ) |
|
130 { |
|
131 CFileOutput* fileOutput = NULL; |
|
132 // Create CFileOutput object fileOutput |
|
133 TRAPD( err, fileOutput = CFileOutput::NewL( aTestPath, |
|
134 aTestFile, |
|
135 aLoggerType, |
|
136 aOverWrite, |
|
137 aWithTimeStamp, |
|
138 aWithLineBreak, |
|
139 aWithEventRanking, |
|
140 aThreadIdToLogFile, |
|
141 aCreateLogDir, |
|
142 aStaticBufferSize, |
|
143 aUnicode ) ); |
|
144 |
|
145 // Probably path or file name is over allowed size |
|
146 if ( err == KErrArgument ) |
|
147 { |
|
148 User::Leave( KErrArgument ); |
|
149 return NULL; // Never return because leave above |
|
150 } |
|
151 // Not enough memory, @js |
|
152 else if ( err == KErrNoMemory ) |
|
153 { |
|
154 User::Leave( KErrNoMemory ); |
|
155 return NULL; |
|
156 } |
|
157 // If e.g. path not found so we create CNullOutput to avoiding leave |
|
158 // operation. CNullOutput looks logging although it won't. |
|
159 else if ( err != KErrNone ) |
|
160 { |
|
161 CNullOutput* nullOutput = CNullOutput::NewL(); |
|
162 nullOutput->SetOutputCreationResult( err, aOutput ); |
|
163 return nullOutput; |
|
164 } |
|
165 // CFileOutput creation made succesfully |
|
166 else |
|
167 { |
|
168 fileOutput->SetOutputCreationResult( err, aOutput ); |
|
169 return fileOutput; |
|
170 } |
|
171 } |
|
172 else if ( aOutput == CStifLogger::ERDebug ) |
|
173 { |
|
174 CRDebugOutput* rdebugOutput = NULL; |
|
175 // Create CRDebugOutput object rdebugOutput |
|
176 TRAPD( err, rdebugOutput = CRDebugOutput::NewL( aTestPath, |
|
177 aTestFile, |
|
178 aLoggerType, |
|
179 aOverWrite, |
|
180 aWithTimeStamp, |
|
181 aWithLineBreak, |
|
182 aWithEventRanking, |
|
183 aThreadIdToLogFile, |
|
184 aCreateLogDir, |
|
185 aStaticBufferSize ) ); |
|
186 |
|
187 // Probably path or file name is over allowed size |
|
188 if ( err == KErrArgument ) |
|
189 { |
|
190 User::Leave( KErrArgument ); |
|
191 return NULL; // Never return because leave above |
|
192 } |
|
193 // If e.g. no memory so we create CNullOutput to avoiding leave |
|
194 // operation. CNullOutput looks logging although it won't. |
|
195 else if ( err != KErrNone ) |
|
196 { |
|
197 CNullOutput* nullOutput = CNullOutput::NewL(); |
|
198 nullOutput->SetOutputCreationResult( err, aOutput ); |
|
199 return nullOutput; |
|
200 } |
|
201 // CRDebugOutput creation made succesfully |
|
202 else |
|
203 { |
|
204 rdebugOutput->SetOutputCreationResult( err, aOutput ); |
|
205 return rdebugOutput; |
|
206 } |
|
207 } |
|
208 else |
|
209 { |
|
210 User::Leave( KErrArgument ); |
|
211 return NULL; // Never return because leave above |
|
212 } |
|
213 |
|
214 } |
|
215 |
|
216 /* |
|
217 ------------------------------------------------------------------------------- |
|
218 |
|
219 Class: COutput |
|
220 |
|
221 Method: ~COutput |
|
222 |
|
223 Description: Destructor |
|
224 |
|
225 Parameters: None |
|
226 |
|
227 Return Values: None |
|
228 |
|
229 Errors/Exceptions: None |
|
230 |
|
231 Status: Approved |
|
232 |
|
233 ------------------------------------------------------------------------------- |
|
234 */ |
|
235 COutput::~COutput() |
|
236 { |
|
237 |
|
238 } |
|
239 |
|
240 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
241 // None |
|
242 |
|
243 // End of File |