renamed some IKEv2 OpenSSL scenarios
[strongswan.git] / src / charon / bus / listeners / sys_logger.c
index 58c59c4..5bcf28f 100644 (file)
@@ -1,10 +1,3 @@
-/**
- * @file sys_logger.c
- *
- * @brief Implementation of sys_logger_t.
- *
- */
-
 /*
  * Copyright (C) 2006 Martin Willi
  * Hochschule fuer Technik Rapperswil
@@ -45,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 void 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;
@@ -74,29 +66,29 @@ static void 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;
                }
        }
+       /* always stay registered */
+       return TRUE;
 }
 
 /**
  * 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;
+               }
        }
 }
 
@@ -117,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 = (void(*)(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;
 }