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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2