Fix fmtlib including windows.h everywhere

This commit is contained in:
DankParrot 2020-08-22 16:40:09 -07:00
parent 52d583c4c1
commit 75c1f4ce01
2 changed files with 37 additions and 36 deletions

View File

@ -3,16 +3,9 @@
#include <cstdio>
#include <cstdarg>
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
// Instead of defining FMT_HEADER_ONLY or building fmtlib
// we can just include all implementation code in Logger.cpp
#include "fmt/src/format.cc"
namespace Feather::Log
{
@ -36,30 +29,41 @@ namespace Feather::Log
return *s_logger;
}
}
namespace
{
class LoggingManager
{
public:
LoggingManager()
{
#ifdef _WIN32
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
if (handle != INVALID_HANDLE_VALUE)
{
DWORD mode = 0;
if (GetConsoleMode(handle, &mode))
{
// To enable ANSI escape sequences on Windows 10 we need to set this flag
mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(handle, mode);
}
}
#endif
}
};
static LoggingManager s_networkManager;
}
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
namespace
{
class LoggingManager
{
public:
LoggingManager()
{
#ifdef _WIN32
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
if (handle != INVALID_HANDLE_VALUE)
{
DWORD mode = 0;
if (GetConsoleMode(handle, &mode))
{
// To enable ANSI escape sequences on Windows 10 we need to set this flag
mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(handle, mode);
}
}
#endif
}
};
static LoggingManager s_loggingManager;
}

View File

@ -1,8 +1,5 @@
#pragma once
#include <event2/event.h>
#define FMT_HEADER_ONLY
#include <fmt/core.h>
#include <fmt/color.h>
#include <ostream>