{
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 ();
+}
+
#include <stdarg.h>
#include <syslog.h>
+#include <assert.h>
/*
* MODE_OUTPUT_SYSLOG_* modes are mutually exclusive
} \
}
+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(); \
}
#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 = \
}
#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); \
} 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); \
} 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__); \
} 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__, \
} 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__); \
} 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, \
} 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); \
} 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); \
} 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); \
} 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); \
} 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); \
} 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); \
} 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); \
} 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); \
_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 */