diff options
| author | Mikhail Redko <ovitnez@gmail.com> | 2021-04-11 20:41:44 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-11 19:41:44 +0200 |
| commit | 1539bed3db86f2153f2d0d5fbf24bf9ee4af1d92 (patch) | |
| tree | ed25236f21145d23d6e3a3fc9d7ff62675a13ba9 /src/common/Logging | |
| parent | 6bdfa91fa795b24bfba6a4497784b693f6216638 (diff) | |
Core/Misc: Fixed utf8 encoding in console input/output. (#26352)
* Core/Misc: Fixed utf8 encoding in console input/output.
* Fix gcc build
* Fixed that weird 'a' with circle above it and other similar letters. Also fixed encoding in AppenderConsole which sometimes did not work as it should
* Fix build on Linux
* Probably better to do it like this
Diffstat (limited to 'src/common/Logging')
| -rw-r--r-- | src/common/Logging/AppenderConsole.cpp | 13 | ||||
| -rw-r--r-- | src/common/Logging/AppenderConsole.h | 1 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/common/Logging/AppenderConsole.cpp b/src/common/Logging/AppenderConsole.cpp index af2117c6d0c..eb02f5f3ccf 100644 --- a/src/common/Logging/AppenderConsole.cpp +++ b/src/common/Logging/AppenderConsole.cpp @@ -163,6 +163,15 @@ void AppenderConsole::ResetColor(bool stdout_stream) #endif } +void AppenderConsole::Print(std::string const& str, bool error) +{ +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS + WriteWinConsole(str + "\n", error); +#else + utf8printf(error ? stderr : stdout, "%s\n", str.c_str()); +#endif +} + void AppenderConsole::_write(LogMessage const* message) { bool stdout_stream = !(message->level == LOG_LEVEL_ERROR || message->level == LOG_LEVEL_FATAL); @@ -195,9 +204,9 @@ void AppenderConsole::_write(LogMessage const* message) } SetColor(stdout_stream, _colors[index]); - utf8printf(stdout_stream ? stdout : stderr, "%s%s\n", message->prefix.c_str(), message->text.c_str()); + Print(message->prefix + message->text, !stdout_stream); ResetColor(stdout_stream); } else - utf8printf(stdout_stream ? stdout : stderr, "%s%s\n", message->prefix.c_str(), message->text.c_str()); + Print(message->prefix + message->text, !stdout_stream); } diff --git a/src/common/Logging/AppenderConsole.h b/src/common/Logging/AppenderConsole.h index 6c6be4b6c59..19c5c211028 100644 --- a/src/common/Logging/AppenderConsole.h +++ b/src/common/Logging/AppenderConsole.h @@ -53,6 +53,7 @@ class TC_COMMON_API AppenderConsole : public Appender private: void SetColor(bool stdout_stream, ColorTypes color); void ResetColor(bool stdout_stream); + void Print(std::string const& str, bool error); void _write(LogMessage const* message) override; bool _colored; ColorTypes _colors[NUM_ENABLED_LOG_LEVELS]; |
