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 mreddy 1.55 #include <Pegasus/Common/Logger.h>
38 #include <Pegasus/Common/System.h>
39 #include <Pegasus/Common/FileSystem.h>
|
40 kumpf 1.48 #include <Pegasus/Common/MessageLoader.h>
|
41 kumpf 1.54 #include <Pegasus/Common/Executor.h>
|
42 mreddy 1.55 #include <Pegasus/Common/Mutex.h>
|
43 kumpf 1.16
|
44 marek 1.47 #if defined(PEGASUS_USE_SYSLOGS)
45 # include <syslog.h>
46 #endif
47
|
48 mike 1.13 PEGASUS_USING_STD;
49
50 PEGASUS_NAMESPACE_BEGIN
51
|
52 mike 1.55.2.4 // Log callback function and data.
53 static Logger::LogCallback _callback;
54 static void* _data;
55
|
56 mreddy 1.55 // Maximum logfile size is defined as 32 MB = 32 * 1024 * 1024
57 # define PEGASUS_MAX_LOGFILE_SIZE 0X2000000
58
|
59 mike 1.13 const Uint32 Logger::TRACE = (1 << 0);
60 const Uint32 Logger::INFORMATION = (1 << 1);
61 const Uint32 Logger::WARNING = (1 << 2);
62 const Uint32 Logger::SEVERE = (1 << 3);
63 const Uint32 Logger::FATAL = (1 << 4);
64
|
65 david 1.26 static char const* LOGLEVEL_LIST[] =
66 {
67 "TRACE",
68 "INFORMATION",
69 "WARNING",
70 "SEVERE",
71 "FATAL"
72 };
73
|
74 mike 1.13 LoggerRep* Logger::_rep = 0;
75 String Logger::_homeDirectory = ".";
|
76 kumpf 1.16
|
77 david 1.26 const Uint32 Logger::_NUM_LOGLEVEL = 5;
78
79 // Set separator
80 const char Logger::_SEPARATOR = '@';
81
|
82 kumpf 1.40 Uint32 Logger::_severityMask;
|
83 kumpf 1.16
|
84 mike 1.13 Uint32 Logger::_writeControlMask = 0xF; // Set all on by default
85
|
86 david 1.26 // Set the return codes
87 const Boolean Logger::_SUCCESS = 1;
88 const Boolean Logger::_FAILURE = 0;
89
|
90 kumpf 1.40 static const char* fileNames[] =
|
91 mike 1.13 {
|
92 kumpf 1.40 "PegasusTrace.log",
93 "PegasusStandard.log",
|
94 yi.zhou 1.45 "PegasusAudit.log",
|
95 kumpf 1.40 "PegasusError.log",
96 "PegasusDebug.log"
|
97 mike 1.13 };
|
98 mreddy 1.55 static const char* lockFileName = "PegasusLog.lock";
|
99 mike 1.13
|
100 mike 1.55.2.1 #if defined(PEGASUS_OS_VXWORKS) && defined(log)
101 # undef log
102 #endif
|
103 mike 1.13
|
104 mreddy 1.55 /* _constructFileName prepares the absolute file name from homeDirectory
105 and fileName.
|
106 mike 1.13
|
107 mreddy 1.55 Today this is static. However, it should be completely
108 configerable and driven from the config file so that
109 Log organization and names are open.
110 ATTN: rewrite this so that names, choice to do logs and
111 mask for level of severity are all driven from configuration
112 input.
113 */
114 static CString _constructFileName(
115 const String& homeDirectory,
116 const char * fileName)
117 {
|
118 mike 1.13 String result;
|
119 a.dunfey 1.50 result.reserveCapacity((Uint32)(homeDirectory.size() + 1 +
|
120 mreddy 1.55 strlen(fileName)));
|
121 kumpf 1.20 result.append(homeDirectory);
122 result.append('/');
|
123 mreddy 1.55 result.append(fileName);
|
124 kumpf 1.22 return result.getCString();
|
125 mike 1.13 }
126
127 class LoggerRep
128 {
129 public:
130
131 LoggerRep(const String& homeDirectory)
132 {
|
133 kumpf 1.40 #if !defined(PEGASUS_USE_SYSLOGS)
134 // Add test for home directory set.
|
135 mike 1.13
|
136 kumpf 1.40 // If home directory does not exist, create it.
137 CString lgDir = homeDirectory.getCString();
|
138 mike 1.13
|
139 kumpf 1.40 if (!System::isDirectory(lgDir))
140 System::makeDirectory(lgDir);
|
141 mike 1.13
|
142 kumpf 1.40 // KS: I put the second test in just in case some trys to create
143 // a completly erronous directory. At least we will get a message
|
144 kumpf 1.48 if (!System::isDirectory(lgDir))
145 {
146 MessageLoaderParms parms("Common.Logger.LOGGING_DISABLED",
147 "Logging Disabled");
|
148 kumpf 1.40
|
149 kumpf 1.48 cerr << MessageLoader::getMessage(parms);
|
150 kumpf 1.40 }
151
|
152 mreddy 1.55 //Filelocks are not used for VMS
153 #if !defined(PEGASUS_OS_VMS)
154 _loggerLockFileName = _constructFileName(homeDirectory, lockFileName);
155
156 // Open and close a file to make sure that the file exists, on which
157 // file lock is requested
158 FILE *fileLockFilePointer;
159 fileLockFilePointer = fopen(_loggerLockFileName, "a+");
160 if(fileLockFilePointer)
161 {
162 fclose(fileLockFilePointer);
163 }
164 #endif
165
166
167 _logFileNames[Logger::TRACE_LOG] = _constructFileName(homeDirectory,
168 fileNames[Logger::TRACE_LOG]);
|
169 kumpf 1.40
|
170 mreddy 1.55 _logFileNames[Logger::STANDARD_LOG] = _constructFileName(homeDirectory,
171 fileNames[Logger::STANDARD_LOG]);
|
172 kumpf 1.40
|
173 thilo.boehm 1.46 #ifndef PEGASUS_DISABLE_AUDIT_LOGGER
|
174 mreddy 1.55 _logFileNames[Logger::AUDIT_LOG] = _constructFileName(homeDirectory,
175 fileNames[Logger::AUDIT_LOG]);
|
176 thilo.boehm 1.46 #endif
177
|
178 mreddy 1.55 _logFileNames[Logger::ERROR_LOG] = _constructFileName(homeDirectory,
179 fileNames[Logger::ERROR_LOG]);
|
180 kumpf 1.40
|
181 mreddy 1.55 _logFileNames[Logger::DEBUG_LOG] = _constructFileName(homeDirectory,
182 fileNames[Logger::DEBUG_LOG]);
|
183 marek 1.47 #else
184
185 #ifdef PEGASUS_OS_ZOS
|
186 marek 1.49 logIdentity = strdup(System::CIMSERVER.getCString());
|
187 marek 1.47 // If System Log is used open it
|
188 kumpf 1.48 System::openlog(logIdentity, LOG_PID, LOG_DAEMON);
|
189 marek 1.47 #endif
190
191 #endif
192
193 }
194
195 ~LoggerRep()
196 {
197
|
198 mreddy 1.55 #ifdef PEGASUS_OS_ZOS
199 System::closelog();
200 free(logIdentity);
|
201 marek 1.47 #endif
|
202 mreddy 1.55 }
203
204 // Actual logging is done in this routine
205 void log(Logger::LogFileType logFileType,
206 const String& systemId,
207 Uint32 logLevel,
208 const String localizedMsg)
209 {
|
210 mike 1.55.2.4 // Use logging callback if installed and bypass logging logic below.
211
212 if (_callback)
213 {
214 // Set type:
215
216 int type;
217
218 switch (logFileType)
219 {
220 case Logger::TRACE_LOG:
221 type = 1;
222 break;
223 case Logger::STANDARD_LOG:
224 type = 2;
225 break;
226 case Logger::AUDIT_LOG:
227 type = 3;
228 break;
229 case Logger::ERROR_LOG:
230 type = 4;
231 mike 1.55.2.4 break;
232 case Logger::DEBUG_LOG:
233 type = 5;
234 break;
235 default:
236 return;
237 }
238
239 // Set system:
240
241 CString system(systemId.getCString());
242
243 // Set level:
244
245 int level;
246
247 switch (logLevel)
248 {
249 case Logger::TRACE:
250 level = 1;
251 break;
252 mike 1.55.2.4 case Logger::INFORMATION:
253 level = 2;
254 break;
255 case Logger::WARNING:
256 level = 3;
257 break;
258 case Logger::SEVERE:
259 level = 4;
260 break;
261 case Logger::FATAL:
262 level = 5;
263 break;
264 default:
265 return;
266 }
267
268 // Set message:
269
270 CString message(localizedMsg.getCString());
271
272 // Invoke the callback.
273 mike 1.55.2.4
274 (*_callback)(type, system, level, message, _data);
275
276 return;
277 }
|
278 mike 1.55.2.2
|
279 mreddy 1.55 #if defined(PEGASUS_USE_SYSLOGS)
|
280 marek 1.47
|
281 mreddy 1.55 // Log the message
282 System::syslog(systemId, logLevel, localizedMsg.getCString());
|
283 marek 1.47
284 #else
|
285 mreddy 1.55 // Prepend the systemId to the incoming message
286 String messageString(systemId);
287 messageString.append(": ");
288 messageString.append(localizedMsg); // l10n
|
289 marek 1.47
|
290 mreddy 1.55 // Get the logLevel String
291 // This converts bitmap to string based on highest order
292 // bit set
293 // ATTN: KS Fix this more efficiently.
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 mike 1.13
|
301 mreddy 1.55 # ifndef PEGASUS_OS_VMS
302 // Acquire AutoMutex (for thread sync)
303 // and AutoFileLock (for Process Sync).
304 AutoMutex am(_mutex);
305 AutoFileLock fileLock(_loggerLockFileName);
306
307 Uint32 logFileSize = 0;
308
309 // Read logFileSize to check if the logfile needs to be pruned.
310 FileSystem::getFileSize(String(_logFileNames[logFileType]),
311 logFileSize);
312
313 // Check if the size of the logfile is exceeding 32MB.
314 if ( logFileSize > PEGASUS_MAX_LOGFILE_SIZE)
315 {
316 // Prepare appropriate file name based on the logFileType.
317 // Eg: if Logfile name is PegasusStandard.log, pruned logfile name
318 // will be PegasusStandard-062607-122302.log,where 062607-122302
319 // is the time stamp.
320 String prunedLogfile(_logFileNames[logFileType],
321 (Uint32)strlen(_logFileNames[logFileType]) - 4);
322 mreddy 1.55 prunedLogfile.append('-');
323
324 // Get timestamp,remove illegal chars in file name'/' and ':'
325 // (: is illegal Open VMS) from the time stamp. Append the time
326 // info to the file name.
|
327 mike 1.13
|
328 mreddy 1.55 String timeStamp = System::getCurrentASCIITime();
329 for (unsigned int i=0; i<=timeStamp.size(); i++)
330 {
331 if(timeStamp[i] == '/' || timeStamp[i] == ':')
332 {
333 timeStamp.remove(i, 1);
334 }
335 }
336 prunedLogfile.append(timeStamp);
|
337 mike 1.13
|
338 mreddy 1.55 // Append '.log' to the file
339 prunedLogfile.append( ".log");
|
340 mike 1.13
|
341 mreddy 1.55 // Rename the logfile
342 FileSystem::renameFile(String(_logFileNames[logFileType]),
343 prunedLogfile);
344
345 } // Check if the logfile needs to be pruned.
346 # endif // ifndef PEGASUS_OS_VMS
347
348 // Open Logfile. Based on the value of logFileType, one of the five
349 // Logfiles will be opened.
350 ofstream logFileStream;
351 logFileStream.open(_logFileNames[logFileType], ios::app);
352 logFileStream << System::getCurrentASCIITime()
353 << " " << tmp << (const char *)messageString.getCString() << endl;
354 logFileStream.close();
355 #endif // ifndef PEGASUS_USE_SYSLOGS
|
356 mike 1.13 }
357
358 private:
359
|
360 marek 1.47 #ifdef PEGASUS_OS_ZOS
|
361 marek 1.49 char* logIdentity;
|
362 marek 1.47 #endif
|
363 mreddy 1.55 CString _logFileNames[int(Logger::NUM_LOGS)];
364 #ifndef PEGASUS_OS_VMS
365 CString _loggerLockFileName;
366 Mutex _mutex;
367 #endif
|
368 mike 1.13 };
369
|
370 david 1.26 void Logger::_putInternal(
|
371 mike 1.13 LogFileType logFileType,
372 const String& systemId,
|
373 kumpf 1.48 const Uint32 logComponent, // FUTURE: Support logComponent mask
|
374 david 1.26 Uint32 logLevel,
|
375 mike 1.13 const String& formatString,
|
376 kumpf 1.48 const String& messageId,
|
377 mike 1.13 const Formatter::Arg& arg0,
378 const Formatter::Arg& arg1,
379 const Formatter::Arg& arg2,
380 const Formatter::Arg& arg3,
381 const Formatter::Arg& arg4,
382 const Formatter::Arg& arg5,
383 const Formatter::Arg& arg6,
384 const Formatter::Arg& arg7,
385 const Formatter::Arg& arg8,
386 const Formatter::Arg& arg9)
387 {
|
388 david 1.26 // Test for logLevel against severity mask to determine
|
389 mike 1.13 // if we write this log.
|
390 kumpf 1.40 if ((_severityMask & logLevel) != 0)
|
391 mike 1.13 {
|
392 kumpf 1.40 if (!_rep)
393 _rep = new LoggerRep(_homeDirectory);
|
394 mike 1.13
|
395 chuck 1.29
|
396 mreddy 1.53 // l10n start
|
397 chuck 1.29 // The localized message to be sent to the system log.
|
398 kumpf 1.40 String localizedMsg;
399
400 // If the caller specified a messageId, then load the localized
401 // message in the locale of the server process.
402 if (messageId != String::EMPTY)
403 {
404 // A message ID was specified. Use the MessageLoader.
405 MessageLoaderParms msgParms(messageId, formatString);
406 msgParms.useProcessLocale = true;
407 msgParms.arg0 = arg0;
408 msgParms.arg1 = arg1;
409 msgParms.arg2 = arg2;
410 msgParms.arg3 = arg3;
411 msgParms.arg4 = arg4;
412 msgParms.arg5 = arg5;
413 msgParms.arg6 = arg6;
414 msgParms.arg7 = arg7;
415 msgParms.arg8 = arg8;
416 msgParms.arg9 = arg9;
417
418 localizedMsg = MessageLoader::getMessage(msgParms);
419 kumpf 1.40 }
420 else
421 { // No message ID. Use the Pegasus formatter
422 localizedMsg = Formatter::format(formatString,
423 arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
424 }
425 // l10n end
426
427
|
428 mreddy 1.55 // Call the actual logging routine is in LoggerRep.
429 _rep->log(logFileType, systemId, logLevel, localizedMsg);
|
430 david 1.26 }
431 }
|
432 mike 1.13
|
433 mike 1.42 ////////////////////////////////////////////////////////////////////////////////
434 //
435 // Public methods start here:
436 //
437 ////////////////////////////////////////////////////////////////////////////////
438
|
439 david 1.26 void Logger::put(
|
440 kumpf 1.40 LogFileType logFileType,
441 const String& systemId,
442 Uint32 logLevel,
443 const String& formatString,
444 const Formatter::Arg& arg0,
445 const Formatter::Arg& arg1,
446 const Formatter::Arg& arg2,
447 const Formatter::Arg& arg3,
448 const Formatter::Arg& arg4,
449 const Formatter::Arg& arg5,
450 const Formatter::Arg& arg6,
451 const Formatter::Arg& arg7,
452 const Formatter::Arg& arg8,
453 const Formatter::Arg& arg9)
|
454 chuck 1.29 {
|
455 mike 1.42 if (wouldLog(logLevel))
456 {
457 Logger::_putInternal(logFileType, systemId, 0, logLevel,
|
458 kumpf 1.48 formatString, String::EMPTY, arg0, arg1, arg2, arg3,
|
459 mike 1.42 arg4, arg5, arg6, arg7, arg8, arg9);
460 }
|
461 karl 1.37 }
462
463 void Logger::put(
|
464 kumpf 1.40 LogFileType logFileType,
465 const String& systemId,
466 Uint32 logLevel,
467 const String& formatString)
|
468 karl 1.37 {
|
469 mike 1.42 if (wouldLog(logLevel))
470 {
471 Logger::_putInternal(logFileType, systemId, 0, logLevel,
472 formatString, String::EMPTY);
473 }
474 }
|
475 karl 1.37
|
476 mike 1.42 void Logger::put(
477 LogFileType logFileType,
478 const String& systemId,
479 Uint32 logLevel,
480 const String& formatString,
481 const Formatter::Arg& arg0)
482 {
483 if (wouldLog(logLevel))
484 {
485 Logger::_putInternal(logFileType, systemId, 0, logLevel,
486 formatString, String::EMPTY, arg0);
487 }
|
488 karl 1.37 }
489
490 void Logger::put(
|
491 kumpf 1.40 LogFileType logFileType,
492 const String& systemId,
493 Uint32 logLevel,
494 const String& formatString,
|
495 mike 1.42 const Formatter::Arg& arg0,
496 const Formatter::Arg& arg1)
|
497 karl 1.37 {
|
498 mike 1.42 if (wouldLog(logLevel))
499 {
500 Logger::_putInternal(logFileType, systemId, 0, logLevel,
501 formatString, String::EMPTY, arg0, arg1);
502 }
503 }
|
504 karl 1.37
|
505 mike 1.42 void Logger::put(
506 LogFileType logFileType,
507 const String& systemId,
508 Uint32 logLevel,
509 const String& formatString,
510 const Formatter::Arg& arg0,
511 const Formatter::Arg& arg1,
512 const Formatter::Arg& arg2)
513 {
514 if (wouldLog(logLevel))
515 {
516 Logger::_putInternal(logFileType, systemId, 0, logLevel,
517 formatString, String::EMPTY, arg0, arg1, arg2);
518 }
|
519 chuck 1.29 }
520
521 void Logger::put_l(
|
522 kumpf 1.40 LogFileType logFileType,
523 const String& systemId,
524 Uint32 logLevel,
|
525 mike 1.42 const String& messageId,
|
526 kumpf 1.40 const String& formatString,
527 const Formatter::Arg& arg0,
528 const Formatter::Arg& arg1,
529 const Formatter::Arg& arg2,
530 const Formatter::Arg& arg3,
531 const Formatter::Arg& arg4,
532 const Formatter::Arg& arg5,
533 const Formatter::Arg& arg6,
534 const Formatter::Arg& arg7,
535 const Formatter::Arg& arg8,
536 const Formatter::Arg& arg9)
|
537 david 1.26 {
|
538 mike 1.42 if (wouldLog(logLevel))
539 {
540 Logger::_putInternal(logFileType, systemId, 0, logLevel,
541 formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5,
542 arg6, arg7, arg8, arg9);
543 }
|
544 karl 1.37 }
545
546 void Logger::put_l(
547 LogFileType logFileType,
548 const String& systemId,
549 Uint32 logLevel,
550 const String& messageId,
551 const String& formatString)
552 {
|
553 mike 1.42 if (wouldLog(logLevel))
554 {
555 Logger::_putInternal(logFileType, systemId, 0, logLevel,
|
556 kumpf 1.40 formatString, messageId);
|
557 mike 1.42 }
|
558 karl 1.37 }
559
560 void Logger::put_l(
561 LogFileType logFileType,
562 const String& systemId,
563 Uint32 logLevel,
564 const String& messageId,
565 const String& formatString,
566 const Formatter::Arg& arg0)
567 {
|
568 mike 1.42 if (wouldLog(logLevel))
569 {
570 Logger::_putInternal(logFileType, systemId, 0, logLevel,
571 formatString, messageId, arg0);
572 }
573 }
|
574 karl 1.37
|
575 mike 1.42 void Logger::put_l(
576 LogFileType logFileType,
577 const String& systemId,
578 Uint32 logLevel,
579 const String& messageId,
580 const String& formatString,
581 const Formatter::Arg& arg0,
582 const Formatter::Arg& arg1)
583 {
584 if (wouldLog(logLevel))
585 {
586 Logger::_putInternal(logFileType, systemId, 0, logLevel,
587 formatString, messageId, arg0, arg1);
588 }
589 }
590
591 void Logger::put_l(
592 LogFileType logFileType,
593 const String& systemId,
594 Uint32 logLevel,
595 const String& messageId,
596 mike 1.42 const String& formatString,
597 const Formatter::Arg& arg0,
598 const Formatter::Arg& arg1,
599 const Formatter::Arg& arg2)
600 {
601 if (wouldLog(logLevel))
602 {
603 Logger::_putInternal(logFileType, systemId, 0, logLevel,
604 formatString, messageId, arg0, arg1, arg2);
605 }
|
606 david 1.26 }
607
608 void Logger::trace(
|
609 kumpf 1.40 LogFileType logFileType,
610 const String& systemId,
611 const Uint32 logComponent,
612 const String& formatString,
613 const Formatter::Arg& arg0,
614 const Formatter::Arg& arg1,
615 const Formatter::Arg& arg2,
616 const Formatter::Arg& arg3,
617 const Formatter::Arg& arg4,
618 const Formatter::Arg& arg5,
619 const Formatter::Arg& arg6,
620 const Formatter::Arg& arg7,
621 const Formatter::Arg& arg8,
622 const Formatter::Arg& arg9)
|
623 chuck 1.29 {
|
624 mike 1.42 if (wouldLog(Logger::TRACE))
625 {
626 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
627 formatString, String::EMPTY, arg0, arg1, arg2, arg3, arg4, arg5,
628 arg6, arg7, arg8, arg9);
629 }
630 }
|
631 chuck 1.29
|
632 mike 1.42 void Logger::trace(
633 LogFileType logFileType,
634 const String& systemId,
635 const Uint32 logComponent,
636 const String& formatString)
637 {
638 if (wouldLog(Logger::TRACE))
639 {
640 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
641 formatString, String::EMPTY);
642 }
643 }
644
645 void Logger::trace(
646 LogFileType logFileType,
647 const String& systemId,
648 const Uint32 logComponent,
649 const String& formatString,
650 const Formatter::Arg& arg0)
651 {
652 if (wouldLog(Logger::TRACE))
653 mike 1.42 {
654 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
655 formatString, String::EMPTY, arg0);
656 }
657 }
658
659 void Logger::trace(
660 LogFileType logFileType,
661 const String& systemId,
662 const Uint32 logComponent,
663 const String& formatString,
664 const Formatter::Arg& arg0,
665 const Formatter::Arg& arg1)
666 {
667 if (wouldLog(Logger::TRACE))
668 {
669 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
670 formatString, String::EMPTY, arg0, arg1);
671 }
672 }
673
674 mike 1.42 void Logger::trace(
675 LogFileType logFileType,
676 const String& systemId,
677 const Uint32 logComponent,
678 const String& formatString,
679 const Formatter::Arg& arg0,
680 const Formatter::Arg& arg1,
681 const Formatter::Arg& arg2)
682 {
683 if (wouldLog(Logger::TRACE))
684 {
685 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
686 formatString, String::EMPTY, arg0, arg1, arg2);
687 }
|
688 chuck 1.29 }
689
690 void Logger::trace_l(
|
691 kumpf 1.40 LogFileType logFileType,
692 const String& systemId,
693 const Uint32 logComponent,
694 const String& messageId,
695 const String& formatString,
696 const Formatter::Arg& arg0,
697 const Formatter::Arg& arg1,
698 const Formatter::Arg& arg2,
699 const Formatter::Arg& arg3,
700 const Formatter::Arg& arg4,
701 const Formatter::Arg& arg5,
702 const Formatter::Arg& arg6,
703 const Formatter::Arg& arg7,
704 const Formatter::Arg& arg8,
705 const Formatter::Arg& arg9)
|
706 david 1.26 {
|
707 mike 1.42 if (wouldLog(Logger::TRACE))
708 {
709 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
710 formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5, arg6,
711 arg7, arg8, arg9);
712 }
713 }
714
715 void Logger::trace_l(
716 LogFileType logFileType,
717 const String& systemId,
718 const Uint32 logComponent,
719 const String& messageId,
720 const String& formatString)
721 {
722 if (wouldLog(Logger::TRACE))
723 {
724 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
725 formatString, messageId);
726 }
727 }
728 mike 1.42
729 void Logger::trace_l(
730 LogFileType logFileType,
731 const String& systemId,
732 const Uint32 logComponent,
733 const String& messageId,
734 const String& formatString,
735 const Formatter::Arg& arg0)
736 {
737 if (wouldLog(Logger::TRACE))
738 {
739 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
740 formatString, messageId, arg0);
741 }
742 }
|
743 david 1.26
|
744 mike 1.42 void Logger::trace_l(
745 LogFileType logFileType,
746 const String& systemId,
747 const Uint32 logComponent,
748 const String& messageId,
749 const String& formatString,
750 const Formatter::Arg& arg0,
751 const Formatter::Arg& arg1)
752 {
753 if (wouldLog(Logger::TRACE))
754 {
755 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
756 formatString, messageId, arg0, arg1);
757 }
758 }
759
760 void Logger::trace_l(
761 LogFileType logFileType,
762 const String& systemId,
763 const Uint32 logComponent,
764 const String& messageId,
765 mike 1.42 const String& formatString,
766 const Formatter::Arg& arg0,
767 const Formatter::Arg& arg1,
768 const Formatter::Arg& arg2)
769 {
770 if (wouldLog(Logger::TRACE))
771 {
772 Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
773 formatString, messageId, arg0, arg1, arg2);
774 }
|
775 mike 1.13 }
776
777 void Logger::setHomeDirectory(const String& homeDirectory)
778 {
779 _homeDirectory = homeDirectory;
780 }
|
781 david 1.26
782 void Logger::setlogLevelMask( const String logLevelList )
783 {
|
784 karl 1.37 Uint32 logLevelType = 0;
|
785 david 1.26 String logLevelName = logLevelList;
786
787 // Check if logLevel has been specified
788 if (logLevelName != String::EMPTY)
789 {
790 // initialise _severityMask
791 _severityMask = 0;
792
|
793 kumpf 1.40 // Set logLevelType to indicate the level of logging
|
794 david 1.26 // required by the user.
|
795 kumpf 1.40 if (String::equalNoCase(logLevelName,"TRACE"))
796 {
797 logLevelType = Logger::TRACE;
798 }
799 else if (String::equalNoCase(logLevelName,"INFORMATION"))
800 {
801 logLevelType = Logger::INFORMATION;
802 }
803 else if (String::equalNoCase(logLevelName,"WARNING"))
804 {
805 logLevelType = Logger::WARNING;
806 }
807 else if (String::equalNoCase(logLevelName,"SEVERE"))
808 {
809 logLevelType = Logger::SEVERE;
810 }
811 else if (String::equalNoCase(logLevelName,"FATAL"))
812 {
813 logLevelType = Logger::FATAL;
814 }
815 // Setting _severityMask. NOTE: When adding new logLevels
|
816 david 1.26 // it is essential that they are adding in ascending order
817 // based on priority. Once a case statement is true we will
818 // continue to set all following log levels with a higher
819 // priority.
|
820 kumpf 1.40 switch(logLevelType)
821 {
822 case Logger::TRACE:
823 _severityMask |= Logger::TRACE;
824 case Logger::INFORMATION:
825 _severityMask |= Logger::INFORMATION;
826 case Logger::WARNING:
827 _severityMask |= Logger::WARNING;
828 case Logger::SEVERE:
829 _severityMask |= Logger::SEVERE;
830 case Logger::FATAL:
831 _severityMask |= Logger::FATAL;
832 }
|
833 kumpf 1.54
834 Executor::updateLogLevel(logLevelName.getCString());
|
835 david 1.26 }
836 else
837 {
|
838 kumpf 1.40 // Property logLevel not specified, set default value.
839 _severityMask = ~Logger::TRACE;
|
840 kumpf 1.54 Executor::updateLogLevel("INFORMATION");
|
841 david 1.26 }
842 }
843
|
844 mike 1.42 Boolean Logger::isValidlogLevel(const String logLevel)
|
845 david 1.26 {
846 // Validate the logLevel and modify the logLevel argument
847 // to reflect the invalid logLevel
848
849 Uint32 index=0;
850 String logLevelName = String::EMPTY;
851 Boolean validlogLevel=false;
852
853 logLevelName = logLevel;
854
855 if (logLevelName != String::EMPTY)
856 {
|
857 kumpf 1.40 // Lookup the index for logLevel name in _logLevel_LIST
858 index = 0;
859 validlogLevel = false;
860
861 while (index < _NUM_LOGLEVEL)
862 {
863 if (String::equalNoCase(logLevelName, LOGLEVEL_LIST[index]))
864 {
865 // Found logLevel, break from the loop
866 validlogLevel = true;
867 break;
868 }
869 else
870 {
871 index++;
872 }
873 }
|
874 david 1.26 }
875 else
876 {
|
877 kumpf 1.40 // logLevels is empty, it is a valid value so return true
878 return _SUCCESS;
|
879 david 1.26 }
880
881 return validlogLevel;
882 }
883
|
884 mike 1.55.2.4
885 void Logger::setLogCallback(Logger::LogCallback callback, void* data)
886 {
887 _callback = callback;
888 _data = data;
889 }
890
|
891 mike 1.13 PEGASUS_NAMESPACE_END
|