diff options
author | David Robillard <d@drobilla.net> | 2018-11-26 22:14:39 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:58 +0100 |
commit | a08759985ce25cda9b340a85eef30f572a8ceacc (patch) | |
tree | ec3f979605792b69c4c2fc7895f5dc917af39e7e /src/world.h | |
parent | 704305ddadae5e8737cf775bcc7fb1db3e91a1ce (diff) | |
download | serd-a08759985ce25cda9b340a85eef30f572a8ceacc.tar.gz serd-a08759985ce25cda9b340a85eef30f572a8ceacc.tar.bz2 serd-a08759985ce25cda9b340a85eef30f572a8ceacc.zip |
Add extensible logging API
Diffstat (limited to 'src/world.h')
-rw-r--r-- | src/world.h | 33 |
1 files changed, 29 insertions, 4 deletions
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 <stdarg.h> #include <stdint.h> #include <stdio.h> 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 |