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:
Felix Fietkau
2021-04-16 14:15:15 +02:00
parent 6d62833ca1
commit 2b1c740ce3
11 changed files with 529 additions and 161 deletions

10
main.c
View File

@@ -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();