Added code for logging
This commit is contained in:
parent
20431090ea
commit
ae0d0a0671
42
ogl_editor/src/rlog.c
Normal file
42
ogl_editor/src/rlog.c
Normal 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
14
ogl_editor/src/rlog.h
Normal 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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user