From a08759985ce25cda9b340a85eef30f572a8ceacc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 26 Nov 2018 22:14:39 +0100 Subject: Add extensible logging API --- src/world.h | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'src/world.h') diff --git a/src/world.h b/src/world.h index 11f36e21..7328afe3 100644 --- a/src/world.h +++ b/src/world.h @@ -19,13 +19,14 @@ #include "serd/serd.h" +#include #include #include struct SerdWorldImpl { SerdNodes* nodes; - SerdErrorSink error_sink; - void* error_handle; + SerdLogFunc log_func; + void* log_handle; SerdNode* blank_node; const SerdNode* rdf_first; const SerdNode* rdf_nil; @@ -39,9 +40,33 @@ struct SerdWorldImpl { FILE* serd_world_fopen(SerdWorld* world, const char* path, const char* mode); -SerdStatus serd_world_error(const SerdWorld* world, const SerdError* e); +/// Write a message to the log +SERD_API +SERD_LOG_FUNC(5, 0) +SerdStatus +serd_world_vlogf_internal(const SerdWorld* world, + SerdStatus st, + SerdLogLevel level, + const SerdCursor* cursor, + const char* fmt, + va_list args); +/// Write a message to the log +SERD_API +SERD_LOG_FUNC(5, 6) SerdStatus -serd_world_errorf(const SerdWorld* world, SerdStatus st, const char* fmt, ...); +serd_world_logf_internal(const SerdWorld* world, + SerdStatus st, + SerdLogLevel level, + const SerdCursor* cursor, + const char* fmt, + ...); + +#define SERD_LOG_ERRORF(world, st, fmt, ...) \ + serd_world_logf_internal( \ + world, st, SERD_LOG_LEVEL_ERR, NULL, fmt, __VA_ARGS__) + +#define SERD_LOG_ERROR(world, st, msg) \ + serd_world_logf_internal(world, st, SERD_LOG_LEVEL_ERR, NULL, msg) #endif // SERD_WORLD_H -- cgit v1.2.1