(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                 "PegasusError.log",
132                 "PegasusDebug.log"
133             };
134             static const char* lockFileName = "PegasusLog.lock";
135             
136             /*
137                 _constructFileName builds the absolute file name from homeDirectory
138 mreddy 1.55     and fileName.
139             */
140             static CString _constructFileName(
141                 const String& homeDirectory,
142                 const char * fileName)
143             {
144 mike   1.13     String result;
145 kumpf  1.57     result.reserveCapacity(
146                     (Uint32)(homeDirectory.size() + 1 + strlen(fileName)));
147 kumpf  1.20     result.append(homeDirectory);
148                 result.append('/');
149 mreddy 1.55     result.append(fileName);
150 kumpf  1.22     return result.getCString();
151 mike   1.13 }
152             
153             class LoggerRep
154             {
155             public:
156             
157                 LoggerRep(const String& homeDirectory)
158                 {
159 kumpf  1.40         // Add test for home directory set.
160 mike   1.13 
161 kumpf  1.40         // If home directory does not exist, create it.
162                     CString lgDir = homeDirectory.getCString();
163 mike   1.13 
164 kumpf  1.40         if (!System::isDirectory(lgDir))
165                         System::makeDirectory(lgDir);
166 mike   1.13 
167 kumpf  1.40         // KS: I put the second test in just in case some trys to create
168                     // a completly erronous directory.  At least we will get a message
169 kumpf  1.48         if (!System::isDirectory(lgDir))
170                     {
171                         MessageLoaderParms parms("Common.Logger.LOGGING_DISABLED",
172                             "Logging Disabled");
173 kumpf  1.40 
174 kumpf  1.48             cerr << MessageLoader::getMessage(parms);
175 kumpf  1.40         }
176             
177 mreddy 1.55        //Filelocks are not used for VMS
178 kumpf  1.57 # if !defined(PEGASUS_OS_VMS)
179 mreddy 1.55         _loggerLockFileName = _constructFileName(homeDirectory, lockFileName);
180             
181                     // Open and close a file to make sure that the file exists, on which
182                     // file lock is requested
183                     FILE *fileLockFilePointer;
184                     fileLockFilePointer = fopen(_loggerLockFileName, "a+");
185                     if(fileLockFilePointer)
186                     {
187                         fclose(fileLockFilePointer);
188                     }
189 kumpf  1.57 # endif
190 mreddy 1.55 
191                     _logFileNames[Logger::TRACE_LOG] = _constructFileName(homeDirectory,
192                                                            fileNames[Logger::TRACE_LOG]);
193 kumpf  1.40 
194 mreddy 1.55         _logFileNames[Logger::STANDARD_LOG] = _constructFileName(homeDirectory,
195                                                            fileNames[Logger::STANDARD_LOG]);
196 kumpf  1.40 
197 kumpf  1.57 # ifdef PEGASUS_ENABLE_AUDIT_LOGGER
198 mreddy 1.55         _logFileNames[Logger::AUDIT_LOG] = _constructFileName(homeDirectory,
199                                                            fileNames[Logger::AUDIT_LOG]);
200 kumpf  1.57 # endif
201 thilo.boehm 1.46 
202 mreddy      1.55         _logFileNames[Logger::ERROR_LOG] = _constructFileName(homeDirectory,
203                                                                 fileNames[Logger::ERROR_LOG]);
204 marek       1.47     }
205                  
206                      ~LoggerRep()
207                      {
208 mreddy      1.55     }
209                  
210                      // Actual logging is done in this routine
211                      void log(Logger::LogFileType logFileType,
212                          const String& systemId,
213                          Uint32 logLevel,
214                          const String localizedMsg)
215                      {
216                          // 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 kumpf       1.57         {
247 mreddy      1.55             // 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                              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 mike        1.13     }
287                  
288                  private:
289                  
290 mreddy      1.55     CString _logFileNames[int(Logger::NUM_LOGS)];
291 kumpf       1.57 
292                  # ifndef PEGASUS_OS_VMS
293 mreddy      1.55     CString _loggerLockFileName;
294                      Mutex _mutex;
295 kumpf       1.57 # endif
296 mike        1.13 };
297                  
298 kumpf       1.57 #endif    // !defined(PEGASUS_USE_SYSLOGS)
299                  
300                  
301                  ///////////////////////////////////////////////////////////////////////////////
302                  //
303                  // Logger
304                  //
305                  ///////////////////////////////////////////////////////////////////////////////
306                  
307 david       1.26 void Logger::_putInternal(
308 mike        1.13     LogFileType logFileType,
309                      const String& systemId,
310 kumpf       1.48     const Uint32 logComponent, // FUTURE: Support logComponent mask
311 david       1.26     Uint32 logLevel,
312 mike        1.13     const String& formatString,
313 kumpf       1.48     const String& messageId,
314 mike        1.13     const Formatter::Arg& arg0,
315                      const Formatter::Arg& arg1,
316                      const Formatter::Arg& arg2,
317                      const Formatter::Arg& arg3,
318                      const Formatter::Arg& arg4,
319                      const Formatter::Arg& arg5,
320                      const Formatter::Arg& arg6,
321                      const Formatter::Arg& arg7,
322                      const Formatter::Arg& arg8,
323                      const Formatter::Arg& arg9)
324                  {
325 david       1.26     // Test for logLevel against severity mask to determine
326 mike        1.13     // if we write this log.
327 kumpf       1.40     if ((_severityMask & logLevel) != 0)
328 mike        1.13     {
329 kumpf       1.40         if (!_rep)
330                             _rep = new LoggerRep(_homeDirectory);
331 mike        1.13 
332 chuck       1.29 
333 mreddy      1.53         // l10n start
334 chuck       1.29         // The localized message to be sent to the system log.
335 kumpf       1.40         String localizedMsg;
336                  
337                          // If the caller specified a messageId, then load the localized
338                          // message in the locale of the server process.
339                          if (messageId != String::EMPTY)
340                          {
341                              // A message ID was specified.  Use the MessageLoader.
342                              MessageLoaderParms msgParms(messageId, formatString);
343                              msgParms.useProcessLocale = true;
344                              msgParms.arg0 = arg0;
345                              msgParms.arg1 = arg1;
346                              msgParms.arg2 = arg2;
347                              msgParms.arg3 = arg3;
348                              msgParms.arg4 = arg4;
349                              msgParms.arg5 = arg5;
350                              msgParms.arg6 = arg6;
351                              msgParms.arg7 = arg7;
352                              msgParms.arg8 = arg8;
353                              msgParms.arg9 = arg9;
354                  
355                              localizedMsg = MessageLoader::getMessage(msgParms);
356 kumpf       1.40         }
357                          else
358                          {  // No message ID.  Use the Pegasus formatter
359                                localizedMsg = Formatter::format(formatString,
360                                  arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
361                          }
362                  // l10n end
363                  
364 mreddy      1.55        // Call the actual logging routine is in LoggerRep.
365                         _rep->log(logFileType, systemId, logLevel, localizedMsg);
366 marek       1.59        
367                         // route log message to trace too -> component LogMessages
368                         if (Logger::TRACE_LOG != logFileType)
369                         {
370                             // do not write log message to trace when trace facility is
371                             // the log to avoid double messages
372                             if (Tracer::TRACE_FACILITY_LOG != Tracer::getTraceFacility())
373                             {
374                                 PEG_TRACE_CSTRING(
375                                     TRC_LOGMSG,
376                                     Tracer::LEVEL1,
377                                     (const char*) localizedMsg.getCString());
378                             }
379                         }
380 david       1.26     }
381                  }
382 mike        1.13 
383 mike        1.42 ////////////////////////////////////////////////////////////////////////////////
384                  //
385                  // Public methods start here:
386                  //
387                  ////////////////////////////////////////////////////////////////////////////////
388                  
389 david       1.26 void Logger::put(
390 kumpf       1.40     LogFileType logFileType,
391                      const String& systemId,
392                      Uint32 logLevel,
393                      const String& formatString,
394                      const Formatter::Arg& arg0,
395                      const Formatter::Arg& arg1,
396                      const Formatter::Arg& arg2,
397                      const Formatter::Arg& arg3,
398                      const Formatter::Arg& arg4,
399                      const Formatter::Arg& arg5,
400                      const Formatter::Arg& arg6,
401                      const Formatter::Arg& arg7,
402                      const Formatter::Arg& arg8,
403                      const Formatter::Arg& arg9)
404 chuck       1.29 {
405 mike        1.42     if (wouldLog(logLevel))
406                      {
407                          Logger::_putInternal(logFileType, systemId, 0, logLevel,
408 kumpf       1.48             formatString, String::EMPTY, arg0, arg1, arg2, arg3,
409 mike        1.42             arg4, arg5, arg6, arg7, arg8, arg9);
410                      }
411 karl        1.37 }
412                  
413                  void Logger::put(
414 kumpf       1.40     LogFileType logFileType,
415                      const String& systemId,
416                      Uint32 logLevel,
417                      const String& formatString)
418 karl        1.37 {
419 mike        1.42     if (wouldLog(logLevel))
420                      {
421                          Logger::_putInternal(logFileType, systemId, 0, logLevel,
422                              formatString, String::EMPTY);
423                      }
424                  }
425 karl        1.37 
426 mike        1.42 void Logger::put(
427                      LogFileType logFileType,
428                      const String& systemId,
429                      Uint32 logLevel,
430                      const String& formatString,
431                      const Formatter::Arg& arg0)
432                  {
433                      if (wouldLog(logLevel))
434                      {
435                          Logger::_putInternal(logFileType, systemId, 0, logLevel,
436                              formatString, String::EMPTY, arg0);
437                      }
438 karl        1.37 }
439                  
440                  void Logger::put(
441 kumpf       1.40     LogFileType logFileType,
442                      const String& systemId,
443                      Uint32 logLevel,
444                      const String& formatString,
445 mike        1.42     const Formatter::Arg& arg0,
446                      const Formatter::Arg& arg1)
447 karl        1.37 {
448 mike        1.42     if (wouldLog(logLevel))
449                      {
450                          Logger::_putInternal(logFileType, systemId, 0, logLevel,
451                              formatString, String::EMPTY, arg0, arg1);
452                      }
453                  }
454 karl        1.37 
455 mike        1.42 void Logger::put(
456                      LogFileType logFileType,
457                      const String& systemId,
458                      Uint32 logLevel,
459                      const String& formatString,
460                      const Formatter::Arg& arg0,
461                      const Formatter::Arg& arg1,
462                      const Formatter::Arg& arg2)
463                  {
464                      if (wouldLog(logLevel))
465                      {
466                          Logger::_putInternal(logFileType, systemId, 0, logLevel,
467                              formatString, String::EMPTY, arg0, arg1, arg2);
468                      }
469 chuck       1.29 }
470                  
471                  void Logger::put_l(
472 kumpf       1.40     LogFileType logFileType,
473                      const String& systemId,
474                      Uint32 logLevel,
475 mike        1.42     const String& messageId,
476 kumpf       1.40     const String& formatString,
477                      const Formatter::Arg& arg0,
478                      const Formatter::Arg& arg1,
479                      const Formatter::Arg& arg2,
480                      const Formatter::Arg& arg3,
481                      const Formatter::Arg& arg4,
482                      const Formatter::Arg& arg5,
483                      const Formatter::Arg& arg6,
484                      const Formatter::Arg& arg7,
485                      const Formatter::Arg& arg8,
486                      const Formatter::Arg& arg9)
487 david       1.26 {
488 mike        1.42     if (wouldLog(logLevel))
489                      {
490                          Logger::_putInternal(logFileType, systemId, 0, logLevel,
491                              formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5,
492                              arg6, arg7, arg8, arg9);
493                      }
494 karl        1.37 }
495                  
496                  void Logger::put_l(
497                       LogFileType logFileType,
498                       const String& systemId,
499                       Uint32 logLevel,
500                       const String& messageId,
501                       const String& formatString)
502                  {
503 mike        1.42     if (wouldLog(logLevel))
504                      {
505                          Logger::_putInternal(logFileType, systemId, 0, logLevel,
506 kumpf       1.40         formatString, messageId);
507 mike        1.42     }
508 karl        1.37 }
509                  
510                  void Logger::put_l(
511                       LogFileType logFileType,
512                       const String& systemId,
513                       Uint32 logLevel,
514                       const String& messageId,
515                       const String& formatString,
516                       const Formatter::Arg& arg0)
517                  {
518 mike        1.42     if (wouldLog(logLevel))
519                      {
520                          Logger::_putInternal(logFileType, systemId, 0, logLevel,
521                              formatString, messageId, arg0);
522                      }
523                  }
524 karl        1.37 
525 mike        1.42 void Logger::put_l(
526                       LogFileType logFileType,
527                       const String& systemId,
528                       Uint32 logLevel,
529                       const String& messageId,
530                       const String& formatString,
531                       const Formatter::Arg& arg0,
532                       const Formatter::Arg& arg1)
533                  {
534                      if (wouldLog(logLevel))
535                      {
536                          Logger::_putInternal(logFileType, systemId, 0, logLevel,
537                              formatString, messageId, arg0, arg1);
538                      }
539                  }
540                  
541                  void Logger::put_l(
542                       LogFileType logFileType,
543                       const String& systemId,
544                       Uint32 logLevel,
545                       const String& messageId,
546 mike        1.42      const String& formatString,
547                       const Formatter::Arg& arg0,
548                       const Formatter::Arg& arg1,
549                       const Formatter::Arg& arg2)
550                  {
551                      if (wouldLog(logLevel))
552                      {
553                          Logger::_putInternal(logFileType, systemId, 0, logLevel,
554                              formatString, messageId, arg0, arg1, arg2);
555                      }
556 david       1.26 }
557                  
558                  void Logger::trace(
559 kumpf       1.40     LogFileType logFileType,
560                      const String& systemId,
561                      const Uint32 logComponent,
562                      const String& formatString,
563                      const Formatter::Arg& arg0,
564                      const Formatter::Arg& arg1,
565                      const Formatter::Arg& arg2,
566                      const Formatter::Arg& arg3,
567                      const Formatter::Arg& arg4,
568                      const Formatter::Arg& arg5,
569                      const Formatter::Arg& arg6,
570                      const Formatter::Arg& arg7,
571                      const Formatter::Arg& arg8,
572                      const Formatter::Arg& arg9)
573 chuck       1.29 {
574 mike        1.42     if (wouldLog(Logger::TRACE))
575                      {
576                          Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
577                              formatString, String::EMPTY, arg0, arg1, arg2, arg3, arg4, arg5,
578                              arg6, arg7, arg8, arg9);
579                      }
580                  }
581 chuck       1.29 
582 mike        1.42 void Logger::trace(
583                      LogFileType logFileType,
584                      const String& systemId,
585                      const Uint32 logComponent,
586                      const String& formatString)
587                  {
588                      if (wouldLog(Logger::TRACE))
589                      {
590                          Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
591                              formatString, String::EMPTY);
592                      }
593                  }
594                  
595                  void Logger::trace(
596                      LogFileType logFileType,
597                      const String& systemId,
598                      const Uint32 logComponent,
599                      const String& formatString,
600                      const Formatter::Arg& arg0)
601                  {
602                      if (wouldLog(Logger::TRACE))
603 mike        1.42     {
604                          Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
605                              formatString, String::EMPTY, arg0);
606                      }
607                  }
608                  
609                  void Logger::trace(
610                      LogFileType logFileType,
611                      const String& systemId,
612                      const Uint32 logComponent,
613                      const String& formatString,
614                      const Formatter::Arg& arg0,
615                      const Formatter::Arg& arg1)
616                  {
617                      if (wouldLog(Logger::TRACE))
618                      {
619                          Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
620                              formatString, String::EMPTY, arg0, arg1);
621                      }
622                  }
623                  
624 mike        1.42 void Logger::trace(
625                      LogFileType logFileType,
626                      const String& systemId,
627                      const Uint32 logComponent,
628                      const String& formatString,
629                      const Formatter::Arg& arg0,
630                      const Formatter::Arg& arg1,
631                      const Formatter::Arg& arg2)
632                  {
633                      if (wouldLog(Logger::TRACE))
634                      {
635                          Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
636                              formatString, String::EMPTY, arg0, arg1, arg2);
637                      }
638 chuck       1.29 }
639                  
640                  void Logger::trace_l(
641 kumpf       1.40     LogFileType logFileType,
642                      const String& systemId,
643                      const Uint32 logComponent,
644                      const String& messageId,
645                      const String& formatString,
646                      const Formatter::Arg& arg0,
647                      const Formatter::Arg& arg1,
648                      const Formatter::Arg& arg2,
649                      const Formatter::Arg& arg3,
650                      const Formatter::Arg& arg4,
651                      const Formatter::Arg& arg5,
652                      const Formatter::Arg& arg6,
653                      const Formatter::Arg& arg7,
654                      const Formatter::Arg& arg8,
655                      const Formatter::Arg& arg9)
656 david       1.26 {
657 mike        1.42     if (wouldLog(Logger::TRACE))
658                      {
659                          Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
660                              formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5, arg6,
661                              arg7, arg8, arg9);
662                      }
663                  }
664                  
665                  void Logger::trace_l(
666                      LogFileType logFileType,
667                      const String& systemId,
668                      const Uint32 logComponent,
669                      const String& messageId,
670                      const String& formatString)
671                  {
672                      if (wouldLog(Logger::TRACE))
673                      {
674                          Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
675                              formatString, messageId);
676                      }
677                  }
678 mike        1.42 
679                  void Logger::trace_l(
680                      LogFileType logFileType,
681                      const String& systemId,
682                      const Uint32 logComponent,
683                      const String& messageId,
684                      const String& formatString,
685                      const Formatter::Arg& arg0)
686                  {
687                      if (wouldLog(Logger::TRACE))
688                      {
689                          Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
690                              formatString, messageId, arg0);
691                      }
692                  }
693 david       1.26 
694 mike        1.42 void Logger::trace_l(
695                      LogFileType logFileType,
696                      const String& systemId,
697                      const Uint32 logComponent,
698                      const String& messageId,
699                      const String& formatString,
700                      const Formatter::Arg& arg0,
701                      const Formatter::Arg& arg1)
702                  {
703                      if (wouldLog(Logger::TRACE))
704                      {
705                          Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
706                              formatString, messageId, arg0, arg1);
707                      }
708                  }
709                  
710                  void Logger::trace_l(
711                      LogFileType logFileType,
712                      const String& systemId,
713                      const Uint32 logComponent,
714                      const String& messageId,
715 mike        1.42     const String& formatString,
716                      const Formatter::Arg& arg0,
717                      const Formatter::Arg& arg1,
718                      const Formatter::Arg& arg2)
719                  {
720                      if (wouldLog(Logger::TRACE))
721                      {
722                          Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE,
723                              formatString, messageId, arg0, arg1, arg2);
724                      }
725 mike        1.13 }
726                  
727                  void Logger::setHomeDirectory(const String& homeDirectory)
728                  {
729                      _homeDirectory = homeDirectory;
730                  }
731 david       1.26 
732                  void Logger::setlogLevelMask( const String logLevelList )
733                  {
734 karl        1.37     Uint32 logLevelType = 0;
735 david       1.26     String logLevelName      = logLevelList;
736                  
737                      // Check if logLevel has been specified
738                      if (logLevelName != String::EMPTY)
739                      {
740                          // initialise _severityMask
741                          _severityMask = 0;
742                  
743 kumpf       1.40         // Set logLevelType to indicate the level of logging
744 david       1.26         // required by the user.
745 kumpf       1.40         if (String::equalNoCase(logLevelName,"TRACE"))
746                          {
747                              logLevelType =  Logger::TRACE;
748                          }
749                          else if (String::equalNoCase(logLevelName,"INFORMATION"))
750                          {
751                              logLevelType =  Logger::INFORMATION;
752                          }
753                          else if (String::equalNoCase(logLevelName,"WARNING"))
754                          {
755                              logLevelType = Logger::WARNING;
756                          }
757                          else if (String::equalNoCase(logLevelName,"SEVERE"))
758                          {
759                              logLevelType = Logger::SEVERE;
760                          }
761                          else if (String::equalNoCase(logLevelName,"FATAL"))
762                          {
763                              logLevelType = Logger::FATAL;
764                          }
765                          // Setting _severityMask.  NOTE:  When adding new logLevels
766 david       1.26         // it is essential that they are adding in ascending order
767                          // based on priority.  Once a case statement is true we will
768                          // continue to set all following log levels with a higher
769                          // priority.
770 kumpf       1.40         switch(logLevelType)
771                          {
772                              case Logger::TRACE:
773                                    _severityMask |= Logger::TRACE;
774                              case Logger::INFORMATION:
775                                    _severityMask |= Logger::INFORMATION;
776                              case Logger::WARNING:
777                                    _severityMask |= Logger::WARNING;
778                              case Logger::SEVERE:
779                                    _severityMask |= Logger::SEVERE;
780                              case Logger::FATAL:
781                                    _severityMask |= Logger::FATAL;
782                          }
783 kumpf       1.54 
784                          Executor::updateLogLevel(logLevelName.getCString());
785 david       1.26     }
786                      else
787                      {
788 kumpf       1.40         // Property logLevel not specified, set default value.
789                          _severityMask = ~Logger::TRACE;
790 kumpf       1.54         Executor::updateLogLevel("INFORMATION");
791 david       1.26     }
792                  }
793                  
794 mike        1.42 Boolean Logger::isValidlogLevel(const String logLevel)
795 david       1.26 {
796                      // Validate the logLevel and modify the logLevel argument
797                      // to reflect the invalid logLevel
798                  
799                      Uint32    index=0;
800                      String    logLevelName = String::EMPTY;
801                      Boolean   validlogLevel=false;
802                  
803                      logLevelName = logLevel;
804                  
805                      if (logLevelName != String::EMPTY)
806                      {
807 kumpf       1.40         // Lookup the index for logLevel name in _logLevel_LIST
808                          index = 0;
809                          validlogLevel = false;
810                  
811                          while (index < _NUM_LOGLEVEL)
812                          {
813                              if (String::equalNoCase(logLevelName, LOGLEVEL_LIST[index]))
814                              {
815                                  // Found logLevel, break from the loop
816                                  validlogLevel = true;
817                                  break;
818                              }
819                              else
820                              {
821                                  index++;
822                              }
823                          }
824 david       1.26     }
825                      else
826                      {
827 kumpf       1.40         // logLevels is empty, it is a valid value so return true
828 kumpf       1.57         return true;
829 david       1.26     }
830                  
831                      return validlogLevel;
832                  }
833                  
834 mike        1.13 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2