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