Exemple #1
0
	void Log::Write(eLogType logType, const char * fmt, ...) {

		char buf[2048] = { 0 };
		va_list va_alist;

		va_start(va_alist, fmt);
		vsprintf_s(buf, fmt, va_alist);
		va_end(va_alist);

		GetConsole()->SetTextColor(logTypeToColorMap[logType]);

		char buff2[2048] = { 0 };
		sprintf_s(buff2, "%s %s\n", GetTimeFormatted().c_str(), buf);
		// Print to console
		printf(buff2);

#ifndef _DEBUG
		if (logType == LogTypeDebug) {
			return;
		}
#endif

		sprintf_s(buff2, "%s%s %s\n", GetTimeFormatted().c_str(), logTypeToFormatMap[logType].c_str(), buf);
		// Write to log file
		LogToFile(buff2);
	}
Exemple #2
0
void LogPrintf(int Level, const char *format, ...)
{
	va_list args;
	char buffer[2048];
	
	va_start(args, format);
	vsnprintf_s(buffer, 2047, 2047, format, args);
	va_end(args);
	
	if (log == NULL)
	{
		fopen_s(&log, "libm3.log", "w");
	}
	
	// Create log message
	std::string Log = StringFromFormat("%s %s", GetTimeFormatted().c_str(), buffer);
	fwrite(Log.c_str(), 1, strlen(Log.c_str()), log);
	fflush(log);
	LogConsole(Level, Log);
}