(file) Return to Log.c CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Executor

Diff for /pegasus/src/Executor/Log.c between version 1.2 and 1.3

version 1.2, 2007/05/25 18:35:07 version 1.3, 2007/06/12 18:19:46
Line 36 
Line 36 
 #include <syslog.h> #include <syslog.h>
 #include <string.h> #include <string.h>
 #include <stdarg.h> #include <stdarg.h>
 #include "Strlcpy.h"  
 #include "Strlcat.h"  
  
 static enum LogLevel _level = LL_INFORMATION; static enum LogLevel _level = LL_INFORMATION;
  
 void OpenLog(const char* ident)  /*
   **==============================================================================
   **
   ** InitLogLevel()
   **
   **==============================================================================
   */
   
   void InitLogLevel()
 { {
     int options = LOG_PID;      char buffer[EXECUTOR_BUFFER_SIZE];
  
     openlog(ident, options, LOG_DAEMON);      if (GetConfigParam("logLevel", buffer) == 0)
       {
           if (strcasecmp(buffer, "TRACE") == 0)
               _level = LL_TRACE;
           else if (strcasecmp(buffer, "INFORMATION") == 0)
               _level = LL_INFORMATION;
           else if (strcasecmp(buffer, "WARNING") == 0)
               _level = LL_WARNING;
           else if (strcasecmp(buffer, "SEVERE") == 0)
               _level = LL_SEVERE;
           else if (strcasecmp(buffer, "FATAL") == 0)
               _level = LL_FATAL;
       }
 } }
  
 void SetLogLevel(enum LogLevel level)  /*
   **==============================================================================
   **
   ** GetLogLevel()
   **
   **==============================================================================
   */
   
   enum LogLevel GetLogLevel()
 { {
     _level = level;      return _level;
   }
   
   void OpenLog(const char* ident)
   {
       int options = LOG_PID;
   
       openlog(ident, options, LOG_DAEMON);
 } }
  
 void Log(enum LogLevel type, const char *format, ...) void Log(enum LogLevel type, const char *format, ...)
Line 66 
Line 99 
         LOG_DEBUG, /* LL_TRACE */         LOG_DEBUG, /* LL_TRACE */
     };     };
  
     static const char* _prefix[] =  
     {  
         "FATAL",  
         "SEVERE",  
         "WARNING",  
         "INFORMATION",  
         "TRACE"  
     };  
   
     char prefixedFormat[EXECUTOR_BUFFER_SIZE];  
   
     /* Prefix the format with the log level. */  
   
     Strlcpy(prefixedFormat, _prefix[(int)type], sizeof(prefixedFormat));  
     Strlcat(prefixedFormat, ": ", sizeof(prefixedFormat));  
     Strlcat(prefixedFormat, format, sizeof(prefixedFormat));  
   
     /* This array maps Pegasus "log levels" to syslog priorities. */     /* This array maps Pegasus "log levels" to syslog priorities. */
  
     if ((int)type <= (int)_level)     if ((int)type <= (int)_level)
Line 92 
Line 108 
  
         va_start(ap, format);         va_start(ap, format);
         /* Flawfinder: ignore */         /* Flawfinder: ignore */
         vsprintf(buffer, prefixedFormat, ap);          vsprintf(buffer, format, ap);
         va_end(ap);         va_end(ap);
  
         syslog(_priorities[(int)type], "%s", buffer);         syslog(_priorities[(int)type], "%s", buffer);
     }     }
 } }
   
 /*  
 **==============================================================================  
 **  
 ** GetLogLevel()  
 **  
 **==============================================================================  
 */  
   
 void GetLogLevel()  
 {  
     char buffer[EXECUTOR_BUFFER_SIZE];  
   
     if (GetConfigParam("logLevel", buffer) == 0)  
     {  
         if (strcasecmp(buffer, "TRACE") == 0)  
             SetLogLevel(LL_TRACE);  
         else if (strcasecmp(buffer, "INFORMATION") == 0)  
             SetLogLevel(LL_INFORMATION);  
         else if (strcasecmp(buffer, "WARNING") == 0)  
             SetLogLevel(LL_WARNING);  
         else if (strcasecmp(buffer, "SEVERE") == 0)  
             SetLogLevel(LL_SEVERE);  
         else if (strcasecmp(buffer, "FATAL") == 0)  
             SetLogLevel(LL_FATAL);  
     }  
 }  


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2