Added code for logging

This commit is contained in:
Daniel Collin 2012-10-26 16:37:07 +02:00
parent 20431090ea
commit ae0d0a0671
2 changed files with 56 additions and 0 deletions

42
ogl_editor/src/rlog.c Normal file
View File

@ -0,0 +1,42 @@
#include "rlog.h"
#include <stdio.h>
#include <stdarg.h>
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;
}

14
ogl_editor/src/rlog.h Normal file
View File

@ -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();