From ae0d0a0671826239ad3fd13687cede6ddf1f4633 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Fri, 26 Oct 2012 16:37:07 +0200 Subject: [PATCH] Added code for logging --- ogl_editor/src/rlog.c | 42 ++++++++++++++++++++++++++++++++++++++++++ ogl_editor/src/rlog.h | 14 ++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 ogl_editor/src/rlog.c create mode 100644 ogl_editor/src/rlog.h diff --git a/ogl_editor/src/rlog.c b/ogl_editor/src/rlog.c new file mode 100644 index 0000000..4e1d8e0 --- /dev/null +++ b/ogl_editor/src/rlog.c @@ -0,0 +1,42 @@ +#include "rlog.h" +#include +#include + +static int s_log_level = 0; +static int s_old_level = 0; + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void rlog(int logLevel, const char* format, ...) +{ + va_list ap; + + if (logLevel < s_log_level) + return; + + va_start(ap, format); + vprintf(format, ap); + va_end(ap); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void rlog_set_level(int logLevel) +{ + s_log_level = logLevel; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void rlog_level_push() +{ + s_old_level = s_log_level; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void rlog_level_pop() +{ + s_log_level = s_old_level; +} + diff --git a/ogl_editor/src/rlog.h b/ogl_editor/src/rlog.h new file mode 100644 index 0000000..2aa7874 --- /dev/null +++ b/ogl_editor/src/rlog.h @@ -0,0 +1,14 @@ +#pragma once + +enum +{ + R_DEBUG, + R_INFO, + R_ERROR, +}; + +void rlog(int logLevel, const char* format, ...); +void rlog_set_level(int logLevel); +void rlog_level_push(); +void rlog_level_pop(); +