mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 06:15:38 +00:00
CommonHostInterface: Fix command line help not printing on Windows
This commit is contained in:
parent
dae54d06ea
commit
eb7da791ea
|
@ -75,6 +75,16 @@ void UnregisterCallback(CallbackFunctionType callbackFunction, void* pUserParam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsConsoleOutputEnabled()
|
||||||
|
{
|
||||||
|
return s_consoleOutputEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsDebugOutputEnabled()
|
||||||
|
{
|
||||||
|
return s_debugOutputEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
static void ExecuteCallbacks(const char* channelName, const char* functionName, LOGLEVEL level, const char* message)
|
static void ExecuteCallbacks(const char* channelName, const char* functionName, LOGLEVEL level, const char* message)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(s_callback_mutex);
|
std::lock_guard<std::mutex> guard(s_callback_mutex);
|
||||||
|
@ -273,8 +283,15 @@ void SetConsoleOutputParams(bool Enabled, const char* ChannelFilter, LOGLEVEL Le
|
||||||
if (GetConsoleWindow() == NULL)
|
if (GetConsoleWindow() == NULL)
|
||||||
{
|
{
|
||||||
DebugAssert(!console_was_allocated);
|
DebugAssert(!console_was_allocated);
|
||||||
|
|
||||||
|
// Attach to the parent console if we're running from a command window
|
||||||
|
if (!AttachConsole(ATTACH_PARENT_PROCESS))
|
||||||
|
{
|
||||||
|
if (!AllocConsole())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
console_was_allocated = true;
|
console_was_allocated = true;
|
||||||
AllocConsole();
|
|
||||||
|
|
||||||
std::FILE* fp;
|
std::FILE* fp;
|
||||||
freopen_s(&fp, "CONIN$", "r", stdin);
|
freopen_s(&fp, "CONIN$", "r", stdin);
|
||||||
|
|
|
@ -30,9 +30,11 @@ void RegisterCallback(CallbackFunctionType callbackFunction, void* pUserParam);
|
||||||
void UnregisterCallback(CallbackFunctionType callbackFunction, void* pUserParam);
|
void UnregisterCallback(CallbackFunctionType callbackFunction, void* pUserParam);
|
||||||
|
|
||||||
// adds a standard console output
|
// adds a standard console output
|
||||||
|
bool IsConsoleOutputEnabled();
|
||||||
void SetConsoleOutputParams(bool enabled, const char* channelFilter = nullptr, LOGLEVEL levelFilter = LOGLEVEL_TRACE);
|
void SetConsoleOutputParams(bool enabled, const char* channelFilter = nullptr, LOGLEVEL levelFilter = LOGLEVEL_TRACE);
|
||||||
|
|
||||||
// adds a debug console output [win32/android only]
|
// adds a debug console output [win32/android only]
|
||||||
|
bool IsDebugOutputEnabled();
|
||||||
void SetDebugOutputParams(bool enabled, const char* channelFilter = nullptr, LOGLEVEL levelFilter = LOGLEVEL_TRACE);
|
void SetDebugOutputParams(bool enabled, const char* channelFilter = nullptr, LOGLEVEL levelFilter = LOGLEVEL_TRACE);
|
||||||
|
|
||||||
// adds a file output
|
// adds a file output
|
||||||
|
@ -48,34 +50,28 @@ void Writef(const char* channelName, const char* functionName, LOGLEVEL level, c
|
||||||
void Writev(const char* channelName, const char* functionName, LOGLEVEL level, const char* format, va_list ap);
|
void Writev(const char* channelName, const char* functionName, LOGLEVEL level, const char* format, va_list ap);
|
||||||
} // namespace Log
|
} // namespace Log
|
||||||
|
|
||||||
#ifdef Y_BUILD_CONFIG_SHIPPING
|
|
||||||
#define LOG_MESSAGE_FUNCTION_NAME ""
|
|
||||||
#else
|
|
||||||
#define LOG_MESSAGE_FUNCTION_NAME __FUNCTION__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// log wrappers
|
// log wrappers
|
||||||
#define Log_SetChannel(ChannelName) static const char* ___LogChannel___ = #ChannelName;
|
#define Log_SetChannel(ChannelName) static const char* ___LogChannel___ = #ChannelName;
|
||||||
#define Log_ErrorPrint(msg) Log::Write(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_ERROR, msg)
|
#define Log_ErrorPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_ERROR, msg)
|
||||||
#define Log_ErrorPrintf(...) Log::Writef(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_ERROR, __VA_ARGS__)
|
#define Log_ErrorPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_ERROR, __VA_ARGS__)
|
||||||
#define Log_WarningPrint(msg) Log::Write(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_WARNING, msg)
|
#define Log_WarningPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_WARNING, msg)
|
||||||
#define Log_WarningPrintf(...) Log::Writef(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_WARNING, __VA_ARGS__)
|
#define Log_WarningPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_WARNING, __VA_ARGS__)
|
||||||
#define Log_SuccessPrint(msg) Log::Write(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_SUCCESS, msg)
|
#define Log_SuccessPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_SUCCESS, msg)
|
||||||
#define Log_SuccessPrintf(...) Log::Writef(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_SUCCESS, __VA_ARGS__)
|
#define Log_SuccessPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_SUCCESS, __VA_ARGS__)
|
||||||
#define Log_InfoPrint(msg) Log::Write(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_INFO, msg)
|
#define Log_InfoPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_INFO, msg)
|
||||||
#define Log_InfoPrintf(...) Log::Writef(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_INFO, __VA_ARGS__)
|
#define Log_InfoPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_INFO, __VA_ARGS__)
|
||||||
#define Log_PerfPrint(msg) Log::Write(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_PERF, msg)
|
#define Log_PerfPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_PERF, msg)
|
||||||
#define Log_PerfPrintf(...) Log::Writef(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_PERF, __VA_ARGS__)
|
#define Log_PerfPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_PERF, __VA_ARGS__)
|
||||||
#define Log_DevPrint(msg) Log::Write(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_DEV, msg)
|
#define Log_DevPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_DEV, msg)
|
||||||
#define Log_DevPrintf(...) Log::Writef(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_DEV, __VA_ARGS__)
|
#define Log_DevPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_DEV, __VA_ARGS__)
|
||||||
#define Log_ProfilePrint(msg) Log::Write(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_PROFILE, msg)
|
#define Log_ProfilePrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_PROFILE, msg)
|
||||||
#define Log_ProfilePrintf(...) Log::Writef(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_PROFILE, __VA_ARGS__)
|
#define Log_ProfilePrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_PROFILE, __VA_ARGS__)
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define Log_DebugPrint(msg) Log::Write(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_DEBUG, msg)
|
#define Log_DebugPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_DEBUG, msg)
|
||||||
#define Log_DebugPrintf(...) Log::Writef(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_DEBUG, __VA_ARGS__)
|
#define Log_DebugPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_DEBUG, __VA_ARGS__)
|
||||||
#define Log_TracePrint(msg) Log::Write(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_TRACE, msg)
|
#define Log_TracePrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_TRACE, msg)
|
||||||
#define Log_TracePrintf(...) Log::Writef(___LogChannel___, LOG_MESSAGE_FUNCTION_NAME, LOGLEVEL_TRACE, __VA_ARGS__)
|
#define Log_TracePrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_TRACE, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define Log_DebugPrint(msg) \
|
#define Log_DebugPrint(msg) \
|
||||||
do \
|
do \
|
||||||
|
|
|
@ -204,13 +204,24 @@ void CommonHostInterface::PowerOffSystem()
|
||||||
|
|
||||||
static void PrintCommandLineVersion(const char* frontend_name)
|
static void PrintCommandLineVersion(const char* frontend_name)
|
||||||
{
|
{
|
||||||
|
const bool was_console_enabled = Log::IsConsoleOutputEnabled();
|
||||||
|
if (!was_console_enabled)
|
||||||
|
Log::SetConsoleOutputParams(true);
|
||||||
|
|
||||||
std::fprintf(stderr, "%s Version %s (%s)\n", frontend_name, g_scm_tag_str, g_scm_branch_str);
|
std::fprintf(stderr, "%s Version %s (%s)\n", frontend_name, g_scm_tag_str, g_scm_branch_str);
|
||||||
std::fprintf(stderr, "https://github.com/stenzek/duckstation\n");
|
std::fprintf(stderr, "https://github.com/stenzek/duckstation\n");
|
||||||
std::fprintf(stderr, "\n");
|
std::fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
if (!was_console_enabled)
|
||||||
|
Log::SetConsoleOutputParams(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintCommandLineHelp(const char* progname, const char* frontend_name)
|
static void PrintCommandLineHelp(const char* progname, const char* frontend_name)
|
||||||
{
|
{
|
||||||
|
const bool was_console_enabled = Log::IsConsoleOutputEnabled();
|
||||||
|
if (!was_console_enabled)
|
||||||
|
Log::SetConsoleOutputParams(true);
|
||||||
|
|
||||||
PrintCommandLineVersion(frontend_name);
|
PrintCommandLineVersion(frontend_name);
|
||||||
std::fprintf(stderr, "Usage: %s [parameters] [--] [boot filename]\n", progname);
|
std::fprintf(stderr, "Usage: %s [parameters] [--] [boot filename]\n", progname);
|
||||||
std::fprintf(stderr, "\n");
|
std::fprintf(stderr, "\n");
|
||||||
|
@ -234,6 +245,9 @@ static void PrintCommandLineHelp(const char* progname, const char* frontend_name
|
||||||
" parameters make up the filename. Use when the filename contains\n"
|
" parameters make up the filename. Use when the filename contains\n"
|
||||||
" spaces or starts with a dash.\n");
|
" spaces or starts with a dash.\n");
|
||||||
std::fprintf(stderr, "\n");
|
std::fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
if (!was_console_enabled)
|
||||||
|
Log::SetConsoleOutputParams(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommonHostInterface::ParseCommandLineParameters(int argc, char* argv[],
|
bool CommonHostInterface::ParseCommandLineParameters(int argc, char* argv[],
|
||||||
|
|
Loading…
Reference in a new issue