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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2