mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-26 04:41:34 +00:00
move to debugging.[ch]pp
This commit is contained in:
parent
74955555b9
commit
f6c8842457
5 changed files with 33 additions and 56 deletions
|
@ -90,7 +90,7 @@ add_component_dir (misc
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (debug
|
add_component_dir (debug
|
||||||
debugging debuglog win32
|
debugging debuglog
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(NOT WIN32 AND NOT APPLE)
|
IF(NOT WIN32 AND NOT APPLE)
|
||||||
|
|
|
@ -4,6 +4,34 @@
|
||||||
|
|
||||||
namespace Debug
|
namespace Debug
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
bool attachParentConsole()
|
||||||
|
{
|
||||||
|
if (GetConsoleWindow() != nullptr)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (AttachConsole(ATTACH_PARENT_PROCESS))
|
||||||
|
{
|
||||||
|
fflush(stdout);
|
||||||
|
fflush(stderr);
|
||||||
|
std::cout.flush();
|
||||||
|
std::cerr.flush();
|
||||||
|
|
||||||
|
// this looks dubious but is really the right way
|
||||||
|
_wfreopen(L"CON", L"w", stdout);
|
||||||
|
_wfreopen(L"CON", L"w", stderr);
|
||||||
|
_wfreopen(L"CON", L"r", stdin);
|
||||||
|
freopen("CON", "w", stdout);
|
||||||
|
freopen("CON", "w", stderr);
|
||||||
|
freopen("CON", "r", stdin);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::streamsize DebugOutputBase::write(const char *str, std::streamsize size)
|
std::streamsize DebugOutputBase::write(const char *str, std::streamsize size)
|
||||||
{
|
{
|
||||||
// Skip debug level marker
|
// Skip debug level marker
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
#include <SDL_messagebox.h>
|
#include <SDL_messagebox.h>
|
||||||
|
|
||||||
#include "debuglog.hpp"
|
#include "debuglog.hpp"
|
||||||
#if defined _WIN32
|
|
||||||
# include "win32.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Debug
|
namespace Debug
|
||||||
{
|
{
|
||||||
|
@ -46,6 +43,10 @@ namespace Debug
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
bool attachParentConsole();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_DEBUG)
|
#if defined(_WIN32) && defined(_DEBUG)
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN 1
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
#include "win32.hpp"
|
|
||||||
|
|
||||||
#undef _CRT_SECURE_NO_WARNINGS
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
namespace Debug {
|
|
||||||
|
|
||||||
bool attachParentConsole()
|
|
||||||
{
|
|
||||||
if (GetConsoleWindow() != nullptr)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (AttachConsole(ATTACH_PARENT_PROCESS))
|
|
||||||
{
|
|
||||||
fflush(stdout);
|
|
||||||
fflush(stderr);
|
|
||||||
std::cout.flush();
|
|
||||||
std::cerr.flush();
|
|
||||||
|
|
||||||
// this looks dubious but is really the right way
|
|
||||||
_wfreopen(L"CON", L"w", stdout);
|
|
||||||
_wfreopen(L"CON", L"w", stderr);
|
|
||||||
_wfreopen(L"CON", L"r", stdin);
|
|
||||||
freopen("CON", "w", stdout);
|
|
||||||
freopen("CON", "w", stderr);
|
|
||||||
freopen("CON", "r", stdin);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // ns Debug
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,9 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
namespace Debug {
|
|
||||||
bool attachParentConsole();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue