mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 11:43:56 +00:00
Always print errors
This commit is contained in:
@@ -153,26 +153,32 @@ namespace
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
win_emu.log.print(color::red, "Emulation failed at: 0x%" PRIx64 " - %s\n",
|
||||
win_emu.emu().read_instruction_pointer(), e.what());
|
||||
win_emu.log.error("Emulation failed at: 0x%" PRIx64 " - %s\n", win_emu.emu().read_instruction_pointer(),
|
||||
e.what());
|
||||
throw;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
win_emu.log.print(color::red, "Emulation failed at: 0x%" PRIx64 "\n",
|
||||
win_emu.emu().read_instruction_pointer());
|
||||
win_emu.log.error("Emulation failed at: 0x%" PRIx64 "\n", win_emu.emu().read_instruction_pointer());
|
||||
throw;
|
||||
}
|
||||
|
||||
const auto exit_status = win_emu.process.exit_status;
|
||||
if (!exit_status.has_value())
|
||||
{
|
||||
win_emu.log.print(color::red, "Emulation terminated without status!\n");
|
||||
win_emu.log.error("Emulation terminated without status!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto success = *exit_status == STATUS_SUCCESS;
|
||||
win_emu.log.print(success ? color::green : color::red, "Emulation terminated with status: %X\n", *exit_status);
|
||||
|
||||
if (!options.silent)
|
||||
{
|
||||
win_emu.log.disable_output(false);
|
||||
win_emu.log.print(success ? color::green : color::red, "Emulation terminated with status: %X\n",
|
||||
*exit_status);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,7 @@ namespace
|
||||
catch (...)
|
||||
{
|
||||
win_emu.log.disable_output(false);
|
||||
win_emu.log.print(color::red, "Emulation failed at: 0x%" PRIx64 "\n",
|
||||
win_emu.emu().read_instruction_pointer());
|
||||
win_emu.log.error("Emulation failed at: 0x%" PRIx64 "\n", win_emu.emu().read_instruction_pointer());
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace
|
||||
va_list ap; \
|
||||
va_start(ap, msg); \
|
||||
const auto str = format(&ap, msg); \
|
||||
va_end(ap);
|
||||
va_end(ap)
|
||||
|
||||
void print_colored(const std::string_view& line, const color_type base_color)
|
||||
{
|
||||
@@ -106,9 +106,9 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void logger::print(const color c, const std::string_view message) const
|
||||
void logger::print_message(const color c, const std::string_view message, const bool force) const
|
||||
{
|
||||
if (this->disable_output_)
|
||||
if (!force && this->disable_output_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -120,40 +120,40 @@ void logger::print(const color c, const std::string_view message) const
|
||||
void logger::print(const color c, const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(c, data);
|
||||
this->print_message(c, data);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cert-dcl50-cpp)
|
||||
void logger::info(const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(color::cyan, data);
|
||||
this->print_message(color::cyan, data);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cert-dcl50-cpp)
|
||||
void logger::warn(const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(color::yellow, data);
|
||||
this->print_message(color::yellow, data);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cert-dcl50-cpp)
|
||||
void logger::error(const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(color::red, data);
|
||||
this->print_message(color::red, data, true);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cert-dcl50-cpp)
|
||||
void logger::success(const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(color::green, data);
|
||||
this->print_message(color::green, data);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cert-dcl50-cpp)
|
||||
void logger::log(const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(color::gray, data);
|
||||
this->print_message(color::gray, data);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ enum class color
|
||||
class logger
|
||||
{
|
||||
public:
|
||||
void print(color c, std::string_view message) const;
|
||||
void print(color c, const char* message, ...) const FORMAT_ATTRIBUTE(3, 4);
|
||||
void info(const char* message, ...) const FORMAT_ATTRIBUTE(2, 3);
|
||||
void warn(const char* message, ...) const FORMAT_ATTRIBUTE(2, 3);
|
||||
@@ -43,4 +42,5 @@ class logger
|
||||
|
||||
private:
|
||||
bool disable_output_{false};
|
||||
void print_message(color c, std::string_view message, bool force = false) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user