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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2