1 karl 1.43 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.13 //
|
3 karl 1.36 // 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.32 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.36 // 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.38 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.43 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.13 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.18 // 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.13 // 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 //
|
21 kumpf 1.18 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.13 // 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.18 // 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.13 // 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 #include <iostream>
35 #include <fstream>
|
36 kumpf 1.23 #include <cstring>
|
37 mike 1.13 #include "Logger.h"
38 #include "System.h"
|
39 kumpf 1.48 #include <Pegasus/Common/MessageLoader.h>
|
40 kumpf 1.16
|
41 marek 1.47 #if defined(PEGASUS_USE_SYSLOGS)
42 # include <syslog.h>
43 #endif
44
|
45 mike 1.13 PEGASUS_USING_STD;
46
47 PEGASUS_NAMESPACE_BEGIN
48
49 const Uint32 Logger::TRACE = (1 << 0);
50 const Uint32 Logger::INFORMATION = (1 << 1);
51 const Uint32 Logger::WARNING = (1 << 2);
52 const Uint32 Logger::SEVERE = (1 << 3);
53 const Uint32 Logger::FATAL = (1 << 4);
54
|
55 david 1.26 static char const* LOGLEVEL_LIST[] =
56 {
57 "TRACE",
58 "INFORMATION",
59 "WARNING",
60 "SEVERE",
61 "FATAL"
62 };
63
|
64 mike 1.13 LoggerRep* Logger::_rep = 0;
65 String Logger::_homeDirectory = ".";
|
66 kumpf 1.16
|
67 david 1.26 const Uint32 Logger::_NUM_LOGLEVEL = 5;
68
69 // Set separator
70 const char Logger::_SEPARATOR = '@';
71
|
72 kumpf 1.40 Uint32 Logger::_severityMask;
|
73 kumpf 1.16
|
74 mike 1.13 Uint32 Logger::_writeControlMask = 0xF; // Set all on by default
75
|
76 david 1.26 // Set the return codes
77 const Boolean Logger::_SUCCESS = 1;
78 const Boolean Logger::_FAILURE = 0;
79
|
80 mike 1.13 /* _allocLogFileName. Allocates the name from a name set.
81 Today this is static. However, it should be completely
82 configerable and driven from the config file so that
83 Log organization and names are open.
84 ATTN: rewrite this so that names, choice to do logs and
85 mask for level of severity are all driven from configuration
86 input.
87 */
|
88 kumpf 1.22 static CString _allocLogFileName(
|
89 mike 1.13 const String& homeDirectory,
90 Logger::LogFileType logFileType)
91 {
|
92 kumpf 1.40 static const char* fileNames[] =
|
93 mike 1.13 {
|
94 kumpf 1.40 "PegasusTrace.log",
95 "PegasusStandard.log",
|
96 yi.zhou 1.45 "PegasusAudit.log",
|
97 kumpf 1.40 "PegasusError.log",
98 "PegasusDebug.log"
|
99 mike 1.13 };
100
101 int index = int(logFileType);
102
103 if (index > Logger::NUM_LOGS)
|
104 kumpf 1.40 index = Logger::ERROR_LOG;
|
105 mike 1.13
106 const char* logFileName = fileNames[index];
107
108 String result;
|
109 kumpf 1.19 result.reserveCapacity(homeDirectory.size() + 1 + strlen(logFileName));
|
110 kumpf 1.20 result.append(homeDirectory);
111 result.append('/');
112 result.append(logFileName);
|
113 kumpf 1.22 return result.getCString();
|
114 mike 1.13 }
115
116 class LoggerRep
117 {
118 public:
119
120 LoggerRep(const String& homeDirectory)
121 {
|
122 kumpf 1.40 #if !defined(PEGASUS_USE_SYSLOGS)
123 // Add test for home directory set.
|
124 mike 1.13
|
125 kumpf 1.40 // If home directory does not exist, create it.
126 CString lgDir = homeDirectory.getCString();
|
127 mike 1.13
|
128 kumpf 1.40 if (!System::isDirectory(lgDir))
129 System::makeDirectory(lgDir);
|
130 mike 1.13
|
131 kumpf 1.40 // KS: I put the second test in just in case some trys to create
132 // a completly erronous directory. At least we will get a message
|
133 kumpf 1.48 if (!System::isDirectory(lgDir))
134 {
135 MessageLoaderParms parms("Common.Logger.LOGGING_DISABLED",
136 "Logging Disabled");
|
137 kumpf 1.40
|
138 kumpf 1.48 cerr << MessageLoader::getMessage(parms);
|
139 kumpf 1.40 }
140
141 CString fileName = _allocLogFileName(homeDirectory, Logger::TRACE_LOG);
142 _logs[Logger::TRACE_LOG].open(fileName, ios::app);
143
144 fileName = _allocLogFileName(homeDirectory, Logger::STANDARD_LOG);
145 _logs[Logger::STANDARD_LOG].open(fileName, ios::app);
146
|
147 thilo.boehm 1.46 #ifndef PEGASUS_DISABLE_AUDIT_LOGGER
148 fileName = _allocLogFileName(homeDirectory, Logger::AUDIT_LOG);
149 _logs[Logger::AUDIT_LOG].open(fileName, ios::app);
150 #endif
151
|
152 kumpf 1.40 fileName = _allocLogFileName(homeDirectory, Logger::ERROR_LOG);
153 _logs[Logger::ERROR_LOG].open(fileName, ios::app);
154
155 fileName = _allocLogFileName(homeDirectory, Logger::DEBUG_LOG);
156 _logs[Logger::DEBUG_LOG].open(fileName, ios::app);
|
157 marek 1.47 #else
158
159 #ifdef PEGASUS_OS_ZOS
|
160 marek 1.49 logIdentity = strdup(System::CIMSERVER.getCString());
|
161 marek 1.47 // If System Log is used open it
|
162 kumpf 1.48 System::openlog(logIdentity, LOG_PID, LOG_DAEMON);
|
163 marek 1.47 #endif
164
165 #endif
166
167 }
168
169 ~LoggerRep()
170 {
171 #if !defined(PEGASUS_USE_SYSLOGS)
172 _logs[Logger::TRACE_LOG].close();
173 _logs[Logger::STANDARD_LOG].close();
174
175 #ifndef PEGASUS_DISABLE_AUDIT_LOGGER
176 _logs[Logger::AUDIT_LOG].close();
177 #endif
178
179 _logs[Logger::ERROR_LOG].close();
180 _logs[Logger::DEBUG_LOG].close();
181
182 #else
183
184 marek 1.47 #ifdef PEGASUS_OS_ZOS
185 System::closelog();
|
186 marek 1.49 free(logIdentity);
|
187 marek 1.47 #endif
188
|
189 kumpf 1.40 #endif
|
190 mike 1.13
191 }
192
193 ostream& logOf(Logger::LogFileType logFileType)
194 {
|
195 kumpf 1.40 int index = int(logFileType);
|
196 mike 1.13
|
197 jim.wunderlich 1.41 if (index > int(Logger::NUM_LOGS))
|
198 kumpf 1.40 index = Logger::ERROR_LOG;
|
199 mike 1.13
|
200 kumpf 1.40 return _logs[index];
|
201 mike 1.13 }
202
203 private:
204
|
205 marek 1.47 #ifdef PEGASUS_OS_ZOS
|
206 marek 1.49 char* logIdentity;
|
207 marek 1.47 #endif
|
208 mike 1.13 ofstream _logs[int(Logger::NUM_LOGS)];
209 };
210
|
211 david 1.26 void Logger::_putInternal(
|
212 mike 1.13 LogFileType logFileType,
213 const String& systemId,
|
214 kumpf 1.48 const Uint32 logComponent, // FUTURE: Support logComponent mask
|
215 david 1.26 Uint32 logLevel,
|
216 mike 1.13 const String& formatString,
|
217 kumpf 1.48 const String& messageId,
|
218 mike 1.13 const Formatter::Arg& arg0,
219 const Formatter::Arg& arg1,
220 const Formatter::Arg& arg2,
221 const Formatter::Arg& arg3,
222 const Formatter::Arg& arg4,
223 const Formatter::Arg& arg5,
224 const Formatter::Arg& arg6,
225 const Formatter::Arg& arg7,
226 const Formatter::Arg& arg8,
227 const Formatter::Arg& arg9)
228 {
|
229 david 1.26 // Test for logLevel against severity mask to determine
|
230 mike 1.13 // if we write this log.
|
231 kumpf 1.40 if ((_severityMask & logLevel) != 0)
|
232 mike 1.13 {
|
233 kumpf 1.40 if (!_rep)
234 _rep = new LoggerRep(_homeDirectory);
|
235 mike 1.13
|
236 kumpf 1.40 // Get the logLevel String
237 // This converts bitmap to string based on highest order
238 // bit set
239 // ATTN: KS Fix this more efficiently.
240 static const char* svNames[] =
241 {
242 "TRACE ",
243 "INFO ",
244 "WARNING ",
245 "SEVERE ",
246 "FATAL "
247 };
248 // NUM_LEVELS = 5
249 int sizeSvNames = sizeof(svNames) / sizeof(svNames[0]) - 1;
|
250 chuck 1.29
251 // l10n start
252 // The localized message to be sent to the system log.
|
253 kumpf 1.40 String localizedMsg;
254
255 // If the caller specified a messageId, then load the localized
256 // message in the locale of the server process.
257 if (messageId != String::EMPTY)
258 {
259 // A message ID was specified. Use the MessageLoader.
260 MessageLoaderParms msgParms(messageId, formatString);
261 msgParms.useProcessLocale = true;
262 msgParms.arg0 = arg0;
263 msgParms.arg1 = arg1;
264 msgParms.arg2 = arg2;
265 msgParms.arg3 = arg3;
266 msgParms.arg4 = arg4;
267 msgParms.arg5 = arg5;
268 msgParms.arg6 = arg6;
269 msgParms.arg7 = arg7;
270 msgParms.arg8 = arg8;
271 msgParms.arg9 = arg9;
272
273 localizedMsg = MessageLoader::getMessage(msgParms);
274 kumpf 1.40 }
275 else
276 { // No message ID. Use the Pegasus formatter
277 localizedMsg = Formatter::format(formatString,
278 arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
279 }
280 // l10n end
281
|
282 david 1.26 #if defined(PEGASUS_USE_SYSLOGS)
283
|
284 kumpf 1.40 // Log the message
|
285 yi.zhou 1.44 System::syslog(systemId, logLevel, localizedMsg.getCString());
|
286 kumpf 1.40
287 #else
288
289 // Prepend the systemId to the incoming message
290 String messageString(systemId);
291 messageString.append(": ");
292 messageString.append(localizedMsg); // l10n
293
294 const char* tmp = "";
295 if (logLevel & Logger::TRACE) tmp = "TRACE ";
296 if (logLevel & Logger::INFORMATION) tmp = "INFO ";
297 if (logLevel & Logger::WARNING) tmp = "WARNING ";
298 if (logLevel & Logger::SEVERE) tmp = "SEVERE ";
299 if (logLevel & Logger::FATAL) tmp = "FATAL ";
300
301 _rep->logOf(logFileType) << System::getCurrentASCIITime()
302 << " " << tmp << (const char *)messageString.getCString() << endl;
303
304 #endif
|
305 david 1.26 }
306 }
|
307 mike 1.13
|
308 mike 1.42 ////////////////////////////////////////////////////////////////////////////////
309 //
310 // Public methods start here:
311 //
312 ////////////////////////////////////////////////////////////////////////////////
313
|
314 david 1.26 void Logger::put(
|
315 kumpf 1.40 LogFileType logFileType,
316 const String& systemId,
317 Uint32 logLevel,
318 const String& formatString,
319 const Formatter::Arg& arg0,
320 const Formatter::Arg& arg1,
321 const Formatter::Arg& arg2,
322 const Formatter::Arg& arg3,
323 const Formatter::Arg& arg4,
324 const Formatter::Arg& arg5,
325 const Formatter::Arg& arg6,
326 const Formatter::Arg& arg7,
327 const Formatter::Arg& arg8,
328 const Formatter::Arg& arg9)
|
329 chuck 1.29 {
|
330 mike 1.42 if (wouldLog(logLevel))
331 {
332 Logger::_putInternal(logFileType, systemId, 0, logLevel,
|
333 kumpf 1.48 formatString, String::EMPTY, arg0, arg1, arg2, arg3,
|
334 mike 1.42 arg4, arg5, arg6, arg7, arg8, arg9);
335 }
|
336 karl 1.37 }
337
338 void Logger::put(
|
339 kumpf 1.40 LogFileType logFileType,
340 const String& systemId,
341 Uint32 logLevel,
342 const String& formatString)
|
343 karl 1.37 {
|
344 mike 1.42 if (wouldLog(logLevel))
345 {
346 Logger::_putInternal(logFileType, systemId, 0, logLevel,
347 formatString, String::EMPTY);
348 }
349 }
|
350 karl 1.37
|
351 mike 1.42 void Logger::put(
352 LogFileType logFileType,
353 const String& systemId,
354 Uint32 logLevel,
355 const String& formatString,
356 const Formatter::Arg& arg0)
357 {
358 if (wouldLog(logLevel))
359 {
360 Logger::_putInternal(logFileType, systemId, 0, logLevel,
361 formatString, String::EMPTY, arg0);
362 }
|
363 karl 1.37 }
364
365 void Logger::put(
|
366 kumpf 1.40 LogFileType logFileType,
367 const String& systemId,
368 Uint32 logLevel,
369 const String& formatString,
|
370 mike 1.42 const Formatter::Arg& arg0,
371 const Formatter::Arg& arg1)
|
372 karl 1.37 {
|
373 mike 1.42 if (wouldLog(logLevel))
374 {
375 Logger::_putInternal(logFileType, systemId, 0, logLevel,
376 formatString, String::EMPTY, arg0, arg1);
377 }
378 }
|
379 karl 1.37
|
380 mike 1.42 void Logger::put(
381 LogFileType logFileType,
382 const String& systemId,
383 Uint32 logLevel,
384 const String& formatString,
385 const Formatter::Arg& arg0,
386 const Formatter::Arg& arg1,
387 const Formatter::Arg& arg2)
388 {
389 if (wouldLog(logLevel))
390 {
391 Logger::_putInternal(logFileType, systemId, 0, logLevel,
392 formatString, String::EMPTY, arg0, arg1, arg2);
393 }
|
394 chuck 1.29 }
395
396 void Logger::put_l(
|
397 kumpf 1.40 LogFileType logFileType,
398 const String& systemId,
399 Uint32 logLevel,
|
400 mike 1.42 const String& messageId,
|
401 kumpf 1.40 const String& formatString,
402 const Formatter::Arg& arg0,
403 const Formatter::Arg& arg1,
404 const Formatter::Arg& arg2,
405 const Formatter::Arg& arg3,
406 const Formatter::Arg& arg4,
407 const Formatter::Arg& arg5,
408 const Formatter::Arg& arg6,
409 const Formatter::Arg& arg7,
410 const Formatter::Arg& arg8,
411 const Formatter::Arg& arg9)
|
412 david 1.26 {
|
413 mike 1.42 if (wouldLog(logLevel))
414 {
415 Logger::_putInternal(logFileType, systemId, 0, logLevel,
416 formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5,
417 arg6, arg7, arg8, arg9);
418 }
|
419 karl 1.37 }
420
421 void Logger::put_l(
422 LogFileType logFileType,
423 const String& systemId,
424 Uint32 logLevel,
425 const String& messageId,
426 const String& formatString)
427 {
|
428 mike 1.42 if (wouldLog(logLevel))
429 {
430 Logger::_putInternal(logFileType, systemId, 0, logLevel,
|
431 kumpf 1.40 formatString, messageId);
|
432 mike 1.42 }
|
433 karl 1.37 }
434
435 void Logger::put_l(
436 LogFileType logFileType,
437 const String& systemId,
438 Uint32 logLevel,
439 const String& messageId,
440 const String& formatString,
441 const Formatter::Arg& arg0)
442 {
|
443 mike 1.42 if (wouldLog(logLevel))
444 {
445 Logger::_putInternal(logFileType, systemId, 0, logLevel,
446 formatString, messageId, arg0);
447 }
448 }
|
449 karl 1.37
|
450 mike 1.42 void Logger::put_l(
451 LogFileType logFileType,
452 const String& systemId,
453 Uint32 logLevel,
454 const String& messageId,
455 const String& formatString,
456 const Formatter::Arg& arg0,
457 const Formatter::Arg& arg1)
458 {
459 if (wouldLog(logLevel))
460 {
461 Logger::_putInternal(logFileType, systemId, 0, logLevel,
462 formatString, messageId, arg0, arg1);
463 }
464 }
465
466 void Logger::put_l(
467 LogFileType logFileType,
468 const String& systemId,
469 Uint32 logLevel,
470 const String& messageId,
471 mike 1.42 const String& formatString,
472 const Formatter::Arg& arg0,
473 const Formatter::Arg& arg1,
474 const Formatter::Arg& arg2)
475 {
476 if (wouldLog(logLevel))
477 {
478 Logger::_putInternal(logFileType, systemId, 0, logLevel,
479 formatString, messageId, arg0, arg1, arg2);
480 }
|
481 david 1.26 }
482
483 void Logger::trace(
|
484 kumpf 1.40 LogFileType logFileType,
485 const String& systemId,
486 const Uint32 logComponent,
487 const String& formatString,
488 const Formatter::Arg& arg0,
489 const Formatter::Arg& arg1,
490 const Formatter::Arg& arg2,
491 const Formatter::Arg& arg3,
492 const Formatter::Arg& arg4,
493 const Formatter::Arg& arg5,
494 const Formatter::Arg& arg6,
495 const Formatter::Arg& arg7,
496 const Formatter::Arg& arg8,
497 const Formatter::Arg& arg9)
|
498 chuck 1.29 {
|
499 mike 1.42 if (wouldLog(Logger::TRACE))
500 {
501 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
502 formatString, String::EMPTY, arg0, arg1, arg2, arg3, arg4, arg5,
503 arg6, arg7, arg8, arg9);
504 }
505 }
|
506 chuck 1.29
|
507 mike 1.42 void Logger::trace(
508 LogFileType logFileType,
509 const String& systemId,
510 const Uint32 logComponent,
511 const String& formatString)
512 {
513 if (wouldLog(Logger::TRACE))
514 {
515 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
516 formatString, String::EMPTY);
517 }
518 }
519
520 void Logger::trace(
521 LogFileType logFileType,
522 const String& systemId,
523 const Uint32 logComponent,
524 const String& formatString,
525 const Formatter::Arg& arg0)
526 {
527 if (wouldLog(Logger::TRACE))
528 mike 1.42 {
529 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
530 formatString, String::EMPTY, arg0);
531 }
532 }
533
534 void Logger::trace(
535 LogFileType logFileType,
536 const String& systemId,
537 const Uint32 logComponent,
538 const String& formatString,
539 const Formatter::Arg& arg0,
540 const Formatter::Arg& arg1)
541 {
542 if (wouldLog(Logger::TRACE))
543 {
544 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
545 formatString, String::EMPTY, arg0, arg1);
546 }
547 }
548
549 mike 1.42 void Logger::trace(
550 LogFileType logFileType,
551 const String& systemId,
552 const Uint32 logComponent,
553 const String& formatString,
554 const Formatter::Arg& arg0,
555 const Formatter::Arg& arg1,
556 const Formatter::Arg& arg2)
557 {
558 if (wouldLog(Logger::TRACE))
559 {
560 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
561 formatString, String::EMPTY, arg0, arg1, arg2);
562 }
|
563 chuck 1.29 }
564
565 void Logger::trace_l(
|
566 kumpf 1.40 LogFileType logFileType,
567 const String& systemId,
568 const Uint32 logComponent,
569 const String& messageId,
570 const String& formatString,
571 const Formatter::Arg& arg0,
572 const Formatter::Arg& arg1,
573 const Formatter::Arg& arg2,
574 const Formatter::Arg& arg3,
575 const Formatter::Arg& arg4,
576 const Formatter::Arg& arg5,
577 const Formatter::Arg& arg6,
578 const Formatter::Arg& arg7,
579 const Formatter::Arg& arg8,
580 const Formatter::Arg& arg9)
|
581 david 1.26 {
|
582 mike 1.42 if (wouldLog(Logger::TRACE))
583 {
584 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
585 formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5, arg6,
586 arg7, arg8, arg9);
587 }
588 }
589
590 void Logger::trace_l(
591 LogFileType logFileType,
592 const String& systemId,
593 const Uint32 logComponent,
594 const String& messageId,
595 const String& formatString)
596 {
597 if (wouldLog(Logger::TRACE))
598 {
599 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
600 formatString, messageId);
601 }
602 }
603 mike 1.42
604 void Logger::trace_l(
605 LogFileType logFileType,
606 const String& systemId,
607 const Uint32 logComponent,
608 const String& messageId,
609 const String& formatString,
610 const Formatter::Arg& arg0)
611 {
612 if (wouldLog(Logger::TRACE))
613 {
614 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
615 formatString, messageId, arg0);
616 }
617 }
|
618 david 1.26
|
619 mike 1.42 void Logger::trace_l(
620 LogFileType logFileType,
621 const String& systemId,
622 const Uint32 logComponent,
623 const String& messageId,
624 const String& formatString,
625 const Formatter::Arg& arg0,
626 const Formatter::Arg& arg1)
627 {
628 if (wouldLog(Logger::TRACE))
629 {
630 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
631 formatString, messageId, arg0, arg1);
632 }
633 }
634
635 void Logger::trace_l(
636 LogFileType logFileType,
637 const String& systemId,
638 const Uint32 logComponent,
639 const String& messageId,
640 mike 1.42 const String& formatString,
641 const Formatter::Arg& arg0,
642 const Formatter::Arg& arg1,
643 const Formatter::Arg& arg2)
644 {
645 if (wouldLog(Logger::TRACE))
646 {
647 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
648 formatString, messageId, arg0, arg1, arg2);
649 }
|
650 mike 1.13 }
651
652 void Logger::setHomeDirectory(const String& homeDirectory)
653 {
654 _homeDirectory = homeDirectory;
655 }
|
656 david 1.26
657 void Logger::setlogLevelMask( const String logLevelList )
658 {
659 Uint32 position = 0;
|
660 karl 1.37 Uint32 logLevelType = 0;
|
661 david 1.26 String logLevelName = logLevelList;
662
663 // Check if logLevel has been specified
664 if (logLevelName != String::EMPTY)
665 {
666 // initialise _severityMask
667 _severityMask = 0;
668
|
669 kumpf 1.40 // Set logLevelType to indicate the level of logging
|
670 david 1.26 // required by the user.
|
671 kumpf 1.40 if (String::equalNoCase(logLevelName,"TRACE"))
672 {
673 logLevelType = Logger::TRACE;
674 }
675 else if (String::equalNoCase(logLevelName,"INFORMATION"))
676 {
677 logLevelType = Logger::INFORMATION;
678 }
679 else if (String::equalNoCase(logLevelName,"WARNING"))
680 {
681 logLevelType = Logger::WARNING;
682 }
683 else if (String::equalNoCase(logLevelName,"SEVERE"))
684 {
685 logLevelType = Logger::SEVERE;
686 }
687 else if (String::equalNoCase(logLevelName,"FATAL"))
688 {
689 logLevelType = Logger::FATAL;
690 }
691 // Setting _severityMask. NOTE: When adding new logLevels
|
692 david 1.26 // it is essential that they are adding in ascending order
693 // based on priority. Once a case statement is true we will
694 // continue to set all following log levels with a higher
695 // priority.
|
696 kumpf 1.40 switch(logLevelType)
697 {
698 case Logger::TRACE:
699 _severityMask |= Logger::TRACE;
700 case Logger::INFORMATION:
701 _severityMask |= Logger::INFORMATION;
702 case Logger::WARNING:
703 _severityMask |= Logger::WARNING;
704 case Logger::SEVERE:
705 _severityMask |= Logger::SEVERE;
706 case Logger::FATAL:
707 _severityMask |= Logger::FATAL;
708 }
|
709 david 1.26 }
710 else
711 {
|
712 kumpf 1.40 // Property logLevel not specified, set default value.
713 _severityMask = ~Logger::TRACE;
|
714 david 1.26 }
715 return ;
716 }
717
|
718 mike 1.42 Boolean Logger::isValidlogLevel(const String logLevel)
|
719 david 1.26 {
720 // Validate the logLevel and modify the logLevel argument
721 // to reflect the invalid logLevel
722
723 Uint32 position=0;
724 Uint32 index=0;
725 String logLevelName = String::EMPTY;
726 Boolean validlogLevel=false;
727 Boolean retCode=true;
728
729 logLevelName = logLevel;
730
731 if (logLevelName != String::EMPTY)
732 {
|
733 kumpf 1.40 // Lookup the index for logLevel name in _logLevel_LIST
734 index = 0;
735 validlogLevel = false;
736
737 while (index < _NUM_LOGLEVEL)
738 {
739 if (String::equalNoCase(logLevelName, LOGLEVEL_LIST[index]))
740 {
741 // Found logLevel, break from the loop
742 validlogLevel = true;
743 break;
744 }
745 else
746 {
747 index++;
748 }
749 }
|
750 david 1.26 }
751 else
752 {
|
753 kumpf 1.40 // logLevels is empty, it is a valid value so return true
754 return _SUCCESS;
|
755 david 1.26 }
756
757 return validlogLevel;
758 }
759
|
760 mike 1.13 PEGASUS_NAMESPACE_END
|