Problem with assert.h in previous patch fixed here.

Index: logsys.c
===================================================================
--- logsys.c    (revision 1568)
+++ logsys.c    (working copy)
@@ -632,3 +632,41 @@
 {
        worker_thread_group_wait (&log_thread_group);
 }
+
+int logsys_init (char *name, int mode, int facility, int priority, char *file)
+{
+       char *errstr;
+
+       logsys_subsys_id = 0;
+
+       strncpy (logsys_loggers[0].subsys, name,
+                sizeof (logsys_loggers[0].subsys));
+       logsys_config_mode_set (mode);
+       logsys_config_facility_set (name, facility);
+       logsys_config_file_set (&errstr, file);
+       _logsys_config_priority_set (0, priority);
+       if ((mode & LOG_MODE_BUFFER_BEFORE_CONFIG) == 0) {
+               _logsys_wthread_create ();
+       }
+       return (0);
+}
+
+int logsys_conf (char *name, int mode, int facility, int priority, char *file)
+{
+       char *errstr;
+
+       strncpy (logsys_loggers[0].subsys, name,
+               sizeof (logsys_loggers[0].subsys));
+       logsys_config_mode_set (mode);
+       logsys_config_facility_set (name, facility);
+       logsys_config_file_set (&errstr, file);
+       _logsys_config_priority_set (0, priority);
+       return (0);
+}
+
+void logsys_exit (void)
+{
+       logsys_subsys_id = -1;
+       logsys_flush ();
+}
+
Index: logsys.h
===================================================================
--- logsys.h    (revision 1568)
+++ logsys.h    (working copy)
@@ -38,6 +38,7 @@
 
 #include <stdarg.h>
 #include <syslog.h>
+#include <assert.h>
 
 /*
  * MODE_OUTPUT_SYSLOG_* modes are mutually exclusive
@@ -170,8 +171,9 @@
        }                                                               \
 }
 
+static unsigned int logsys_subsys_id __attribute__((unused)) = -1;     \
+
 #define LOGSYS_DECLARE_NOSUBSYS(priority)                              \
-static unsigned int logsys_subsys_id __attribute__((unused));          \
 __attribute__ ((constructor)) static void logsys_nosubsys_init (void)  \
 {                                                                      \
        _logsys_nosubsys_set();                                         \
@@ -180,7 +182,6 @@
 }
 
 #define LOGSYS_DECLARE_SUBSYS(subsys,priority)                         \
-static unsigned int logsys_subsys_id __attribute__((unused));          \
 __attribute__ ((constructor)) static void logsys_subsys_init (void)    \
 {                                                                      \
        logsys_subsys_id =                                              \
@@ -188,6 +189,7 @@
 }
 
 #define log_printf(lvl, format, args...) do {                          \
+       assert (logsys_subsys_id != -1);                                \
        if ((lvl) <= logsys_loggers[logsys_subsys_id].priority) {       \
                _logsys_log_printf2 (__FILE__, __LINE__, lvl,           \
                        logsys_subsys_id, (format), ##args);            \
@@ -195,6 +197,7 @@
 } while(0)
 
 #define dprintf(format, args...) do {                                  \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_log_printf2 (__FILE__, __LINE__, LOG_DEBUG,     \
                        logsys_subsys_id, (format), ##args);            \
@@ -202,6 +205,7 @@
 } while(0)
 
 #define ENTER_VOID() do {                                              \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_ENTER,    \
                        logsys_subsys_id, ">%s\n", __FUNCTION__);       \
@@ -209,6 +213,7 @@
 } while(0)
 
 #define ENTER(format, args...) do {                                    \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_ENTER,    \
                        logsys_subsys_id, ">%s: " format, __FUNCTION__, \
@@ -217,6 +222,7 @@
 } while(0)
 
 #define LEAVE_VOID() do {                                              \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_LEAVE,    \
                        logsys_subsys_id, "<%s\n", __FUNCTION__);       \
@@ -224,6 +230,7 @@
 } while(0)
 
 #define LEAVE(format, args...) do {                                    \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_LEAVE,    \
                        logsys_subsys_id, "<%s: " format,               \
@@ -232,6 +239,7 @@
 } while(0)
 
 #define TRACE1(format, args...) do {                                   \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE1,   \
                        logsys_subsys_id, (format), ##args);            \
@@ -239,6 +247,7 @@
 } while(0)
 
 #define TRACE2(format, args...) do {                                   \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE2,   \
                        logsys_subsys_id, (format), ##args);            \
@@ -246,6 +255,7 @@
 } while(0)
 
 #define TRACE3(format, args...) do { \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE3,   \
                        logsys_subsys_id, (format), ##args);            \
@@ -253,6 +263,7 @@
 } while(0)
 
 #define TRACE4(format, args...) do { \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE4,   \
                        logsys_subsys_id, (format), ##args);            \
@@ -260,6 +271,7 @@
 } while(0)
 
 #define TRACE5(format, args...) do {                                   \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE5,   \
                logsys_subsys_id, (format), ##args);                    \
@@ -267,6 +279,7 @@
 } while(0)
 
 #define TRACE6(format, args...) do {                                   \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE6,   \
                        logsys_subsys_id, (format), ##args);            \
@@ -274,6 +287,7 @@
 } while(0)
 
 #define TRACE7(format, args...) do {                                   \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
                _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE7,   \
                         logsys_subsys_id, (format), ##args);           \
@@ -281,6 +295,7 @@
 } while(0)
 
 #define TRACE8(format, args...) do {                                   \
+       assert (logsys_subsys_id != -1);                                \
        if (LOG_LEVEL_DEBUG <= logsys_loggers[logsys_subsys_id].priority) { \
        _logsys_trace (__FILE__, __LINE__, LOGSYS_TAG_TRACE8,           \
         logsys_subsys_id, (format), ##args);                           \
@@ -293,4 +308,10 @@
        _logsys_config_priority_set (logsys_subsys_id, priority);       \
 } while(0)
 
+/* simple, function-based api */
+
+int logsys_init (char *name, int mode, int facility, int priority, char *file);
+int logsys_conf (char *name, int mode, int facility, int priority, char *file);
+void logsys_exit (void);
+
 #endif /* LOGSYS_H_DEFINED */
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to