#include "log.h"

namespace Log
{
	bool isLogging = false;
	bool verbose = false;
	std::string logName;
	std::ofstream logFile;
};

void Log::Init(const char* fname)
{
	if (isLogging) return;
	isLogging = true;
	remove(fname);
	logName = fname;
	logFile.open(fname);
};
void Log::EnableVerbose()
{
	verbose = true;
}
void Log::Write(const std::string& s)
{
	if (!isLogging) return;
	logFile << s << std::endl;
};
void Log::Write(const char* s, ...)
{
	if (!isLogging) return;
	va_list lst;
	va_start(lst, s);
	char buffer[2048];
	vsprintf(buffer, s, lst);
	logFile << buffer;
	logFile << std::endl;
};
void Log::Writen(const std::string& s)
{
	if (!isLogging) return;
	logFile << s;
};
void Log::Writen(const char* s, ...)
{
	if (!isLogging) return;
	va_list lst;
	va_start(lst, s);
	char buffer[2048];
	vsprintf(buffer, s, lst);
	logFile << buffer;
};
void Log::WriteVerbose(const std::string& s)
{
	if (!isLogging || !verbose) return;
	logFile << s << std::endl;
};
void Log::WriteVerbose(const char* s, ...)
{
	if (!isLogging || !verbose) return;
	va_list lst;
	va_start(lst, s);
	char buffer[2048];
	vsprintf(buffer, s, lst);
	logFile << buffer;
	logFile << std::endl;
};
void Log::WriteVerbosen(const std::string& s)
{
	if (!isLogging || !verbose) return;
	logFile << s;
};
void Log::WriteVerbosen(const char* s, ...)
{
	if (!isLogging || !verbose) return;
	va_list lst;
	va_start(lst, s);
	char buffer[2048];
	vsprintf(buffer, s, lst);
	logFile << buffer;
};

