(file) Return to Logger.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2