mirror of https://github.com/AxioDL/logvisor.git
Merge branch 'master' of https://github.com/RetroView/LogVisor
This commit is contained in:
commit
834e089885
|
@ -10,7 +10,7 @@
|
||||||
namespace LogVisor
|
namespace LogVisor
|
||||||
{
|
{
|
||||||
|
|
||||||
#if WIN32 && UNICODE
|
#if _WIN32 && UNICODE
|
||||||
#define LOG_UCS2 1
|
#define LOG_UCS2 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -19,10 +19,10 @@ namespace LogVisor
|
||||||
*/
|
*/
|
||||||
enum Level
|
enum Level
|
||||||
{
|
{
|
||||||
INFO, /**< Non-error informative message */
|
Info, /**< Non-error informative message */
|
||||||
WARNING, /**< Non-error warning message */
|
Warning, /**< Non-error warning message */
|
||||||
ERROR, /**< Recoverable error message */
|
Error, /**< Recoverable error message */
|
||||||
FATAL_ERROR /**< Non-recoverable error message (calls abort) */
|
FatalError /**< Non-recoverable error message (calls abort) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,7 +114,7 @@ public:
|
||||||
for (auto& logger : MainLoggers)
|
for (auto& logger : MainLoggers)
|
||||||
logger->report(m_modName, severity, format, ap);
|
logger->report(m_modName, severity, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
if (severity == FATAL_ERROR)
|
if (severity == FatalError)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
#define _WIN32_LEAN_AND_MEAN 1
|
#define _WIN32_LEAN_AND_MEAN 1
|
||||||
#include <Windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
@ -29,14 +29,14 @@ void RegisterThreadName(const char* name)
|
||||||
pthread_setname_np(name);
|
pthread_setname_np(name);
|
||||||
#elif __linux__
|
#elif __linux__
|
||||||
pthread_setname_np(pthread_self(), name);
|
pthread_setname_np(pthread_self(), name);
|
||||||
#elif _WIN32
|
#elif _MSC_VER
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
DWORD dwType; // Must be 0x1000.
|
DWORD dwType; // Must be 0x1000.
|
||||||
LPCSTR szName; // Pointer to name (in user addr space).
|
LPCSTR szName; // Pointer to name (in user addr space).
|
||||||
DWORD dwThreadID; // Thread ID (-1=caller thread).
|
DWORD dwThreadID; // Thread ID (-1=caller thread).
|
||||||
DWORD dwFlags; // Reserved for future use, must be zero.
|
DWORD dwFlags; // Reserved for future use, must be zero.
|
||||||
} info = {0x1000, name, -1, 0};
|
} info = {0x1000, name, (DWORD)-1, 0};
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
RaiseException(0x406D1388, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info);
|
RaiseException(0x406D1388, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info);
|
||||||
|
@ -96,19 +96,19 @@ struct ConsoleLogger : public ILogger
|
||||||
fprintf(stderr, "[");
|
fprintf(stderr, "[");
|
||||||
switch (severity)
|
switch (severity)
|
||||||
{
|
{
|
||||||
case INFO:
|
case Info:
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
|
||||||
fprintf(stderr, "INFO");
|
fprintf(stderr, "INFO");
|
||||||
break;
|
break;
|
||||||
case WARNING:
|
case Warning:
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
|
||||||
fprintf(stderr, "WARNING");
|
fprintf(stderr, "WARNING");
|
||||||
break;
|
break;
|
||||||
case ERROR:
|
case Error:
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED);
|
||||||
fprintf(stderr, "ERROR");
|
fprintf(stderr, "ERROR");
|
||||||
break;
|
break;
|
||||||
case FATAL_ERROR:
|
case FatalError:
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED);
|
||||||
fprintf(stderr, "FATAL ERROR");
|
fprintf(stderr, "FATAL ERROR");
|
||||||
break;
|
break;
|
||||||
|
@ -122,7 +122,7 @@ struct ConsoleLogger : public ILogger
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
|
||||||
fprintf(stderr, " %5.4f", tmd);
|
fprintf(stderr, " %5.4f", tmd);
|
||||||
if (FrameIndex)
|
if (FrameIndex)
|
||||||
fprintf(fp, " (%llu)", FrameIndex);
|
fprintf(stderr, " (%llu)", FrameIndex);
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY);
|
||||||
fprintf(stderr, "] ");
|
fprintf(stderr, "] ");
|
||||||
SetConsoleTextAttribute(Term, 0);
|
SetConsoleTextAttribute(Term, 0);
|
||||||
|
@ -238,16 +238,16 @@ struct FileLogger : public ILogger
|
||||||
fprintf(fp, "[");
|
fprintf(fp, "[");
|
||||||
switch (severity)
|
switch (severity)
|
||||||
{
|
{
|
||||||
case INFO:
|
case Info:
|
||||||
fprintf(fp, "INFO");
|
fprintf(fp, "INFO");
|
||||||
break;
|
break;
|
||||||
case WARNING:
|
case Warning:
|
||||||
fprintf(fp, "WARNING");
|
fprintf(fp, "WARNING");
|
||||||
break;
|
break;
|
||||||
case ERROR:
|
case Error:
|
||||||
fprintf(fp, "ERROR");
|
fprintf(fp, "ERROR");
|
||||||
break;
|
break;
|
||||||
case FATAL_ERROR:
|
case FatalError:
|
||||||
fprintf(fp, "FATAL ERROR");
|
fprintf(fp, "FATAL ERROR");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue