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

#include "common.h"
#include "setup.h"

void log(int level, const char * fmt, ...)
{
	char tmpstr[BUFSIZ];
	char timestr[16];
	va_list ap;
	time_t now;
	struct tm local;

	va_start(ap, fmt);

	if (PvrSetup.LogLevel >= level)
	{
		time(&now);
		localtime_r(&now, &local);
		vsnprintf(tmpstr, sizeof(tmpstr), fmt, ap);
		strftime(timestr, sizeof(timestr), "%H:%M:%S", &local);
		printf("pvrinput: %s %s\n", timestr, tmpstr);
	}
	va_end(ap);
}
