aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail/implementation.c
diff options
context:
space:
mode:
Diffstat (limited to 'pugl/detail/implementation.c')
-rw-r--r--pugl/detail/implementation.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c
index 7764bbd..9d3d6b4 100644
--- a/pugl/detail/implementation.c
+++ b/pugl/detail/implementation.c
@@ -22,9 +22,34 @@
#include "pugl/pugl.h"
#include <stdbool.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+static const char*
+puglLogLevelPrefix(const PuglLogLevel level)
+{
+ switch (level) {
+ case PUGL_LOG_LEVEL_ERR:
+ return "error: ";
+ case PUGL_LOG_LEVEL_WARNING:
+ return "warning: ";
+ case PUGL_LOG_LEVEL_INFO:
+ case PUGL_LOG_LEVEL_DEBUG:
+ return "";
+ }
+
+ return "";
+}
+
+static void
+puglDefaultLogFunc(PuglWorld* PUGL_UNUSED(world),
+ PuglLogLevel level,
+ const char* msg)
+{
+ fprintf(stderr, "%s%s", puglLogLevelPrefix(level), msg);
+}
+
const char*
puglStrerror(const PuglStatus status)
{
@@ -98,6 +123,9 @@ puglNewWorld(void)
}
world->startTime = puglGetTime(world);
+ world->logFunc = puglDefaultLogFunc;
+ world->logLevel = PUGL_LOG_LEVEL_INFO;
+
puglSetString(&world->className, "Pugl");
return world;
@@ -125,6 +153,22 @@ puglGetWorldHandle(PuglWorld* world)
}
PuglStatus
+puglSetLogFunc(PuglWorld* world, PuglLogFunc logFunc)
+{
+ world->logFunc = logFunc;
+
+ return PUGL_SUCCESS;
+}
+
+PuglStatus
+puglSetLogLevel(PuglWorld* world, PuglLogLevel level)
+{
+ world->logLevel = level;
+
+ return PUGL_SUCCESS;
+}
+
+PuglStatus
puglSetClassName(PuglWorld* const world, const char* const name)
{
puglSetString(&world->className, name);