#include "debug.h"

#include <stdio.h>
#include <stdarg.h>

static uint8_t debug_level = DEBUG_WARN;

void
DEBUG( uint8_t level, char* msg, ... )
{
	va_list ap;

	if( level < debug_level )
	{
		va_start(ap, msg);

		if( level > DEBUG_WARN )
		{
			vfprintf(stdout, msg, ap);
		} else
		{
			vfprintf(stderr, msg, ap);
		}
		va_end(ap);
	}
}

void
DEBUG_level( uint8_t level )
{
	if( level > DEBUG_FINE )
	{
		level = DEBUG_FINE;
	}
	
	debug_level = level;
}
