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

#include "utils.h"

#include "trace.h"

static char* levels[]={
	"Normal",
	"Error",
	"Warning",
	"Notice",
	"!Trace",
	NULL
};

int
sx_trace(int level, char* file, char* function, int line, char* format,...)
{ 
	va_list ap;
	char buffer[8192], sbuf[4096];

	va_start(ap,format);
	vsnprintf(sbuf,sizeof(sbuf),format,ap);
	va_end(ap);

	if(level<=0 || level>(sizeof(levels)/sizeof(char*))) level=0;
 
	snprintf(buffer,sizeof(buffer),"%s %s (%s:%i) %s\n", levels[level],
		function,file,line,sbuf);

	return printf("%s", buffer);

};
