diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2019-08-06 17:37:51 +0300 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2019-08-19 12:40:42 +0300 |
commit | 843b238551be3fd4b770e9912a0e169491e5a419 (patch) | |
tree | 38c4309c250a13226d6ff4ad18aaafc106c0ce1e | |
parent | 670ac1c0edbc1a4e60f2fee2fcb1e39b57f853fc (diff) | |
download | weston-843b238551be3fd4b770e9912a0e169491e5a419.tar.gz |
weston-log: Return bytes written for 'printf()' and 'vprintf()' functions
Information is needed for 'vlog()' and 'vlog_continue()' (others
depend on them).
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
-rw-r--r-- | include/libweston/weston-log.h | 4 | ||||
-rw-r--r-- | libweston/weston-log.c | 15 |
2 files changed, 12 insertions, 7 deletions
diff --git a/include/libweston/weston-log.h b/include/libweston/weston-log.h index f896d224..50afbeb0 100644 --- a/include/libweston/weston-log.h +++ b/include/libweston/weston-log.h @@ -79,11 +79,11 @@ void weston_log_scope_write(struct weston_log_scope *scope, const char *data, size_t len); -void +int weston_log_scope_vprintf(struct weston_log_scope *scope, const char *fmt, va_list ap); -void +int weston_log_scope_printf(struct weston_log_scope *scope, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); diff --git a/libweston/weston-log.c b/libweston/weston-log.c index 30018bf5..3584462b 100644 --- a/libweston/weston-log.c +++ b/libweston/weston-log.c @@ -753,16 +753,16 @@ weston_log_scope_write(struct weston_log_scope *scope, * * \memberof weston_log_scope */ -WL_EXPORT void +WL_EXPORT int weston_log_scope_vprintf(struct weston_log_scope *scope, const char *fmt, va_list ap) { static const char oom[] = "Out of memory"; char *str; - int len; + int len = 0; if (!weston_log_scope_is_enabled(scope)) - return; + return len; len = vasprintf(&str, fmt, ap); if (len >= 0) { @@ -771,6 +771,8 @@ weston_log_scope_vprintf(struct weston_log_scope *scope, } else { weston_log_scope_write(scope, oom, sizeof oom - 1); } + + return len; } /** Write a formatted string for a scope @@ -786,15 +788,18 @@ weston_log_scope_vprintf(struct weston_log_scope *scope, * * \memberof weston_log_scope */ -WL_EXPORT void +WL_EXPORT int weston_log_scope_printf(struct weston_log_scope *scope, const char *fmt, ...) { va_list ap; + int len; va_start(ap, fmt); - weston_log_scope_vprintf(scope, fmt, ap); + len = weston_log_scope_vprintf(scope, fmt, ap); va_end(ap); + + return len; } /** Write a formatted string for a subscription |