renamed some IKEv2 OpenSSL scenarios
[strongswan.git] / src / charon / bus / listeners / sys_logger.c
index 876fab8..5bcf28f 100644 (file)
@@ -11,8 +11,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
- *
- * $Id$
  */
 
 #include <stdio.h>
@@ -40,19 +38,18 @@ struct private_sys_logger_t {
        int facility;
        
        /**
-        * Maximum level to log
+        * Maximum level to log, for each group
         */
        level_t levels[DBG_MAX];
 };
 
-
 /**
- * Implementation of bus_listener_t.signal.
+ * Implementation of listener_t.log.
  */
-static bool signal_(private_sys_logger_t *this, signal_t signal, level_t level,
-                                       int thread, ike_sa_t* ike_sa, char *format, va_list args)
+static bool log_(private_sys_logger_t *this, debug_t group, level_t level,
+                                int thread, ike_sa_t* ike_sa, char *format, va_list args)
 {
-       if (level <= this->levels[SIG_TYPE(signal)])
+       if (level <= this->levels[group])
        {
                char buffer[8192];
                char *current = buffer, *next;
@@ -69,7 +66,7 @@ static bool signal_(private_sys_logger_t *this, signal_t signal, level_t level,
                                *(next++) = '\0';
                        }
                        syslog(this->facility|LOG_INFO, "%.2d[%N] %s\n",
-                                  thread, signal_names, signal, current);
+                                  thread, debug_names, group, current);
                        current = next;
                }
        }
@@ -80,20 +77,18 @@ static bool signal_(private_sys_logger_t *this, signal_t signal, level_t level,
 /**
  * Implementation of sys_logger_t.set_level.
  */
-static void set_level(private_sys_logger_t *this, signal_t signal, level_t level)
+static void set_level(private_sys_logger_t *this, debug_t group, level_t level)
 {
-       if (signal == SIG_ANY)
+       if (group < DBG_ANY)
        {
-               int i;
-               for (i = 0; i < DBG_MAX; i++)
-               {
-                       this->levels[i] = level;
-               }
+               this->levels[group] = level;
        }
        else
        {
-               
-               this->levels[SIG_TYPE(signal)] = level;
+               for (group = 0; group < DBG_MAX; group++)
+               {
+                       this->levels[group] = level;
+               }
        }
 }
 
@@ -114,13 +109,14 @@ sys_logger_t *sys_logger_create(int facility)
        private_sys_logger_t *this = malloc_thing(private_sys_logger_t);
        
        /* public functions */
-       this->public.listener.signal = (bool(*)(bus_listener_t*,signal_t,level_t,int,ike_sa_t*,char*,va_list))signal_;
-       this->public.set_level = (void(*)(sys_logger_t*,signal_t,level_t))set_level;
+       memset(&this->public.listener, 0, sizeof(listener_t));
+       this->public.listener.log = (bool(*)(listener_t*,debug_t,level_t,int,ike_sa_t*,char*,va_list))log_;
+       this->public.set_level = (void(*)(sys_logger_t*,debug_t,level_t))set_level;
        this->public.destroy = (void(*)(sys_logger_t*))destroy;
        
        /* private variables */
        this->facility = facility;
-       set_level(this, SIG_ANY, LEVEL_SILENT);
+       set_level(this, DBG_ANY, LEVEL_SILENT);
        
        return &this->public;
 }