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