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 // Author: Mike Brasher (mbrasher@bmc.com)
33 //
|
34 david 1.12 // Modified By: Dave Rosckes (rosckes@us.ibm.com)
|
35 david.dillard 1.22 // David Dillard, Symantec Corp. (david_dillard@symantec.com)
|
36 mike 1.8 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39 #ifndef Pegasus_Logger_h
40 #define Pegasus_Logger_h
41
42 #include <Pegasus/Common/Config.h>
43 #include <Pegasus/Common/Formatter.h>
|
44 kumpf 1.11 #include <Pegasus/Common/Linkage.h>
|
45 david 1.14 #include <Pegasus/Common/System.h>
|
46 mike 1.21 #include <Pegasus/Common/MessageLoader.h>
47
|
48 kumpf 1.25 // The Logger::trace optimization introduces the PEG_LOGGER_TRACE macro which
49 // propagates branch conditions wherever it is used. The optimization is
50 // disabled for C-Cover builds so the coverage of these branches is not
51 // measured.
52 #ifdef PEGASUS_CCOVER
53 # define PEG_LOGGER_TRACE(ARGS_LIST) \
54 Logger::trace ARGS_LIST
55 #else
56 # define PEG_LOGGER_TRACE(ARGS_LIST) \
|
57 mike 1.21 do \
58 { \
59 if (Logger::wouldLog(Logger::TRACE)) \
60 { \
61 Logger::trace ARGS_LIST ; \
62 } \
63 } \
64 while (0)
|
65 kumpf 1.25 #endif
|
66 mike 1.8
67 PEGASUS_NAMESPACE_BEGIN
68
69 class LoggerRep;
70
|
71 mike 1.21 /** This class provides the interface for writing log records to the log.
|
72 mike 1.8 */
73 class PEGASUS_COMMON_LINKAGE Logger
74 {
75 public:
76
|
77 david.dillard 1.22 enum LogFileType
|
78 mike 1.21 {
|
79 david.dillard 1.22 TRACE_LOG,
80 STANDARD_LOG,
|
81 mike 1.21 ERROR_LOG,
82 DEBUG_LOG
|
83 mike 1.8 };
|
84 mike 1.21
|
85 mike 1.8 enum { NUM_LOGS = 4 };
|
86 david.dillard 1.22
87 /** Log file Level - Defines the loglevel of the log entry irrespective of
88 which log file it goes into. This is actually a bit mask as defined in
89 logger.cpp. Thus, it serves both as a level of indication of the
90 seriousness and possibly as a mask to select what is logged.
|
91 mike 1.8 ATTN: The selection test has not been done.
92 */
93 static const Uint32 TRACE;
94 static const Uint32 INFORMATION;
95 static const Uint32 WARNING;
96 static const Uint32 SEVERE;
97 static const Uint32 FATAL;
98
|
99 mike 1.21 /** Puts a message to the defined log file
100 @param logFileType - Type of log file (Trace, etc.)
|
101 david.dillard 1.22 @param systemId - ID of the system generating the log entry within
|
102 mike 1.21 Pegasus. This is user defined but generally breaks down into major
103 Pegasus components.
104 @param level logLevel of the log entry. To be used both t0
|
105 david.dillard 1.22 mark the log entry and tested against a mask to determine if log
|
106 mike 1.21 entry should be written.
|
107 david.dillard 1.22 @param formatString Format definition string for the Log. See the
|
108 mike 1.21 Formatter for details.
109 @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
110 that go into the log entry.
111 <pre>
112 Logger::put(Logger::TRACE_LOG, "CIMServer", Logger::WARNING,
113 "X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5);
114 </pre>
115 */
116 static void put(
117 LogFileType logFileType,
118 const String& systemId,
119 Uint32 logLevel,
120 const String& formatString,
121 const Formatter::Arg& arg0,
122 const Formatter::Arg& arg1,
123 const Formatter::Arg& arg2,
124 const Formatter::Arg& arg3,
125 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
126 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
127 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
128 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
129 mike 1.21 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
130 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
131
132 /** Optimized zero-argument form of put().
133 */
134 static void put(
135 LogFileType logFileType,
136 const String& systemId,
137 Uint32 logLevel,
138 const String& formatString);
|
139 david 1.12
|
140 mike 1.21 /** Optimized one-argument form of put().
|
141 mike 1.8 */
142 static void put(
|
143 mike 1.21 LogFileType logFileType,
144 const String& systemId,
145 Uint32 logLevel,
146 const String& formatString,
147 const Formatter::Arg& arg0);
|
148 karl 1.19
|
149 mike 1.21 /** Optimized two-argument form of put().
150 */
|
151 karl 1.19 static void put(
|
152 mike 1.21 LogFileType logFileType,
153 const String& systemId,
154 Uint32 logLevel,
155 const String& formatString,
156 const Formatter::Arg& arg0,
157 const Formatter::Arg& arg1);
|
158 karl 1.19
|
159 mike 1.21 /** Optimized three-argument form of put().
160 */
|
161 karl 1.19 static void put(
|
162 mike 1.21 LogFileType logFileType,
163 const String& systemId,
164 Uint32 logLevel,
165 const String& formatString,
166 const Formatter::Arg& arg0,
167 const Formatter::Arg& arg1,
168 const Formatter::Arg& arg2);
|
169 david 1.12
|
170 chuck 1.15 /** put_l - Puts a localized message to the defined log file
|
171 mike 1.21 @param logFileType - Type of log file (Trace, etc.)
|
172 david.dillard 1.22 @param systemId - ID of the system generating the log entry within
|
173 mike 1.21 Pegasus. This is user defined but generally breaks down into major
174 Pegasus components.
175 @param level logLevel of the log entry. To be used both t0
|
176 david.dillard 1.22 mark the log entry and tested against a mask to determine if log
|
177 mike 1.21 entry should be written.
|
178 david.dillard 1.22 @param messageId Message ID of the format string to load from
179 the resource bundle.
180 @param formatString Default format definition string. See the
|
181 mike 1.21 Formatter for details. This will be used as the default format string
182 in case the resource bundle cannot be found.
183 @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
184 that go into the log entry.
185 <pre>
186 Logger::put(Logger::TRACE_LOG, "CIMServer", Logger::WARNING,
187 "X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5);
188 </pre>
|
189 chuck 1.15 */
190 static void put_l(
|
191 mike 1.21 LogFileType logFileType,
192 const String& systemId,
193 Uint32 logLevel,
|
194 david.dillard 1.22 const String& messageId,
|
195 mike 1.21 const String& formatString,
196 const Formatter::Arg& arg0,
197 const Formatter::Arg& arg1,
198 const Formatter::Arg& arg2,
199 const Formatter::Arg& arg3,
200 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
201 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
202 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
203 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
204 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
205 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
206 karl 1.19
|
207 mike 1.21 /** Optimized zero-argument form of put_l().
208 */
209 static void put_l(
210 LogFileType logFileType,
211 const String& systemId,
212 Uint32 logLevel,
|
213 david.dillard 1.22 const String& messageId,
|
214 mike 1.21 const String& formatString);
215
216 /** Optimized one-argument form of put_l().
217 */
218 static void put_l(
219 LogFileType logFileType,
220 const String& systemId,
221 Uint32 logLevel,
|
222 david.dillard 1.22 const String& messageId,
|
223 mike 1.21 const String& formatString,
224 const Formatter::Arg& arg0);
225
226 /** Optimized two-argument form of put_l().
227 */
|
228 karl 1.19 static void put_l(
|
229 mike 1.21 LogFileType logFileType,
230 const String& systemId,
231 Uint32 logLevel,
|
232 david.dillard 1.22 const String& messageId,
|
233 mike 1.21 const String& formatString,
234 const Formatter::Arg& arg0,
235 const Formatter::Arg& arg1);
|
236 karl 1.19
|
237 mike 1.21 /** Optimized three-argument form of put_l().
238 */
|
239 karl 1.19 static void put_l(
|
240 mike 1.21 LogFileType logFileType,
241 const String& systemId,
242 Uint32 logLevel,
|
243 david.dillard 1.22 const String& messageId,
|
244 mike 1.21 const String& formatString,
245 const Formatter::Arg& arg0,
246 const Formatter::Arg& arg1,
247 const Formatter::Arg& arg2);
|
248 chuck 1.15
|
249 david.dillard 1.22 /** Puts a message to the define log. Should only be used for trace type
|
250 mike 1.21 logs.
251 */
|
252 david 1.12 static void trace(
|
253 mike 1.21 LogFileType logFileType,
254 const String& systemId,
255 const Uint32 logComponent,
256 const String& formatString,
257 const Formatter::Arg& arg0,
258 const Formatter::Arg& arg1,
259 const Formatter::Arg& arg2,
260 const Formatter::Arg& arg3,
261 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
262 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
263 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
264 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
265 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
|
266 david.dillard 1.22 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
267 mike 1.21
268 /** Optimized three-argument form of trace().
269 */
270 static void trace(
271 LogFileType logFileType,
272 const String& systemId,
273 const Uint32 logComponent,
274 const String& formatString);
275
276 /** Optimized one-argument form of trace().
277 */
278 static void trace(
279 LogFileType logFileType,
280 const String& systemId,
281 const Uint32 logComponent,
282 const String& formatString,
283 const Formatter::Arg& arg0);
284
285 /** Optimized two-argument form of trace().
286 */
287 static void trace(
288 mike 1.21 LogFileType logFileType,
289 const String& systemId,
290 const Uint32 logComponent,
291 const String& formatString,
292 const Formatter::Arg& arg0,
293 const Formatter::Arg& arg1);
294
295 /** Optimized three-argument form of trace().
296 */
297 static void trace(
298 LogFileType logFileType,
299 const String& systemId,
300 const Uint32 logComponent,
301 const String& formatString,
302 const Formatter::Arg& arg0,
303 const Formatter::Arg& arg1,
304 const Formatter::Arg& arg2);
|
305 chuck 1.15
|
306 mike 1.21 /** Puts a localized message to the log. Should only be used
307 for trace type logs.
308 */
|
309 chuck 1.15 static void trace_l(
|
310 mike 1.21 LogFileType logFileType,
311 const String& systemId,
312 const Uint32 logComponent,
|
313 david.dillard 1.22 const String& messageId,
|
314 mike 1.21 const String& formatString,
315 const Formatter::Arg& arg0,
316 const Formatter::Arg& arg1,
317 const Formatter::Arg& arg2,
318 const Formatter::Arg& arg3,
319 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
320 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
321 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
322 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
323 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
324 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
325 chuck 1.15
|
326 mike 1.21 /** Optimized zero-argument form of trace_l().
327 */
328 static void trace_l(
329 LogFileType logFileType,
330 const String& systemId,
331 const Uint32 logComponent,
|
332 david.dillard 1.22 const String& messageId,
|
333 mike 1.21 const String& formatString);
334
335 /** Optimized one-argument form of trace_l().
336 */
337 static void trace_l(
338 LogFileType logFileType,
339 const String& systemId,
340 const Uint32 logComponent,
|
341 david.dillard 1.22 const String& messageId,
|
342 mike 1.21 const String& formatString,
343 const Formatter::Arg& arg0);
344
345 /** Optimized two-argument form of trace_l().
346 */
347 static void trace_l(
348 LogFileType logFileType,
349 const String& systemId,
350 const Uint32 logComponent,
|
351 david.dillard 1.22 const String& messageId,
|
352 mike 1.21 const String& formatString,
353 const Formatter::Arg& arg0,
354 const Formatter::Arg& arg1);
355
356 /** Optimized three-argument form of trace_l().
357 */
358 static void trace_l(
359 LogFileType logFileType,
360 const String& systemId,
361 const Uint32 logComponent,
|
362 david.dillard 1.22 const String& messageId,
|
363 mike 1.21 const String& formatString,
364 const Formatter::Arg& arg0,
365 const Formatter::Arg& arg1,
366 const Formatter::Arg& arg2);
367
|
368 mike 1.8 /** setHomeDirectory
369 */
370 static void setHomeDirectory(const String& homeDirectory);
371
|
372 david 1.12 /** setlogLevelMask
|
373 mike 1.8 */
|
374 david 1.12 static void setlogLevelMask(const String logLevelList);
|
375 mike 1.8
376 /** setLogWriteControlMask
377 */
378 static void setLogWriteControlMask(const Uint32);
379
|
380 mike 1.21 /** Returns true if the given string is one of the legal log levels.
381 */
|
382 david 1.12 static Boolean isValidlogLevel(const String logLevel);
|
383 mike 1.21
384 /** Tests if a log entry would be created by this call before
385 the logger is called. This function is intended to be used
386 within the server for high usage log entries to avoid the
387 overhead of doing the call when no log is created.
388 @param logLevel Uint32 defining the level of the log to be
389 executed.
390 <p><b>Example:</b>
391 <pre>
392 if (Logger::wouldLog(Logger::TRACE))
393 {
|
394 david.dillard 1.22 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
|
395 mike 1.21 Logger::TRACE, "HTTPMessage - HTTP header name: $0 "
396 "HTTP header value: $1" ,name,value);
397 }
398 </pre>
399 */
|
400 david.dillard 1.22 static Boolean wouldLog(Uint32 logLevel)
|
401 mike 1.21 {
|
402 david.dillard 1.22 return (_severityMask & logLevel) != 0;
|
403 mike 1.21 }
404
|
405 mike 1.8 private:
406
407 static LoggerRep* _rep;
408 static String _homeDirectory;
409 static Uint32 _severityMask;
410 static Uint32 _writeControlMask;
|
411 david 1.12
412 static const char _SEPARATOR;
413 static const Uint32 _NUM_LOGLEVEL;
414
415 static const Boolean _SUCCESS;
416 static const Boolean _FAILURE;
|
417 mike 1.21
|
418 david 1.12 static void _putInternal(
|
419 mike 1.21 LogFileType logFileType,
420 const String& systemId,
421 const Uint32 logComponent,
422 Uint32 logLevel,
423 const String& formatString,
424 const String& messageId,
425 const Formatter::Arg& arg0 = Formatter::DEFAULT_ARG,
426 const Formatter::Arg& arg1 = Formatter::DEFAULT_ARG,
427 const Formatter::Arg& arg2 = Formatter::DEFAULT_ARG,
428 const Formatter::Arg& arg3 = Formatter::DEFAULT_ARG,
429 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
430 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
431 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
432 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
433 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
434 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
435 mike 1.8 };
436
437 PEGASUS_NAMESPACE_END
438
439 #endif /* Pegasus_Logger_h */
|