Make logger stdout cross platform again

This commit is contained in:
Tixx
2025-09-21 21:54:24 +02:00
parent 1209ff88e2
commit a669557726
2 changed files with 8 additions and 6 deletions

View File

@@ -21,12 +21,14 @@
#define beammp_fs_string std::wstring #define beammp_fs_string std::wstring
#define beammp_fs_char wchar_t #define beammp_fs_char wchar_t
#define beammp_wide(str) L##str #define beammp_wide(str) L##str
#define beammp_stdout std::wcout
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#else #else
#define beammp_fs_string std::string #define beammp_fs_string std::string
#define beammp_fs_char char #define beammp_fs_char char
#define beammp_wide(str) str #define beammp_wide(str) str
#define beammp_stdout std::cout
#endif #endif
namespace Utils { namespace Utils {

View File

@@ -57,36 +57,36 @@ void addToLog(const std::wstring& Line) {
} }
void info(const std::string& toPrint) { void info(const std::string& toPrint) {
std::string Print = getDate() + "[INFO] " + toPrint + "\n"; std::string Print = getDate() + "[INFO] " + toPrint + "\n";
std::wcout << Utils::ToWString(Print); beammp_stdout << Utils::ToWString(Print);
addToLog(Print); addToLog(Print);
} }
void debug(const std::string& toPrint) { void debug(const std::string& toPrint) {
std::string Print = getDate() + "[DEBUG] " + toPrint + "\n"; std::string Print = getDate() + "[DEBUG] " + toPrint + "\n";
if (options.verbose) { if (options.verbose) {
std::wcout << Utils::ToWString(Print); beammp_stdout << Utils::ToWString(Print);
} }
addToLog(Print); addToLog(Print);
} }
void warn(const std::string& toPrint) { void warn(const std::string& toPrint) {
std::string Print = getDate() + "[WARN] " + toPrint + "\n"; std::string Print = getDate() + "[WARN] " + toPrint + "\n";
std::wcout << Utils::ToWString(Print); beammp_stdout << Utils::ToWString(Print);
addToLog(Print); addToLog(Print);
} }
void error(const std::string& toPrint) { void error(const std::string& toPrint) {
std::string Print = getDate() + "[ERROR] " + toPrint + "\n"; std::string Print = getDate() + "[ERROR] " + toPrint + "\n";
std::wcout << Utils::ToWString(Print); beammp_stdout << Utils::ToWString(Print);
addToLog(Print); addToLog(Print);
} }
void fatal(const std::string& toPrint) { void fatal(const std::string& toPrint) {
std::string Print = getDate() + "[FATAL] " + toPrint + "\n"; std::string Print = getDate() + "[FATAL] " + toPrint + "\n";
std::wcout << Utils::ToWString(Print); beammp_stdout << Utils::ToWString(Print);
addToLog(Print); addToLog(Print);
std::this_thread::sleep_for(std::chrono::seconds(5)); std::this_thread::sleep_for(std::chrono::seconds(5));
std::exit(1); std::exit(1);
} }
void except(const std::string& toPrint) { void except(const std::string& toPrint) {
std::string Print = getDate() + "[EXCEP] " + toPrint + "\n"; std::string Print = getDate() + "[EXCEP] " + toPrint + "\n";
std::wcout << Utils::ToWString(Print); beammp_stdout << Utils::ToWString(Print);
addToLog(Print); addToLog(Print);
} }