diff options
author | John Crispin <john@phrozen.org> | 2023-11-28 10:13:49 +0300 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2023-11-28 14:08:42 +0300 |
commit | 260ad5bd1566ce08753df743292680afa74bd06f (patch) | |
tree | ccac6e54b56d61ac167c81072be5d3687392bcc1 | |
parent | b77f2a4ce9034d4341668bb61ca55fc177ee7729 (diff) |
udebug: add ulog support
Make ulog able to also log via udebug.
Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r-- | ulog.c | 14 | ||||
-rw-r--r-- | ulog.h | 3 |
2 files changed, 17 insertions, 0 deletions
@@ -29,6 +29,7 @@ static int _ulog_facility = -1; static int _ulog_threshold = LOG_DEBUG; static int _ulog_initialized = 0; static const char *_ulog_ident = NULL; +static struct udebug_buf *udb = NULL; static const char *ulog_default_ident(void) { @@ -120,6 +121,11 @@ static void ulog_syslog(int priority, const char *fmt, va_list ap) vsyslog(priority, fmt, ap); } +void ulog_udebug(struct udebug_buf *_udb) +{ + udb = _udb; +} + void ulog_open(int channels, int facility, const char *ident) { ulog_close(); @@ -149,6 +155,14 @@ void ulog(int priority, const char *fmt, ...) { va_list ap; + if (udb) { + va_start(ap, fmt); + udebug_entry_init(udb); + udebug_entry_vprintf(udb, fmt, ap); + udebug_entry_add(udb); + va_end(ap); + } + if (priority > _ulog_threshold) return; @@ -21,6 +21,8 @@ #include <syslog.h> +#include "udebug.h" + enum { ULOG_KMSG = (1 << 0), ULOG_SYSLOG = (1 << 1), @@ -28,6 +30,7 @@ enum { }; void ulog_open(int channels, int facility, const char *ident); +void ulog_udebug(struct udebug_buf *udb); void ulog_close(void); void ulog_threshold(int threshold); |