logging!!

This commit is contained in:
Yoshman29
2022-11-02 19:32:46 +01:00
parent 4ae869f17c
commit 23045f3fba
14 changed files with 219 additions and 34 deletions
+24 -23
View File
@@ -142,31 +142,32 @@ class WinAPI {
if (!AllocConsole())
return;
FILE* fDummy;
freopen_s(&fDummy, "CONOUT$", "w", stdout);
freopen_s(&fDummy, "CONOUT$", "w", stderr);
freopen_s(&fDummy, "CONIN$", "r", stdin);
std::cout.clear();
std::clog.clear();
std::cerr.clear();
std::cin.clear();
// std::wcout, std::wclog, std::wcerr, std::wcin
HANDLE hConOut = CreateFile(_T("CONOUT$"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
HANDLE hConIn = CreateFile(_T("CONIN$"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
SetStdHandle(STD_OUTPUT_HANDLE, hConOut);
SetStdHandle(STD_ERROR_HANDLE, hConOut);
SetStdHandle(STD_INPUT_HANDLE, hConIn);
std::wcout.clear();
std::wclog.clear();
std::wcerr.clear();
std::wcin.clear();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
')
public static function allocConsole() {
// LogsOverlay.consoleOpened = LogsOverlay.consoleVisible = true;
haxe.Log.trace = function(v:Dynamic, ?infos:haxe.PosInfos) {
// nothing here so that it keeps shit clean
}
}
#if windows
@:functionCode('
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(console, color);
')
#end
public static function setConsoleColors(color:Int) {
}
#if windows
@:functionCode('
system("CLS");
std::cout<< "" <<std::flush;
')
#end
public static function clearScreen() {
}
}
#end