Home Patches

Patch for choose the syslog facility

AndrewAndrew Member Andrea NicotraOrganization: PersonalProject: Backend for IPTV
Hi,

I add Ice.SysLogFacility property for choose the syslog facility.

cheers
--- zeroc-ice-3.3.1/cpp/src/Ice/Instance.cpp	2009-03-20 18:52:13.000000000 +0100
+++ Ice-3.3.1/cpp/src/Ice/Instance.cpp	2009-10-23 10:42:50.000000000 +0200
@@ -903,12 +903,49 @@
             
             if(_initData.properties->getPropertyAsInt("Ice.UseSyslog") > 0)
             {
+                int logfac = 0;
+                string sysLogFacility = _initData.properties->getProperty("Ice.SysLogFacility") ;
+                
                 identForOpenlog = _initData.properties->getProperty("Ice.ProgramName");
                 if(identForOpenlog.empty())
                 {
                     identForOpenlog = "<Unknown Ice Program>";
                 }
-                openlog(identForOpenlog.c_str(), LOG_PID, LOG_USER);
+                
+                if(sysLogFacility.empty())
+                {
+                    openlog(identForOpenlog.c_str(), LOG_PID, LOG_USER);                   
+                }
+                else
+                {
+                    
+                    if (sysLogFacility.find("LOG_KERN") != string::npos) logfac = LOG_KERN;
+                    else if (sysLogFacility.find("LOG_USER") != string::npos) logfac = LOG_USER;
+                    else if (sysLogFacility.find("LOG_MAIL") != string::npos) logfac = LOG_MAIL;
+                    else if (sysLogFacility.find("LOG_DAEMON") != string::npos) logfac = LOG_DAEMON;
+                    else if (sysLogFacility.find("LOG_AUTH") != string::npos) logfac = LOG_AUTH;
+                    else if (sysLogFacility.find("LOG_SYSLOG") != string::npos) logfac = LOG_SYSLOG;
+                    else if (sysLogFacility.find("LOG_LPR") != string::npos) logfac = LOG_LPR;
+                    else if (sysLogFacility.find("LOG_NEWS") != string::npos) logfac = LOG_NEWS;
+                    else if (sysLogFacility.find("LOG_UUCP") != string::npos) logfac = LOG_UUCP;
+                    else if (sysLogFacility.find("LOG_CRON") != string::npos) logfac = LOG_CRON;
+                    else if (sysLogFacility.find("LOG_AUTHPRIV") != string::npos) logfac = LOG_AUTHPRIV;
+                    else if (sysLogFacility.find("LOG_FTP") != string::npos) logfac = LOG_FTP;
+                    else if (sysLogFacility.find("LOG_LOCAL0") != string::npos) logfac = LOG_LOCAL0;
+                    else if (sysLogFacility.find("LOG_LOCAL1") != string::npos) logfac = LOG_LOCAL1;
+                    else if (sysLogFacility.find("LOG_LOCAL2") != string::npos) logfac = LOG_LOCAL2;
+                    else if (sysLogFacility.find("LOG_LOCAL3") != string::npos) logfac = LOG_LOCAL3;
+                    else if (sysLogFacility.find("LOG_LOCAL4") != string::npos) logfac = LOG_LOCAL4;
+                    else if (sysLogFacility.find("LOG_LOCAL5") != string::npos) logfac = LOG_LOCAL5;
+                    else if (sysLogFacility.find("LOG_LOCAL6") != string::npos) logfac = LOG_LOCAL6;
+                    else if (sysLogFacility.find("LOG_LOCAL7") != string::npos) logfac = LOG_LOCAL7;
+                    
+                    if(!logfac)
+                    {
+                        throw InitializationException(__FILE__, __LINE__, "Error on Ice.SysLogFacility property.");
+                    }
+                    openlog(identForOpenlog.c_str(), LOG_PID, logfac);
+                }
             }
 #endif
         }
diff -Naur zeroc-ice-3.3.1/cpp/src/Ice/PropertyNames.cpp Ice-3.3.1/cpp/src/Ice/PropertyNames.cpp
--- zeroc-ice-3.3.1/cpp/src/Ice/PropertyNames.cpp	2009-10-21 19:13:02.000000000 +0200
+++ Ice-3.3.1/cpp/src/Ice/PropertyNames.cpp	2009-10-21 19:13:33.000000000 +0200
@@ -114,6 +114,7 @@
     IceInternal::Property("Ice.TCP.RcvSize", false, 0),
     IceInternal::Property("Ice.TCP.SndSize", false, 0),
     IceInternal::Property("Ice.UseSyslog", false, 0),
+    IceInternal::Property("Ice.SysLogFacility", false, 0),
     IceInternal::Property("Ice.Warn.AMICallback", false, 0),
     IceInternal::Property("Ice.Warn.Connections", false, 0),
     IceInternal::Property("Ice.Warn.Datagrams", false, 0),

Sign In or Register to comment.