diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/reader.c | 10 | ||||
-rw-r--r-- | src/serdi.c | 14 | ||||
-rw-r--r-- | src/validate.c | 11 | ||||
-rw-r--r-- | src/world.c | 29 |
4 files changed, 40 insertions, 24 deletions
diff --git a/src/reader.c b/src/reader.c index 50784ffc..bf871940 100644 --- a/src/reader.c +++ b/src/reader.c @@ -39,10 +39,12 @@ r_err(SerdReader* reader, SerdStatus st, const char* fmt, ...) { va_list args; va_start(args, fmt); - const SerdMessage msg = { - st, SERD_LOG_LEVEL_ERROR, &reader->source.cur, fmt, &args - }; - serd_world_log(reader->world, &msg); + serd_world_vlogf(reader->world, + st, + SERD_LOG_LEVEL_ERROR, + &reader->source.cur, + fmt, + args); va_end(args); return st; } diff --git a/src/serdi.c b/src/serdi.c index 147a68c9..601824af 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -25,6 +25,7 @@ #endif #include <limits.h> +#include <stdarg.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -79,10 +80,19 @@ missing_arg(const char* name, char opt) } static SerdStatus -quiet_error_sink(void* handle, const SerdMessage* msg) +quiet_error_sink(void* handle, + SerdStatus status, + SerdLogLevel level, + const SerdCursor* cursor, + const char* fmt, + va_list args) { (void)handle; - (void)msg; + (void)status; + (void)level; + (void)cursor; + (void)fmt; + (void)args; return SERD_SUCCESS; } diff --git a/src/validate.c b/src/validate.c index a52f92b0..279ca117 100644 --- a/src/validate.c +++ b/src/validate.c @@ -125,12 +125,11 @@ report(ValidationContext* ctx, { va_list args; va_start(args, fmt); - const SerdMessage msg = { SERD_ERR_INVALID, - level, - serd_statement_get_cursor(statement), - fmt, - &args }; - serd_world_log(ctx->model->world, &msg); + serd_world_vlogf(ctx->model->world, SERD_ERR_INVALID, + level, + serd_statement_get_cursor(statement), + fmt, + args); va_end(args); ++ctx->n_errors; diff --git a/src/world.c b/src/world.c index f16b0f95..be4be551 100644 --- a/src/world.c +++ b/src/world.c @@ -51,24 +51,30 @@ serd_world_fopen(SerdWorld* world, const char* path, const char* mode) } SerdStatus -serd_world_log(const SerdWorld* world, const SerdMessage* msg) +serd_world_vlogf(const SerdWorld* world, + SerdStatus st, + SerdLogLevel level, + const SerdCursor* cursor, + const char* fmt, + va_list args) { - static const char* level_strings[] = { "note", "warning", "error" }; + static const char* const level_strings[] = { "note", "warning", "error" }; if (world->msg_func) { - world->msg_func(world->msg_handle, msg); + world->msg_func(world->msg_handle, st, level, cursor, fmt, args); } else { - fprintf(stderr, "%s: ", level_strings[msg->level]); - if (msg->cursor) { + fprintf(stderr, "%s: ", level_strings[level]); + if (cursor) { fprintf(stderr, "%s:%u:%u: ", - serd_node_get_string(msg->cursor->file), - msg->cursor->line, - msg->cursor->col); + serd_node_get_string(cursor->file), + cursor->line, + cursor->col); } - vfprintf(stderr, msg->fmt, *msg->args); + vfprintf(stderr, fmt, args); } - return msg->status; + + return st; } SerdStatus @@ -81,8 +87,7 @@ serd_world_logf(const SerdWorld* world, { va_list args; va_start(args, fmt); - const SerdMessage msg = {st, level, cursor, fmt, &args}; - serd_world_log(world, &msg); + serd_world_vlogf(world, st, level, cursor, fmt, args); va_end(args); return st; } |