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 #define PEG_LOGGER_TRACE(ARGS_LIST) \
49 do \
50 { \
51 if (Logger::wouldLog(Logger::TRACE)) \
52 { \
53 Logger::trace ARGS_LIST ; \
54 } \
55 } \
56 while (0)
|
57 mike 1.8
58 PEGASUS_NAMESPACE_BEGIN
59
60 class LoggerRep;
61
|
62 mike 1.21 /** This class provides the interface for writing log records to the log.
|
63 mike 1.8 */
64 class PEGASUS_COMMON_LINKAGE Logger
65 {
66 public:
67
|
68 david.dillard 1.22 enum LogFileType
|
69 mike 1.21 {
|
70 david.dillard 1.22 TRACE_LOG,
71 STANDARD_LOG,
|
72 mike 1.21 ERROR_LOG,
73 DEBUG_LOG
|
74 mike 1.8 };
|
75 mike 1.21
|
76 mike 1.8 enum { NUM_LOGS = 4 };
|
77 david.dillard 1.22
78 /** Log file Level - Defines the loglevel of the log entry irrespective of
79 which log file it goes into. This is actually a bit mask as defined in
80 logger.cpp. Thus, it serves both as a level of indication of the
81 seriousness and possibly as a mask to select what is logged.
|
82 mike 1.8 ATTN: The selection test has not been done.
83 */
84 static const Uint32 TRACE;
85 static const Uint32 INFORMATION;
86 static const Uint32 WARNING;
87 static const Uint32 SEVERE;
88 static const Uint32 FATAL;
89
|
90 mike 1.21 /** Puts a message to the defined log file
91 @param logFileType - Type of log file (Trace, etc.)
|
92 david.dillard 1.22 @param systemId - ID of the system generating the log entry within
|
93 mike 1.21 Pegasus. This is user defined but generally breaks down into major
94 Pegasus components.
95 @param level logLevel of the log entry. To be used both t0
|
96 david.dillard 1.22 mark the log entry and tested against a mask to determine if log
|
97 mike 1.21 entry should be written.
|
98 david.dillard 1.22 @param formatString Format definition string for the Log. See the
|
99 mike 1.21 Formatter for details.
100 @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
101 that go into the log entry.
102 <pre>
103 Logger::put(Logger::TRACE_LOG, "CIMServer", Logger::WARNING,
104 "X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5);
105 </pre>
106 */
107 static void put(
108 LogFileType logFileType,
109 const String& systemId,
110 Uint32 logLevel,
111 const String& formatString,
112 const Formatter::Arg& arg0,
113 const Formatter::Arg& arg1,
114 const Formatter::Arg& arg2,
115 const Formatter::Arg& arg3,
116 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
117 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
118 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
119 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
120 mike 1.21 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
121 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
122
123 /** Optimized zero-argument form of put().
124 */
125 static void put(
126 LogFileType logFileType,
127 const String& systemId,
128 Uint32 logLevel,
129 const String& formatString);
|
130 david 1.12
|
131 mike 1.21 /** Optimized one-argument form of put().
|
132 mike 1.8 */
133 static void put(
|
134 mike 1.21 LogFileType logFileType,
135 const String& systemId,
136 Uint32 logLevel,
137 const String& formatString,
138 const Formatter::Arg& arg0);
|
139 karl 1.19
|
140 mike 1.21 /** Optimized two-argument form of put().
141 */
|
142 karl 1.19 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 const Formatter::Arg& arg1);
|
149 karl 1.19
|
150 mike 1.21 /** Optimized three-argument form of put().
151 */
|
152 karl 1.19 static void put(
|
153 mike 1.21 LogFileType logFileType,
154 const String& systemId,
155 Uint32 logLevel,
156 const String& formatString,
157 const Formatter::Arg& arg0,
158 const Formatter::Arg& arg1,
159 const Formatter::Arg& arg2);
|
160 david 1.12
|
161 chuck 1.15 /** put_l - Puts a localized message to the defined log file
|
162 mike 1.21 @param logFileType - Type of log file (Trace, etc.)
|
163 david.dillard 1.22 @param systemId - ID of the system generating the log entry within
|
164 mike 1.21 Pegasus. This is user defined but generally breaks down into major
165 Pegasus components.
166 @param level logLevel of the log entry. To be used both t0
|
167 david.dillard 1.22 mark the log entry and tested against a mask to determine if log
|
168 mike 1.21 entry should be written.
|
169 david.dillard 1.22 @param messageId Message ID of the format string to load from
170 the resource bundle.
171 @param formatString Default format definition string. See the
|
172 mike 1.21 Formatter for details. This will be used as the default format string
173 in case the resource bundle cannot be found.
174 @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
175 that go into the log entry.
176 <pre>
177 Logger::put(Logger::TRACE_LOG, "CIMServer", Logger::WARNING,
178 "X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5);
179 </pre>
|
180 chuck 1.15 */
181 static void put_l(
|
182 mike 1.21 LogFileType logFileType,
183 const String& systemId,
184 Uint32 logLevel,
|
185 david.dillard 1.22 const String& messageId,
|
186 mike 1.21 const String& formatString,
187 const Formatter::Arg& arg0,
188 const Formatter::Arg& arg1,
189 const Formatter::Arg& arg2,
190 const Formatter::Arg& arg3,
191 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
192 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
193 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
194 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
195 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
196 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
197 karl 1.19
|
198 mike 1.21 /** Optimized zero-argument form of put_l().
199 */
200 static void put_l(
201 LogFileType logFileType,
202 const String& systemId,
203 Uint32 logLevel,
|
204 david.dillard 1.22 const String& messageId,
|
205 mike 1.21 const String& formatString);
206
207 /** Optimized one-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 const Formatter::Arg& arg0);
216
217 /** Optimized two-argument form of put_l().
218 */
|
219 karl 1.19 static void put_l(
|
220 mike 1.21 LogFileType logFileType,
221 const String& systemId,
222 Uint32 logLevel,
|
223 david.dillard 1.22 const String& messageId,
|
224 mike 1.21 const String& formatString,
225 const Formatter::Arg& arg0,
226 const Formatter::Arg& arg1);
|
227 karl 1.19
|
228 mike 1.21 /** Optimized three-argument form of put_l().
229 */
|
230 karl 1.19 static void put_l(
|
231 mike 1.21 LogFileType logFileType,
232 const String& systemId,
233 Uint32 logLevel,
|
234 david.dillard 1.22 const String& messageId,
|
235 mike 1.21 const String& formatString,
236 const Formatter::Arg& arg0,
237 const Formatter::Arg& arg1,
238 const Formatter::Arg& arg2);
|
239 chuck 1.15
|
240 david.dillard 1.22 /** Puts a message to the define log. Should only be used for trace type
|
241 mike 1.21 logs.
242 */
|
243 david 1.12 static void trace(
|
244 mike 1.21 LogFileType logFileType,
245 const String& systemId,
246 const Uint32 logComponent,
247 const String& formatString,
248 const Formatter::Arg& arg0,
249 const Formatter::Arg& arg1,
250 const Formatter::Arg& arg2,
251 const Formatter::Arg& arg3,
252 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
253 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
254 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
255 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
256 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
|
257 david.dillard 1.22 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
258 mike 1.21
259 /** Optimized three-argument form of trace().
260 */
261 static void trace(
262 LogFileType logFileType,
263 const String& systemId,
264 const Uint32 logComponent,
265 const String& formatString);
266
267 /** Optimized one-argument form of trace().
268 */
269 static void trace(
270 LogFileType logFileType,
271 const String& systemId,
272 const Uint32 logComponent,
273 const String& formatString,
274 const Formatter::Arg& arg0);
275
276 /** Optimized two-argument form of trace().
277 */
278 static void trace(
279 mike 1.21 LogFileType logFileType,
280 const String& systemId,
281 const Uint32 logComponent,
282 const String& formatString,
283 const Formatter::Arg& arg0,
284 const Formatter::Arg& arg1);
285
286 /** Optimized three-argument form of trace().
287 */
288 static void trace(
289 LogFileType logFileType,
290 const String& systemId,
291 const Uint32 logComponent,
292 const String& formatString,
293 const Formatter::Arg& arg0,
294 const Formatter::Arg& arg1,
295 const Formatter::Arg& arg2);
|
296 chuck 1.15
|
297 mike 1.21 /** Puts a localized message to the log. Should only be used
298 for trace type logs.
299 */
|
300 chuck 1.15 static void trace_l(
|
301 mike 1.21 LogFileType logFileType,
302 const String& systemId,
303 const Uint32 logComponent,
|
304 david.dillard 1.22 const String& messageId,
|
305 mike 1.21 const String& formatString,
306 const Formatter::Arg& arg0,
307 const Formatter::Arg& arg1,
308 const Formatter::Arg& arg2,
309 const Formatter::Arg& arg3,
310 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
311 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
312 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
313 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
314 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
315 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
316 chuck 1.15
|
317 mike 1.21 /** Optimized zero-argument form of trace_l().
318 */
319 static void trace_l(
320 LogFileType logFileType,
321 const String& systemId,
322 const Uint32 logComponent,
|
323 david.dillard 1.22 const String& messageId,
|
324 mike 1.21 const String& formatString);
325
326 /** Optimized one-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 const Formatter::Arg& arg0);
335
336 /** Optimized two-argument form of trace_l().
337 */
338 static void trace_l(
339 LogFileType logFileType,
340 const String& systemId,
341 const Uint32 logComponent,
|
342 david.dillard 1.22 const String& messageId,
|
343 mike 1.21 const String& formatString,
344 const Formatter::Arg& arg0,
345 const Formatter::Arg& arg1);
346
347 /** Optimized three-argument form of trace_l().
348 */
349 static void trace_l(
350 LogFileType logFileType,
351 const String& systemId,
352 const Uint32 logComponent,
|
353 david.dillard 1.22 const String& messageId,
|
354 mike 1.21 const String& formatString,
355 const Formatter::Arg& arg0,
356 const Formatter::Arg& arg1,
357 const Formatter::Arg& arg2);
358
|
359 mike 1.8 /** setHomeDirectory
360 */
361 static void setHomeDirectory(const String& homeDirectory);
362
|
363 david 1.12 /** setlogLevelMask
|
364 mike 1.8 */
|
365 david 1.12 static void setlogLevelMask(const String logLevelList);
|
366 mike 1.8
367 /** setLogWriteControlMask
368 */
369 static void setLogWriteControlMask(const Uint32);
370
|
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 static Uint32 _writeControlMask;
|
402 david 1.12
403 static const char _SEPARATOR;
404 static const Uint32 _NUM_LOGLEVEL;
405
406 static const Boolean _SUCCESS;
407 static const Boolean _FAILURE;
|
408 mike 1.21
|
409 david 1.12 static void _putInternal(
|
410 mike 1.21 LogFileType logFileType,
411 const String& systemId,
412 const Uint32 logComponent,
413 Uint32 logLevel,
414 const String& formatString,
415 const String& messageId,
416 const Formatter::Arg& arg0 = Formatter::DEFAULT_ARG,
417 const Formatter::Arg& arg1 = Formatter::DEFAULT_ARG,
418 const Formatter::Arg& arg2 = Formatter::DEFAULT_ARG,
419 const Formatter::Arg& arg3 = Formatter::DEFAULT_ARG,
420 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
421 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
422 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
423 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
424 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
425 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
426 mike 1.8 };
427
428 PEGASUS_NAMESPACE_END
429
430 #endif /* Pegasus_Logger_h */
|