aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-01-13 20:00:25 +0100
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commit456bdeef35ffbfbdad7609e8b8a4ef71372786fd (patch)
tree25fabaa4f361f66a2bac860f06722e7f51776cbc /src/world.c
parentfc2114a10769349d38b3215bc95ded855a2be5b6 (diff)
downloadserd-456bdeef35ffbfbdad7609e8b8a4ef71372786fd.tar.gz
serd-456bdeef35ffbfbdad7609e8b8a4ef71372786fd.tar.bz2
serd-456bdeef35ffbfbdad7609e8b8a4ef71372786fd.zip
[WIP] Add extensible logging API
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c66
1 files changed, 5 insertions, 61 deletions
diff --git a/src/world.c b/src/world.c
index 9f10de49..f5ab2f19 100644
--- a/src/world.c
+++ b/src/world.c
@@ -3,68 +3,19 @@
#include "world.h"
-#include "caret.h"
+#include "log.h"
#include "node.h"
#include "serd/node.h"
-
+#include "serd/status.h"
#include "serd/string_view.h"
+#include "serd/world.h"
#include <assert.h>
-#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-SerdStatus
-serd_world_error(const SerdWorld* const world, const SerdError* const e)
-{
- if (world->error_func) {
- world->error_func(world->error_handle, e);
- } else {
- fprintf(stderr, "error: ");
- if (e->caret) {
- fprintf(stderr,
- "%s:%u:%u: ",
- serd_node_string(e->caret->document),
- e->caret->line,
- e->caret->col);
- }
- vfprintf(stderr, e->fmt, *e->args);
- fprintf(stderr, "\n");
- }
- return e->status;
-}
-
-SerdStatus
-serd_world_verrorf(const SerdWorld* const world,
- const SerdStatus st,
- const char* const fmt,
- va_list args)
-{
- va_list args_copy;
- va_copy(args_copy, args);
-
- const SerdError e = {st, NULL, fmt, &args_copy};
- serd_world_error(world, &e);
- va_end(args_copy);
- return st;
-}
-
-SerdStatus
-serd_world_errorf(const SerdWorld* const world,
- const SerdStatus st,
- const char* const fmt,
- ...)
-{
- va_list args; // NOLINT(cppcoreguidelines-init-variables)
- va_start(args, fmt);
- const SerdError e = {st, NULL, fmt, &args};
- serd_world_error(world, &e);
- va_end(args);
- return st;
-}
-
SerdWorld*
serd_world_new(void)
{
@@ -81,6 +32,8 @@ serd_world_new(void)
world->limits.writer_max_depth = 128U;
world->blank_node = blank_node;
+ serd_log_init(&world->log);
+
return world;
}
@@ -125,12 +78,3 @@ serd_world_get_blank(SerdWorld* const world)
#undef BLANK_CHARS
}
-
-void
-serd_world_set_error_func(SerdWorld* world,
- SerdLogFunc error_func,
- void* handle)
-{
- world->error_func = error_func;
- world->error_handle = handle;
-}