logvisor/lib/logvisor.cpp

613 lines
16 KiB
C++
Raw Normal View History

2015-07-03 22:08:41 +00:00
#if _WIN32
2015-08-31 03:31:31 +00:00
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
2015-09-27 04:33:36 +00:00
#ifndef NOMINMAX
#define NOMINMAX
#endif
2015-07-04 05:20:02 +00:00
#include <windows.h>
2015-11-05 00:02:40 +00:00
#include <io.h>
2018-01-10 06:14:40 +00:00
#include <DbgHelp.h>
#include <TlHelp32.h>
2018-10-07 02:56:33 +00:00
#elif defined(__SWITCH__)
#include <cstring>
#include "nxstl/thread"
#else
#include <sys/ioctl.h>
#include <unistd.h>
#include <dlfcn.h>
#include <cxxabi.h>
2017-12-29 07:53:09 +00:00
#include <cstring>
2018-06-02 00:01:11 +00:00
#if __linux__
#include <sys/prctl.h>
#endif
2015-07-03 22:08:41 +00:00
#endif
#include <fcntl.h>
2015-07-03 22:08:41 +00:00
#include <chrono>
#include <mutex>
#include <thread>
2016-09-19 01:32:20 +00:00
#include <string>
2015-07-03 22:08:41 +00:00
#include <unordered_map>
2017-12-29 07:53:09 +00:00
#include <cstdio>
#include <cinttypes>
#include <signal.h>
2016-03-04 20:11:37 +00:00
#include "logvisor/logvisor.hpp"
2015-07-03 22:08:41 +00:00
/* ANSI sequences */
2015-07-04 06:41:44 +00:00
#define RED "\x1b[1;31m"
#define YELLOW "\x1b[1;33m"
#define GREEN "\x1b[1;32m"
#define MAGENTA "\x1b[1;35m"
#define CYAN "\x1b[1;36m"
2015-07-03 22:08:41 +00:00
#define BOLD "\x1b[1m"
#define NORMAL "\x1b[0m"
2015-07-22 19:06:24 +00:00
#if _WIN32
2018-12-08 05:17:15 +00:00
#define FOREGROUND_WHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
2015-07-22 19:06:24 +00:00
#endif
2016-03-04 23:01:18 +00:00
void logvisorBp() {}
2015-11-26 07:32:50 +00:00
2018-12-08 05:17:15 +00:00
namespace logvisor {
static Module Log("logvisor");
2015-07-03 22:08:41 +00:00
static std::unordered_map<std::thread::id, const char*> ThreadMap;
2017-01-17 01:30:32 +00:00
2018-12-08 05:17:15 +00:00
static void AddThreadToMap(const char* name) {
auto lk = LockLog();
ThreadMap[std::this_thread::get_id()] = name;
2017-01-17 01:30:32 +00:00
}
2018-12-08 05:17:15 +00:00
void RegisterThreadName(const char* name) {
AddThreadToMap(name);
2015-07-03 22:08:41 +00:00
#if __APPLE__
2018-12-08 05:17:15 +00:00
pthread_setname_np(name);
2015-07-03 22:08:41 +00:00
#elif __linux__
2018-12-08 05:17:15 +00:00
prctl(PR_SET_NAME, name);
2015-07-04 05:20:02 +00:00
#elif _MSC_VER
2018-12-08 05:17:15 +00:00
struct {
DWORD dwType; // Must be 0x1000.
LPCSTR szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread).
DWORD dwFlags; // Reserved for future use, must be zero.
} info = {0x1000, name, (DWORD)-1, 0};
__try {
RaiseException(0x406D1388, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
} __except (EXCEPTION_EXECUTE_HANDLER) {}
2015-07-03 22:08:41 +00:00
#endif
}
#if _WIN32
#pragma comment(lib, "Dbghelp.lib")
2017-12-06 03:20:32 +00:00
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP
#define WINDOWS_STORE 1
#else
#define WINDOWS_STORE 0
#endif
2018-12-08 05:17:15 +00:00
void KillProcessTree() {
DWORD myprocID = GetCurrentProcessId();
PROCESSENTRY32 pe = {};
pe.dwSize = sizeof(PROCESSENTRY32);
HANDLE hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (::Process32First(hSnap, &pe)) {
BOOL bContinue = TRUE;
// kill child processes
while (bContinue) {
// only kill child processes
if (pe.th32ParentProcessID == myprocID) {
HANDLE hChildProc = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
if (hChildProc) {
::TerminateProcess(hChildProc, 1);
::CloseHandle(hChildProc);
2018-01-10 06:14:40 +00:00
}
2018-12-08 05:17:15 +00:00
}
bContinue = ::Process32Next(hSnap, &pe);
2018-01-10 06:14:40 +00:00
}
2018-12-08 05:17:15 +00:00
}
2018-01-10 06:14:40 +00:00
}
2018-12-08 05:17:15 +00:00
void logvisorAbort() {
2017-12-06 03:20:32 +00:00
#if !WINDOWS_STORE
2018-12-08 05:17:15 +00:00
unsigned int i;
void* stack[100];
unsigned short frames;
SYMBOL_INFO* symbol;
HANDLE process;
process = GetCurrentProcess();
SymInitialize(process, NULL, TRUE);
frames = CaptureStackBackTrace(0, 100, stack, NULL);
symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1);
symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
for (i = 0; i < frames; i++) {
SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol);
fprintf(stderr, "%i: %s - 0x%0llX", frames - i - 1, symbol->Name, symbol->Address);
DWORD dwDisplacement;
IMAGEHLP_LINE64 line;
SymSetOptions(SYMOPT_LOAD_LINES);
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
if (SymGetLineFromAddr64(process, (DWORD64)(stack[i]), &dwDisplacement, &line)) {
// SymGetLineFromAddr64 returned success
fprintf(stderr, " LINE %d\n", int(line.LineNumber));
} else {
fprintf(stderr, "\n");
}
2018-12-08 05:17:15 +00:00
}
2018-12-08 05:17:15 +00:00
fflush(stderr);
free(symbol);
2017-12-06 03:20:32 +00:00
#endif
2018-01-10 06:14:40 +00:00
2018-12-08 05:17:15 +00:00
KillProcessTree();
2018-01-10 06:14:40 +00:00
2018-12-08 05:17:15 +00:00
// If you caught one of the above signals, it is likely you just
// want to quit your program right now.
#ifndef NDEBUG
2018-12-08 05:17:15 +00:00
signal(SIGABRT, SIG_DFL);
abort();
#else
2018-12-08 05:17:15 +00:00
exit(1);
#endif
}
2018-10-07 02:56:33 +00:00
#elif defined(__SWITCH__)
2018-12-08 05:17:15 +00:00
void logvisorAbort() { exit(1); }
#else
2018-01-10 06:14:40 +00:00
void KillProcessTree() {}
#include <execinfo.h>
2018-12-08 05:17:15 +00:00
void logvisorAbort() {
void* array[128];
size_t size = backtrace(array, 128);
2018-12-08 05:17:15 +00:00
constexpr size_t exeBufSize = 1024 + 1;
char exeNameBuffer[exeBufSize] = {};
#if __linux__
2018-12-08 05:17:15 +00:00
readlink("/proc/self/exe", exeNameBuffer, exeBufSize);
#endif
2018-12-08 05:17:15 +00:00
char cmdLine[1024];
#if __APPLE__
2018-12-08 05:17:15 +00:00
snprintf(cmdLine, 1024, "atos -p %d", getpid());
#else
2018-12-08 05:17:15 +00:00
snprintf(cmdLine, 1024, "2>/dev/null addr2line -C -f -e \"%s\"", exeNameBuffer);
#endif
2018-12-08 05:17:15 +00:00
std::string cmdLineStr = cmdLine;
for (size_t i = 0; i < size; i++) {
2017-11-02 09:20:23 +00:00
#if __linux__
2018-12-08 05:17:15 +00:00
Dl_info dlip;
if (dladdr(array[i], &dlip))
snprintf(cmdLine, 128, " %p", (void*)((uint8_t*)array[i] - (uint8_t*)dlip.dli_fbase));
else
snprintf(cmdLine, 128, " %p", array[i]);
2017-11-02 09:20:23 +00:00
#else
2018-12-08 05:17:15 +00:00
snprintf(cmdLine, 128, " %p", array[i]);
2017-11-02 09:20:23 +00:00
#endif
2018-12-08 05:17:15 +00:00
cmdLineStr += cmdLine;
}
FILE* fp = popen(cmdLineStr.c_str(), "r");
if (fp) {
char readBuf[256];
size_t readSz;
while ((readSz = fread(readBuf, 1, 256, fp)))
fwrite(readBuf, 1, readSz, stderr);
pclose(fp);
} else {
for (size_t i = 0; i < size; i++) {
fprintf(stderr, "- ");
Dl_info dlip;
if (dladdr(array[i], &dlip)) {
int status;
char* demangledName = abi::__cxa_demangle(dlip.dli_sname, nullptr, nullptr, &status);
fprintf(stderr, "%p(%s+%p)\n", dlip.dli_saddr, demangledName ? demangledName : dlip.dli_sname,
(void*)((uint8_t*)array[i] - (uint8_t*)dlip.dli_fbase));
free(demangledName);
} else {
fprintf(stderr, "%p\n", array[i]);
}
}
2018-12-08 05:17:15 +00:00
}
2018-12-08 05:17:15 +00:00
fflush(stderr);
fflush(stdout);
KillProcessTree();
#ifndef NDEBUG
2018-12-08 05:17:15 +00:00
signal(SIGABRT, SIG_DFL);
abort();
#else
2018-12-08 05:17:15 +00:00
exit(1);
#endif
}
#endif
2017-01-18 20:54:00 +00:00
LogMutex _LogMutex;
2018-12-08 05:17:15 +00:00
static void AbortHandler(int signum) {
_LogMutex.enabled = false;
switch (signum) {
case SIGSEGV:
Log.report(logvisor::Fatal, "Segmentation Fault");
case SIGILL:
Log.report(logvisor::Fatal, "Bad Execution");
case SIGFPE:
Log.report(logvisor::Fatal, "Floating Point Exception");
case SIGABRT:
Log.report(logvisor::Fatal, "Abort Signal");
default:
Log.report(logvisor::Fatal, "unknown signal %d", signum);
}
}
2018-03-23 21:38:33 +00:00
uint64_t _LogCounter;
2015-07-03 22:08:41 +00:00
std::vector<std::unique_ptr<ILogger>> MainLoggers;
std::atomic_size_t ErrorCount(0);
2015-07-03 22:08:41 +00:00
static std::chrono::steady_clock MonoClock;
static std::chrono::steady_clock::time_point GlobalStart = MonoClock.now();
2018-12-08 05:17:15 +00:00
static inline std::chrono::steady_clock::duration CurrentUptime() { return MonoClock.now() - GlobalStart; }
2015-07-26 20:55:17 +00:00
std::atomic_uint_fast64_t FrameIndex(0);
2016-03-05 03:21:18 +00:00
2018-12-08 05:17:15 +00:00
static inline int ConsoleWidth() {
int retval = 80;
#if _WIN32
2017-12-06 03:20:32 +00:00
#if !WINDOWS_STORE
2018-12-08 05:17:15 +00:00
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
retval = info.dwSize.X - 1;
2017-12-06 03:20:32 +00:00
#endif
2018-10-07 02:56:33 +00:00
#elif defined(__SWITCH__)
2018-12-08 05:17:15 +00:00
return 80;
#else
2018-12-08 05:17:15 +00:00
struct winsize w;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1)
retval = w.ws_col;
#endif
2018-12-08 05:17:15 +00:00
if (retval < 10)
return 10;
return retval;
}
2015-07-03 22:08:41 +00:00
#if _WIN32
static HANDLE Term = 0;
#else
static const char* Term = nullptr;
#endif
2015-10-07 23:18:37 +00:00
bool XtermColor = false;
2018-12-08 05:17:15 +00:00
struct ConsoleLogger : public ILogger {
ConsoleLogger() {
2015-07-03 22:08:41 +00:00
#if _WIN32
2017-12-06 03:20:32 +00:00
#if !WINDOWS_STORE
2018-12-08 05:17:15 +00:00
const char* conemuANSI = getenv("ConEmuANSI");
if (conemuANSI && !strcmp(conemuANSI, "ON"))
XtermColor = true;
2017-12-06 03:20:32 +00:00
#endif
2018-12-08 05:17:15 +00:00
if (!Term)
Term = GetStdHandle(STD_ERROR_HANDLE);
2015-07-03 22:08:41 +00:00
#else
2018-12-08 05:17:15 +00:00
if (!Term) {
Term = getenv("TERM");
if (Term && !strncmp(Term, "xterm", 5)) {
XtermColor = true;
putenv((char*)"TERM=xterm-16color");
}
2015-07-03 22:08:41 +00:00
}
2018-12-08 05:17:15 +00:00
#endif
}
static void _reportHead(const char* modName, const char* sourceInfo, Level severity) {
/* Clear current line out */
int width = ConsoleWidth();
fprintf(stderr, "\r");
for (int w = 0; w < width; ++w)
fprintf(stderr, " ");
fprintf(stderr, "\r");
std::chrono::steady_clock::duration tm = CurrentUptime();
double tmd = tm.count() * std::chrono::steady_clock::duration::period::num /
(double)std::chrono::steady_clock::duration::period::den;
std::thread::id thrId = std::this_thread::get_id();
const char* thrName = nullptr;
if (ThreadMap.find(thrId) != ThreadMap.end())
thrName = ThreadMap[thrId];
if (XtermColor) {
fprintf(stderr, BOLD "[");
fprintf(stderr, GREEN "%5.4f ", tmd);
uint_fast64_t fIdx = FrameIndex.load();
if (fIdx)
fprintf(stderr, "(%" PRIu64 ") ", fIdx);
switch (severity) {
case Info:
fprintf(stderr, BOLD CYAN "INFO");
break;
case Warning:
fprintf(stderr, BOLD YELLOW "WARNING");
break;
case Error:
fprintf(stderr, RED BOLD "ERROR");
break;
case Fatal:
fprintf(stderr, BOLD RED "FATAL ERROR");
break;
default:
break;
};
fprintf(stderr, NORMAL BOLD " %s", modName);
if (sourceInfo)
fprintf(stderr, BOLD YELLOW " {%s}", sourceInfo);
if (thrName)
fprintf(stderr, BOLD MAGENTA " (%s)", thrName);
fprintf(stderr, NORMAL BOLD "] " NORMAL);
} else {
#if _WIN32
2017-12-06 03:20:32 +00:00
#if !WINDOWS_STORE
2018-12-08 05:17:15 +00:00
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
fprintf(stderr, "[");
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
fprintf(stderr, "%5.4f ", tmd);
uint64_t fi = FrameIndex.load();
if (fi)
fprintf(stderr, "(%" PRIu64 ") ", fi);
switch (severity) {
case Info:
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(stderr, "INFO");
break;
case Warning:
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
fprintf(stderr, "WARNING");
break;
case Error:
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED);
fprintf(stderr, "ERROR");
break;
case Fatal:
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED);
fprintf(stderr, "FATAL ERROR");
break;
default:
break;
};
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
fprintf(stderr, " %s", modName);
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
if (sourceInfo)
fprintf(stderr, " {%s}", sourceInfo);
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
if (thrName)
fprintf(stderr, " (%s)", thrName);
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
fprintf(stderr, "] ");
SetConsoleTextAttribute(Term, FOREGROUND_WHITE);
2017-12-06 03:20:32 +00:00
#endif
#else
2018-12-08 05:17:15 +00:00
fprintf(stderr, "[");
fprintf(stderr, "%5.4f ", tmd);
uint_fast64_t fIdx = FrameIndex.load();
if (fIdx)
fprintf(stderr, "(%" PRIu64 ") ", fIdx);
switch (severity) {
case Info:
fprintf(stderr, "INFO");
break;
case Warning:
fprintf(stderr, "WARNING");
break;
case Error:
fprintf(stderr, "ERROR");
break;
case Fatal:
fprintf(stderr, "FATAL ERROR");
break;
default:
break;
};
fprintf(stderr, " %s", modName);
if (sourceInfo)
fprintf(stderr, " {%s}", sourceInfo);
if (thrName)
fprintf(stderr, " (%s)", thrName);
fprintf(stderr, "] ");
2015-07-03 22:08:41 +00:00
#endif
2015-07-04 06:41:44 +00:00
}
2018-12-08 05:17:15 +00:00
}
2015-07-04 06:41:44 +00:00
2018-12-08 05:17:15 +00:00
void report(const char* modName, Level severity, const char* format, va_list ap) {
_reportHead(modName, nullptr, severity);
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
fflush(stderr);
}
2015-07-04 06:41:44 +00:00
2018-12-08 05:17:15 +00:00
void report(const char* modName, Level severity, const wchar_t* format, va_list ap) {
_reportHead(modName, nullptr, severity);
vfwprintf(stderr, format, ap);
fprintf(stderr, "\n");
fflush(stderr);
}
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, const char* format,
va_list ap) {
char sourceInfo[128];
snprintf(sourceInfo, 128, "%s:%u", file, linenum);
_reportHead(modName, sourceInfo, severity);
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
fflush(stderr);
}
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, const wchar_t* format,
va_list ap) {
char sourceInfo[128];
snprintf(sourceInfo, 128, "%s:%u", file, linenum);
_reportHead(modName, sourceInfo, severity);
vfwprintf(stderr, format, ap);
fprintf(stderr, "\n");
fflush(stderr);
}
2015-07-03 22:08:41 +00:00
};
2018-12-08 05:17:15 +00:00
void RegisterConsoleLogger() {
/* Otherwise construct new console logger */
MainLoggers.emplace_back(new ConsoleLogger);
2015-07-03 22:08:41 +00:00
}
2015-11-05 00:02:40 +00:00
#if _WIN32
2018-12-08 05:17:15 +00:00
void CreateWin32Console() {
2017-12-06 03:20:32 +00:00
#if !WINDOWS_STORE
2018-12-08 05:17:15 +00:00
/* Debug console */
AllocConsole();
2015-11-05 00:02:40 +00:00
2018-12-08 05:17:15 +00:00
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
2017-12-06 03:20:32 +00:00
#endif
2015-11-05 00:02:40 +00:00
}
#endif
2018-12-08 05:17:15 +00:00
void RegisterStandardExceptions() {
signal(SIGABRT, AbortHandler);
signal(SIGSEGV, AbortHandler);
signal(SIGILL, AbortHandler);
signal(SIGFPE, AbortHandler);
}
2018-12-08 05:17:15 +00:00
struct FileLogger : public ILogger {
FILE* fp;
virtual void openFile() = 0;
virtual void closeFile() { fclose(fp); }
void _reportHead(const char* modName, const char* sourceInfo, Level severity) {
std::chrono::steady_clock::duration tm = CurrentUptime();
double tmd = tm.count() * std::chrono::steady_clock::duration::period::num /
(double)std::chrono::steady_clock::duration::period::den;
std::thread::id thrId = std::this_thread::get_id();
const char* thrName = nullptr;
if (ThreadMap.find(thrId) != ThreadMap.end())
thrName = ThreadMap[thrId];
fprintf(fp, "[");
fprintf(fp, "%5.4f ", tmd);
uint_fast64_t fIdx = FrameIndex.load();
if (fIdx)
fprintf(fp, "(%" PRIu64 ") ", fIdx);
switch (severity) {
case Info:
fprintf(fp, "INFO");
break;
case Warning:
fprintf(fp, "WARNING");
break;
case Error:
fprintf(fp, "ERROR");
break;
case Fatal:
fprintf(fp, "FATAL ERROR");
break;
default:
break;
};
fprintf(fp, " %s", modName);
if (sourceInfo)
fprintf(fp, " {%s}", sourceInfo);
if (thrName)
fprintf(fp, " (%s)", thrName);
fprintf(fp, "] ");
}
void report(const char* modName, Level severity, const char* format, va_list ap) {
openFile();
_reportHead(modName, nullptr, severity);
vfprintf(fp, format, ap);
fprintf(fp, "\n");
closeFile();
}
void report(const char* modName, Level severity, const wchar_t* format, va_list ap) {
openFile();
_reportHead(modName, nullptr, severity);
vfwprintf(fp, format, ap);
fprintf(fp, "\n");
closeFile();
}
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, const char* format,
va_list ap) {
openFile();
char sourceInfo[128];
snprintf(sourceInfo, 128, "%s:%u", file, linenum);
_reportHead(modName, sourceInfo, severity);
vfprintf(fp, format, ap);
fprintf(fp, "\n");
closeFile();
}
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, const wchar_t* format,
va_list ap) {
openFile();
char sourceInfo[128];
snprintf(sourceInfo, 128, "%s:%u", file, linenum);
_reportHead(modName, sourceInfo, severity);
vfwprintf(fp, format, ap);
fprintf(fp, "\n");
closeFile();
}
2015-07-03 22:08:41 +00:00
};
2018-12-08 05:17:15 +00:00
struct FileLogger8 : public FileLogger {
const char* m_filepath;
FileLogger8(const char* filepath) : m_filepath(filepath) {}
void openFile() { fp = fopen(m_filepath, "a"); }
2015-07-03 22:08:41 +00:00
};
2018-12-08 05:17:15 +00:00
void RegisterFileLogger(const char* filepath) {
/* Otherwise construct new file logger */
MainLoggers.emplace_back(new FileLogger8(filepath));
2015-07-03 22:08:41 +00:00
}
#if LOG_UCS2
2018-12-08 05:17:15 +00:00
struct FileLogger16 : public FileLogger {
const wchar_t* m_filepath;
FileLogger16(const wchar_t* filepath) : m_filepath(filepath) {}
void openFile() { fp = _wfopen(m_filepath, L"a"); }
2015-07-03 22:08:41 +00:00
};
2018-12-08 05:17:15 +00:00
void RegisterFileLogger(const wchar_t* filepath) {
/* Determine if file logger already added */
for (auto& logger : MainLoggers) {
FileLogger16* filelogger = dynamic_cast<FileLogger16*>(logger.get());
if (filelogger) {
if (!wcscmp(filepath, filelogger->m_filepath))
return;
2015-07-03 22:08:41 +00:00
}
2018-12-08 05:17:15 +00:00
}
2015-07-03 22:08:41 +00:00
2018-12-08 05:17:15 +00:00
/* Otherwise construct new file logger */
MainLoggers.emplace_back(new FileLogger16(filepath));
2015-07-03 22:08:41 +00:00
}
#endif
2018-12-08 05:17:15 +00:00
} // namespace logvisor