X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=ulog.c;h=6c2c1f83b302cbb5f383e2d805dc9294061ac76f;hb=ca3f6d0cdb1e588283c42d039779ceab303ceef2;hp=b7300e720d21012ca60f96490cb24d91abd3efc5;hpb=8fc1c3053e1cdaa341a6009e18eced821f1eda3e;p=project%2Flibubox.git diff --git a/ulog.c b/ulog.c index b7300e7..6c2c1f8 100644 --- a/ulog.c +++ b/ulog.c @@ -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) { @@ -87,6 +88,7 @@ static void ulog_defaults(void) _ulog_initialized = 1; } +__attribute__((format(printf, 2, 0))) static void ulog_kmsg(int priority, const char *fmt, va_list ap) { FILE *kmsg; @@ -102,6 +104,7 @@ static void ulog_kmsg(int priority, const char *fmt, va_list ap) } } +__attribute__((format(printf, 2, 0))) static void ulog_stdio(int priority, const char *fmt, va_list ap) { FILE *out = stderr; @@ -112,11 +115,17 @@ static void ulog_stdio(int priority, const char *fmt, va_list ap) vfprintf(out, fmt, ap); } +__attribute__((format(printf, 2, 0))) 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(); @@ -146,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;