diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-10-20 20:34:47 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-10-20 20:34:47 +0200 |
commit | 6ef07b10b96510077f656f862bcd7da29bafa202 (patch) | |
tree | 69dd3bee73bd1a6719291dd182078313a24c0f72 /contrib/epee/src | |
parent | Merge pull request #4629 (diff) | |
parent | ANSI colors in Windows 10 (diff) | |
download | monero-6ef07b10b96510077f656f862bcd7da29bafa202.tar.xz |
Merge pull request #4520
2e2daebc ANSI colors in Windows 10 (iDunk5400)
Diffstat (limited to 'contrib/epee/src')
-rw-r--r-- | contrib/epee/src/mlog.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index 61d853ef4..638155b6b 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -28,6 +28,13 @@ #ifndef _MLOG_H_ #define _MLOG_H_ +#ifdef _WIN32 +#include <windows.h> +#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING +#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 +#endif +#endif + #include <time.h> #include <atomic> #include <boost/filesystem.hpp> @@ -117,6 +124,31 @@ static const char *get_default_categories(int level) return categories; } +#ifdef WIN32 +bool EnableVTMode() +{ + // Set output mode to handle virtual terminal sequences + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); + if (hOut == INVALID_HANDLE_VALUE) + { + return false; + } + + DWORD dwMode = 0; + if (!GetConsoleMode(hOut, &dwMode)) + { + return false; + } + + dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + if (!SetConsoleMode(hOut, dwMode)) + { + return false; + } + return true; +} +#endif + void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size, const std::size_t max_log_files) { el::Configurations c; @@ -202,6 +234,9 @@ void mlog_configure(const std::string &filename_base, bool console, const std::s monero_log = get_default_categories(0); } mlog_set_log(monero_log); +#ifdef WIN32 + EnableVTMode(); +#endif } void mlog_set_categories(const char *categories) |