rework log handling
- make logging events more structured - add fine grained control over log events - make it possible to receive more detailed events via ubus Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
10
main.c
10
main.c
@@ -22,6 +22,7 @@
|
||||
#include <syslog.h>
|
||||
|
||||
#include "usteer.h"
|
||||
#include "event.h"
|
||||
|
||||
struct ubus_context *ubus_ctx;
|
||||
struct usteer_config config = {};
|
||||
@@ -35,6 +36,14 @@ const char * const event_types[__EVENT_TYPE_MAX] = {
|
||||
[EVENT_TYPE_ASSOC] = "assoc",
|
||||
};
|
||||
|
||||
void log_msg(char *msg)
|
||||
{
|
||||
if (config.syslog)
|
||||
syslog(LOG_INFO, "%s\n", msg);
|
||||
else
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
}
|
||||
|
||||
void debug_msg(int level, const char *func, int line, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -143,6 +152,7 @@ int main(int argc, char **argv)
|
||||
|
||||
openlog("usteer", 0, LOG_USER);
|
||||
|
||||
config_set_event_log_types(NULL);
|
||||
usteer_update_time();
|
||||
uloop_init();
|
||||
|
||||
|
Reference in New Issue
Block a user