aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-31 22:47:54 +0200
committerDavid Robillard <d@drobilla.net>2019-04-13 19:48:23 +0200
commitf19b3c02a317cb74f9410e026b7ec145c8be0bcb (patch)
tree58c5dcbe69cbdd1c87278401353f24d9a3967a7d
parente75d53733b9e016f1fe92d961daa40f74de933e9 (diff)
downloadserd-f19b3c02a317cb74f9410e026b7ec145c8be0bcb.tar.gz
serd-f19b3c02a317cb74f9410e026b7ec145c8be0bcb.tar.bz2
serd-f19b3c02a317cb74f9410e026b7ec145c8be0bcb.zip
WIP: log
-rw-r--r--src/iter.c6
-rw-r--r--src/model.c6
-rw-r--r--src/world.c17
-rw-r--r--src/world.h8
-rw-r--r--src/writer.c16
5 files changed, 22 insertions, 31 deletions
diff --git a/src/iter.c b/src/iter.c
index 87c9dfaf..e5687cd5 100644
--- a/src/iter.c
+++ b/src/iter.c
@@ -70,9 +70,9 @@ static bool
check_version(const SerdIter* const iter)
{
if (iter->version != iter->model->version) {
- serd_world_errorf(iter->model->world,
- SERD_ERR_BAD_ITER,
- "attempt to use invalidated iterator\n");
+ SERD_LOG_ERROR(iter->model->world,
+ SERD_ERR_BAD_ITER,
+ "attempt to use invalidated iterator\n");
return false;
}
return true;
diff --git a/src/model.c b/src/model.c
index 3de53c9f..47e412ac 100644
--- a/src/model.c
+++ b/src/model.c
@@ -572,9 +572,9 @@ serd_model_add(SerdModel* model,
const SerdNode* g)
{
if (!s || !p || !o) {
- return serd_world_errorf(model->world,
- SERD_ERR_BAD_ARG,
- "attempt to add statement with NULL field\n");
+ return SERD_LOG_ERROR(model->world,
+ SERD_ERR_BAD_ARG,
+ "attempt to add statement with NULL field\n");
}
return serd_model_add_internal(model,
diff --git a/src/world.c b/src/world.c
index 2437d83d..f16b0f95 100644
--- a/src/world.c
+++ b/src/world.c
@@ -39,9 +39,9 @@ serd_world_fopen(SerdWorld* world, const char* path, const char* mode)
{
FILE* fd = fopen(path, mode);
if (!fd) {
- serd_world_errorf(world, SERD_ERR_INTERNAL,
- "failed to open file %s (%s)\n",
- path, strerror(errno));
+ SERD_LOG_ERRORF(world, SERD_ERR_INTERNAL,
+ "failed to open file %s (%s)\n",
+ path, strerror(errno));
return NULL;
}
#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FILENO)
@@ -87,17 +87,6 @@ serd_world_logf(const SerdWorld* world,
return st;
}
-SerdStatus
-serd_world_errorf(const SerdWorld* world, SerdStatus st, const char* fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- const SerdMessage msg = { st, SERD_LOG_LEVEL_ERROR, NULL, fmt, &args };
- serd_world_log(world, &msg);
- va_end(args);
- return st;
-}
-
SerdWorld*
serd_world_new(void)
{
diff --git a/src/world.h b/src/world.h
index ef19fb7f..35c23763 100644
--- a/src/world.h
+++ b/src/world.h
@@ -39,8 +39,10 @@ struct SerdWorldImpl {
FILE* serd_world_fopen(SerdWorld* world, const char* path, const char* mode);
-SERD_LOG_FUNC(3, 4)
-SerdStatus
-serd_world_errorf(const SerdWorld* world, SerdStatus st, const char* fmt, ...);
+#define SERD_LOG_ERRORF(world, st, fmt, ...) \
+ serd_world_logf(world, st, SERD_LOG_LEVEL_ERROR, NULL, fmt, __VA_ARGS__);
+
+#define SERD_LOG_ERROR(world, st, msg) \
+ serd_world_logf(world, st, SERD_LOG_LEVEL_ERROR, NULL, msg);
#endif // SERD_WORLD_H
diff --git a/src/writer.c b/src/writer.c
index 685db34a..d183918e 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -192,8 +192,9 @@ write_character(SerdWriter* writer, const uint8_t* utf8, size_t* size)
const uint32_t c = parse_utf8_char(utf8, size);
switch (*size) {
case 0:
- serd_world_errorf(
- writer->world, SERD_ERR_BAD_ARG, "invalid UTF-8: %X\n", utf8[0]);
+ SERD_LOG_ERRORF(writer->world, SERD_ERR_BAD_ARG,
+ "invalid UTF-8: %X\n",
+ utf8[0]);
return sink(replacement_char, sizeof(replacement_char), writer);
case 1:
snprintf(escape, sizeof(escape), "\\u%04X", utf8[0]);
@@ -614,10 +615,9 @@ write_curie(SerdWriter* const writer,
case SERD_NQUADS:
if ((st = serd_env_expand_in_place(
writer->iface.env, node, &prefix, &suffix))) {
- serd_world_errorf(writer->world,
- st,
- "undefined namespace prefix `%s'\n",
- serd_node_get_string(node));
+ SERD_LOG_ERRORF(writer->world, st,
+ "undefined namespace prefix `%s'\n",
+ serd_node_get_string(node));
return false;
}
sink("<", 1, writer);
@@ -898,8 +898,8 @@ serd_writer_end_anon(SerdWriter* writer,
if (writer->syntax == SERD_NTRIPLES || writer->syntax == SERD_NQUADS) {
return SERD_SUCCESS;
} else if (serd_stack_is_empty(&writer->anon_stack)) {
- return serd_world_errorf(writer->world, SERD_ERR_UNKNOWN,
- "unexpected end of anonymous node\n");
+ return SERD_LOG_ERROR(writer->world, SERD_ERR_UNKNOWN,
+ "unexpected end of anonymous node\n");
}
write_sep(writer, writer->context.flags, SEP_ANON_END);