1 karl 1.24 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.8 //
|
3 karl 1.18 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.17 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.18 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.20 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.24 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.8 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.10 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.8 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.24 //
|
21 kumpf 1.10 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.8 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.10 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.8 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_Logger_h
35 #define Pegasus_Logger_h
36
37 #include <Pegasus/Common/Config.h>
38 #include <Pegasus/Common/Formatter.h>
|
39 kumpf 1.11 #include <Pegasus/Common/Linkage.h>
|
40 david 1.14 #include <Pegasus/Common/System.h>
|
41 mike 1.21 #include <Pegasus/Common/MessageLoader.h>
42
|
43 kumpf 1.25 // The Logger::trace optimization introduces the PEG_LOGGER_TRACE macro which
44 // propagates branch conditions wherever it is used. The optimization is
45 // disabled for C-Cover builds so the coverage of these branches is not
46 // measured.
47 #ifdef PEGASUS_CCOVER
48 # define PEG_LOGGER_TRACE(ARGS_LIST) \
49 Logger::trace ARGS_LIST
50 #else
51 # define PEG_LOGGER_TRACE(ARGS_LIST) \
|
52 mike 1.21 do \
53 { \
54 if (Logger::wouldLog(Logger::TRACE)) \
55 { \
56 Logger::trace ARGS_LIST ; \
57 } \
58 } \
59 while (0)
|
60 kumpf 1.25 #endif
|
61 mike 1.8
62 PEGASUS_NAMESPACE_BEGIN
63
64 class LoggerRep;
65
|
66 mike 1.21 /** This class provides the interface for writing log records to the log.
|
67 mike 1.8 */
68 class PEGASUS_COMMON_LINKAGE Logger
69 {
70 public:
71
|
72 david.dillard 1.22 enum LogFileType
|
73 mike 1.21 {
|
74 david.dillard 1.22 TRACE_LOG,
75 STANDARD_LOG,
|
76 kumpf 1.30 AUDIT_LOG, // Use only if PEGASUS_ENABLE_AUDIT_LOGGER is defined
|
77 marek 1.32 ERROR_LOG
|
78 mike 1.8 };
|
79 mike 1.21
|
80 marek 1.32 enum { NUM_LOGS = 4 };
|
81 david.dillard 1.22
82 /** Log file Level - Defines the loglevel of the log entry irrespective of
83 which log file it goes into. This is actually a bit mask as defined in
84 logger.cpp. Thus, it serves both as a level of indication of the
85 seriousness and possibly as a mask to select what is logged.
|
86 mike 1.8 ATTN: The selection test has not been done.
87 */
88 static const Uint32 TRACE;
89 static const Uint32 INFORMATION;
90 static const Uint32 WARNING;
91 static const Uint32 SEVERE;
92 static const Uint32 FATAL;
93
|
94 mike 1.21 /** Puts a message to the defined log file
95 @param logFileType - Type of log file (Trace, etc.)
|
96 david.dillard 1.22 @param systemId - ID of the system generating the log entry within
|
97 mike 1.21 Pegasus. This is user defined but generally breaks down into major
98 Pegasus components.
99 @param level logLevel of the log entry. To be used both t0
|
100 david.dillard 1.22 mark the log entry and tested against a mask to determine if log
|
101 mike 1.21 entry should be written.
|
102 david.dillard 1.22 @param formatString Format definition string for the Log. See the
|
103 mike 1.21 Formatter for details.
104 @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
105 that go into the log entry.
106 <pre>
|
107 kumpf 1.26 Logger::put(Logger::TRACE_LOG, System::CIMSERVER, Logger::WARNING,
|
108 mike 1.21 "X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5);
109 </pre>
110 */
111 static void put(
112 LogFileType logFileType,
113 const String& systemId,
114 Uint32 logLevel,
115 const String& formatString,
116 const Formatter::Arg& arg0,
117 const Formatter::Arg& arg1,
118 const Formatter::Arg& arg2,
119 const Formatter::Arg& arg3,
120 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
121 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
122 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
123 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
124 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
125 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
126
127 /** Optimized zero-argument form of put().
128 */
129 mike 1.21 static void put(
130 LogFileType logFileType,
131 const String& systemId,
132 Uint32 logLevel,
133 const String& formatString);
|
134 david 1.12
|
135 mike 1.21 /** Optimized one-argument form of put().
|
136 mike 1.8 */
137 static void put(
|
138 mike 1.21 LogFileType logFileType,
139 const String& systemId,
140 Uint32 logLevel,
141 const String& formatString,
142 const Formatter::Arg& arg0);
|
143 karl 1.19
|
144 mike 1.21 /** Optimized two-argument form of put().
145 */
|
146 karl 1.19 static void put(
|
147 mike 1.21 LogFileType logFileType,
148 const String& systemId,
149 Uint32 logLevel,
150 const String& formatString,
151 const Formatter::Arg& arg0,
152 const Formatter::Arg& arg1);
|
153 karl 1.19
|
154 mike 1.21 /** Optimized three-argument form of put().
155 */
|
156 karl 1.19 static void put(
|
157 mike 1.21 LogFileType logFileType,
158 const String& systemId,
159 Uint32 logLevel,
160 const String& formatString,
161 const Formatter::Arg& arg0,
162 const Formatter::Arg& arg1,
163 const Formatter::Arg& arg2);
|
164 david 1.12
|
165 chuck 1.15 /** put_l - Puts a localized message to the defined log file
|
166 mike 1.21 @param logFileType - Type of log file (Trace, etc.)
|
167 david.dillard 1.22 @param systemId - ID of the system generating the log entry within
|
168 mike 1.21 Pegasus. This is user defined but generally breaks down into major
169 Pegasus components.
170 @param level logLevel of the log entry. To be used both t0
|
171 david.dillard 1.22 mark the log entry and tested against a mask to determine if log
|
172 mike 1.21 entry should be written.
|
173 david.dillard 1.22 @param messageId Message ID of the format string to load from
174 the resource bundle.
175 @param formatString Default format definition string. See the
|
176 mike 1.21 Formatter for details. This will be used as the default format string
177 in case the resource bundle cannot be found.
178 @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
179 that go into the log entry.
180 <pre>
|
181 kumpf 1.26 Logger::put(Logger::TRACE_LOG, System::CIMSERVER, Logger::WARNING,
|
182 mike 1.21 "X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5);
183 </pre>
|
184 chuck 1.15 */
185 static void put_l(
|
186 mike 1.21 LogFileType logFileType,
187 const String& systemId,
188 Uint32 logLevel,
|
189 david.dillard 1.22 const String& messageId,
|
190 mike 1.21 const String& formatString,
191 const Formatter::Arg& arg0,
192 const Formatter::Arg& arg1,
193 const Formatter::Arg& arg2,
194 const Formatter::Arg& arg3,
195 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
196 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
197 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
198 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
199 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
200 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
201 karl 1.19
|
202 mike 1.21 /** Optimized zero-argument form of put_l().
203 */
204 static void put_l(
205 LogFileType logFileType,
206 const String& systemId,
207 Uint32 logLevel,
|
208 david.dillard 1.22 const String& messageId,
|
209 mike 1.21 const String& formatString);
210
211 /** Optimized one-argument form of put_l().
212 */
213 static void put_l(
214 LogFileType logFileType,
215 const String& systemId,
216 Uint32 logLevel,
|
217 david.dillard 1.22 const String& messageId,
|
218 mike 1.21 const String& formatString,
219 const Formatter::Arg& arg0);
220
221 /** Optimized two-argument form of put_l().
222 */
|
223 karl 1.19 static void put_l(
|
224 mike 1.21 LogFileType logFileType,
225 const String& systemId,
226 Uint32 logLevel,
|
227 david.dillard 1.22 const String& messageId,
|
228 mike 1.21 const String& formatString,
229 const Formatter::Arg& arg0,
230 const Formatter::Arg& arg1);
|
231 karl 1.19
|
232 mike 1.21 /** Optimized three-argument form of put_l().
233 */
|
234 karl 1.19 static void put_l(
|
235 mike 1.21 LogFileType logFileType,
236 const String& systemId,
237 Uint32 logLevel,
|
238 david.dillard 1.22 const String& messageId,
|
239 mike 1.21 const String& formatString,
240 const Formatter::Arg& arg0,
241 const Formatter::Arg& arg1,
242 const Formatter::Arg& arg2);
|
243 chuck 1.15
|
244 david.dillard 1.22 /** Puts a message to the define log. Should only be used for trace type
|
245 mike 1.21 logs.
246 */
|
247 david 1.12 static void trace(
|
248 mike 1.21 LogFileType logFileType,
249 const String& systemId,
250 const Uint32 logComponent,
251 const String& formatString,
252 const Formatter::Arg& arg0,
253 const Formatter::Arg& arg1,
254 const Formatter::Arg& arg2,
255 const Formatter::Arg& arg3,
256 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
257 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
258 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
259 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
260 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
|
261 david.dillard 1.22 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
262 mike 1.21
263 /** Optimized three-argument form of trace().
264 */
265 static void trace(
266 LogFileType logFileType,
267 const String& systemId,
268 const Uint32 logComponent,
269 const String& formatString);
270
271 /** Optimized one-argument form of trace().
272 */
273 static void trace(
274 LogFileType logFileType,
275 const String& systemId,
276 const Uint32 logComponent,
277 const String& formatString,
278 const Formatter::Arg& arg0);
279
280 /** Optimized two-argument form of trace().
281 */
282 static void trace(
283 mike 1.21 LogFileType logFileType,
284 const String& systemId,
285 const Uint32 logComponent,
286 const String& formatString,
287 const Formatter::Arg& arg0,
288 const Formatter::Arg& arg1);
289
290 /** Optimized three-argument form of trace().
291 */
292 static void trace(
293 LogFileType logFileType,
294 const String& systemId,
295 const Uint32 logComponent,
296 const String& formatString,
297 const Formatter::Arg& arg0,
298 const Formatter::Arg& arg1,
299 const Formatter::Arg& arg2);
|
300 chuck 1.15
|
301 mike 1.21 /** Puts a localized message to the log. Should only be used
302 for trace type logs.
303 */
|
304 chuck 1.15 static void trace_l(
|
305 mike 1.21 LogFileType logFileType,
306 const String& systemId,
307 const Uint32 logComponent,
|
308 david.dillard 1.22 const String& messageId,
|
309 mike 1.21 const String& formatString,
310 const Formatter::Arg& arg0,
311 const Formatter::Arg& arg1,
312 const Formatter::Arg& arg2,
313 const Formatter::Arg& arg3,
314 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
315 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
316 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
317 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
318 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
319 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
320 chuck 1.15
|
321 mike 1.21 /** Optimized zero-argument form of trace_l().
322 */
323 static void trace_l(
324 LogFileType logFileType,
325 const String& systemId,
326 const Uint32 logComponent,
|
327 david.dillard 1.22 const String& messageId,
|
328 mike 1.21 const String& formatString);
329
330 /** Optimized one-argument form of trace_l().
331 */
332 static void trace_l(
333 LogFileType logFileType,
334 const String& systemId,
335 const Uint32 logComponent,
|
336 david.dillard 1.22 const String& messageId,
|
337 mike 1.21 const String& formatString,
338 const Formatter::Arg& arg0);
339
340 /** Optimized two-argument form of trace_l().
341 */
342 static void trace_l(
343 LogFileType logFileType,
344 const String& systemId,
345 const Uint32 logComponent,
|
346 david.dillard 1.22 const String& messageId,
|
347 mike 1.21 const String& formatString,
348 const Formatter::Arg& arg0,
349 const Formatter::Arg& arg1);
350
351 /** Optimized three-argument form of trace_l().
352 */
353 static void trace_l(
354 LogFileType logFileType,
355 const String& systemId,
356 const Uint32 logComponent,
|
357 david.dillard 1.22 const String& messageId,
|
358 mike 1.21 const String& formatString,
359 const Formatter::Arg& arg0,
360 const Formatter::Arg& arg1,
361 const Formatter::Arg& arg2);
362
|
363 mike 1.8 /** setHomeDirectory
364 */
365 static void setHomeDirectory(const String& homeDirectory);
366
|
367 david 1.12 /** setlogLevelMask
|
368 mike 1.8 */
|
369 david 1.12 static void setlogLevelMask(const String logLevelList);
|
370 mike 1.8
|
371 mike 1.21 /** Returns true if the given string is one of the legal log levels.
372 */
|
373 david 1.12 static Boolean isValidlogLevel(const String logLevel);
|
374 mike 1.21
375 /** Tests if a log entry would be created by this call before
376 the logger is called. This function is intended to be used
377 within the server for high usage log entries to avoid the
378 overhead of doing the call when no log is created.
379 @param logLevel Uint32 defining the level of the log to be
380 executed.
381 <p><b>Example:</b>
382 <pre>
383 if (Logger::wouldLog(Logger::TRACE))
384 {
|
385 david.dillard 1.22 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
|
386 mike 1.21 Logger::TRACE, "HTTPMessage - HTTP header name: $0 "
387 "HTTP header value: $1" ,name,value);
388 }
389 </pre>
390 */
|
391 david.dillard 1.22 static Boolean wouldLog(Uint32 logLevel)
|
392 mike 1.21 {
|
393 david.dillard 1.22 return (_severityMask & logLevel) != 0;
|
394 mike 1.21 }
395
|
396 mike 1.8 private:
397
398 static LoggerRep* _rep;
399 static String _homeDirectory;
400 static Uint32 _severityMask;
|
401 david 1.12
402 static const Uint32 _NUM_LOGLEVEL;
403
404 static void _putInternal(
|
405 mike 1.21 LogFileType logFileType,
406 const String& systemId,
407 const Uint32 logComponent,
408 Uint32 logLevel,
409 const String& formatString,
410 const String& messageId,
411 const Formatter::Arg& arg0 = Formatter::DEFAULT_ARG,
412 const Formatter::Arg& arg1 = Formatter::DEFAULT_ARG,
413 const Formatter::Arg& arg2 = Formatter::DEFAULT_ARG,
414 const Formatter::Arg& arg3 = Formatter::DEFAULT_ARG,
415 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
416 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
417 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
418 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
419 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
420 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
421 mike 1.8 };
422
423 PEGASUS_NAMESPACE_END
424
425 #endif /* Pegasus_Logger_h */
|