Settings: Default console logging to running from TTY
This commit is contained in:
@ -18,6 +18,8 @@
|
||||
#elif defined(__ANDROID__)
|
||||
#include <android/log.h>
|
||||
#else
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@ -128,6 +130,20 @@ float Log::GetCurrentMessageTime()
|
||||
return static_cast<float>(Common::Timer::ConvertValueToSeconds(Common::Timer::GetCurrentValue() - s_start_timestamp));
|
||||
}
|
||||
|
||||
bool Log::IsConsoleOutputCurrentlyAvailable()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
return (h != NULL && h != INVALID_HANDLE_VALUE);
|
||||
#elif defined(__ANDROID__)
|
||||
return false;
|
||||
#else
|
||||
// standard output isn't really reliable because it could be redirected to a file. check standard input for tty.
|
||||
struct termios attr;
|
||||
return (tcgetattr(STDIN_FILENO, &attr) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Log::IsConsoleOutputEnabled()
|
||||
{
|
||||
return s_console_output_enabled;
|
||||
|
||||
@ -41,6 +41,7 @@ void UnregisterCallback(CallbackFunctionType callbackFunction, void* pUserParam)
|
||||
float GetCurrentMessageTime();
|
||||
|
||||
// adds a standard console output
|
||||
bool IsConsoleOutputCurrentlyAvailable();
|
||||
bool IsConsoleOutputEnabled();
|
||||
void SetConsoleOutputParams(bool enabled, bool timestamps = true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user