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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2