diff options
Diffstat (limited to 'src/serd_validate.c')
-rw-r--r-- | src/serd_validate.c | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/src/serd_validate.c b/src/serd_validate.c index f84344b1..168b9f03 100644 --- a/src/serd_validate.c +++ b/src/serd_validate.c @@ -45,14 +45,16 @@ #define CERRORF(fmt, ...) fprintf(stderr, "serd_validate: " fmt, __VA_ARGS__); #define VERRORF(model, statement, fmt, ...) \ - report(model, statement, "error", fmt, __VA_ARGS__); + report(model, statement, SERD_LOG_LEVEL_ERROR, fmt, __VA_ARGS__); -#define VERROR(model, statement, fmt) report(model, statement, "error", fmt); +#define VERROR(model, statement, fmt) \ + report(model, statement, SERD_LOG_LEVEL_ERROR, fmt); #define VNOTEF(model, statement, fmt, ...) \ - report(model, statement, "note", fmt, __VA_ARGS__); + report(model, statement, SERD_LOG_LEVEL_INFO, fmt, __VA_ARGS__); -#define VNOTE(model, statement, fmt) report(model, statement, "note", fmt); +#define VNOTE(model, statement, fmt) \ + report(model, statement, SERD_LOG_LEVEL_INFO, fmt); #define SERD_FOREACH(name, range) \ for (const SerdStatement* name = NULL; \ @@ -155,29 +157,43 @@ absolute_path(const char* path) #endif } +/* static const char* level_strings[] = { "note", "warning", "error" }; */ + static int report(const SerdModel* model, const SerdStatement* statement, - const char* type, + const SerdLogLevel level, const char* fmt, ...) { va_list args; va_start(args, fmt); - - serd_world_errorf(model->world, SERD_ERR_INVALID, "%s: ", type); - - const SerdCursor* cursor = serd_statement_get_cursor(statement); - if (cursor) { - fprintf(stderr, - "%s:%u:%u: ", - serd_node_get_string(serd_cursor_get_name(cursor)), - serd_cursor_get_line(cursor), - serd_cursor_get_column(cursor)); - } - - vfprintf(stderr, fmt, args); + const SerdMessage msg = { SERD_ERR_INVALID, + level, + serd_statement_get_cursor(statement), + fmt, + &args }; + serd_world_error(model->world, &msg); va_end(args); + /* return st; */ + + /* va_list args; */ + /* va_start(args, fmt); */ + + /* serd_world_errorf( */ + /* model->world, SERD_ERR_INVALID, "%s: ", level_strings[level]); */ + + /* const SerdCursor* cursor = serd_statement_get_cursor(statement); */ + /* if (cursor) { */ + /* fprintf(stderr, */ + /* "%s:%u:%u: ", */ + /* serd_node_get_string(serd_cursor_get_name(cursor)), */ + /* serd_cursor_get_line(cursor), */ + /* serd_cursor_get_column(cursor)); */ + /* } */ + + /* vfprintf(stderr, fmt, args); */ + /* va_end(args); */ ++n_errors; return 1; |