show log in game
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
#include "Log.h"
|
||||
#include "bx/handlealloc.h"
|
||||
#include "bx/hash.h"
|
||||
#include "bx/timer.h"
|
||||
#include <bx/string.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include "Windows.h"
|
||||
|
||||
#include "Instance.h"
|
||||
|
||||
#define ESC "\x1B["
|
||||
#define YELLOW ESC "33m"
|
||||
#define RED ESC "31m"
|
||||
@@ -12,9 +15,11 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
char LineBuffer[1024]{0};
|
||||
char OutBuffer[1024]{0};
|
||||
char LineBuffer[LogInternal::MaxLineSize]{0};
|
||||
char OutBuffer[LogInternal::MaxLineSize]{0};
|
||||
bx::HandleHashMapT<1024> OnceMap;
|
||||
LogHistory History;
|
||||
|
||||
constexpr char LogFormat[]{"%s\n"};
|
||||
constexpr char WarnFormat[]{YELLOW "%s" END "\n"};
|
||||
constexpr char ErrorFormat[]{RED "%s" END "\n"};
|
||||
@@ -33,6 +38,11 @@ void Log(ELogType logType, const char* file, uint32_t line, const char* format,
|
||||
bx::vsnprintf(OutBuffer, sizeof(OutBuffer), LineBuffer, args);
|
||||
va_end(args);
|
||||
OutputDebugStringA(OutBuffer);
|
||||
|
||||
bx::strCopy(&History.LogBuffer[History.WriteIdx * LogInternal::MaxLineSize], LogInternal::MaxLineSize, OutBuffer);
|
||||
History.WriteTime[History.WriteIdx] = bx::getHPCounter();
|
||||
++History.WriteIdx;
|
||||
if (History.WriteIdx >= LogInternal::LogHistorySize) History.WriteIdx = 0;
|
||||
}
|
||||
|
||||
bool WasLogged(ELogType logType, const char* file, uint32_t line, const char* format)
|
||||
@@ -48,3 +58,8 @@ bool WasLogged(ELogType logType, const char* file, uint32_t line, const char* fo
|
||||
OnceMap.insert(hash, {});
|
||||
return false;
|
||||
}
|
||||
|
||||
LogHistory& GetLogHistory()
|
||||
{
|
||||
return History;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user