mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-11 08:36:16 +00:00
Fix more format warnings
This commit is contained in:
@@ -75,6 +75,12 @@ namespace
|
||||
return {buffer, static_cast<size_t>(count)};
|
||||
}
|
||||
|
||||
#define format_to_string(msg, str)\
|
||||
va_list ap;\
|
||||
va_start(ap, msg);\
|
||||
const auto str = format(&ap, msg);\
|
||||
va_end(ap);
|
||||
|
||||
void print_colored(const std::string_view& line, const color_type base_color)
|
||||
{
|
||||
const auto _ = utils::finally(&reset_color);
|
||||
@@ -83,18 +89,48 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void logger::print(const color c, const char* message, ...) const
|
||||
void logger::print(const color c, const std::string_view message) const
|
||||
{
|
||||
if (this->disable_output_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, message);
|
||||
|
||||
const auto data = format(&ap, message);
|
||||
print_colored(data, get_color_type(c));
|
||||
|
||||
va_end(ap);
|
||||
print_colored(message, get_color_type(c));
|
||||
}
|
||||
|
||||
void logger::print(const color c, const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(c, data);
|
||||
}
|
||||
|
||||
void logger::info(const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(color::cyan, data);
|
||||
}
|
||||
|
||||
void logger::warn(const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(color::yellow, data);
|
||||
}
|
||||
|
||||
void logger::error(const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(color::red, data);
|
||||
}
|
||||
|
||||
void logger::success(const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(color::green, data);
|
||||
}
|
||||
|
||||
void logger::log(const char* message, ...) const
|
||||
{
|
||||
format_to_string(message, data);
|
||||
this->print(color::gray, data);
|
||||
}
|
||||
|
||||
@@ -23,37 +23,13 @@ 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);
|
||||
|
||||
template <typename... Args>
|
||||
void info(const char* message, Args... args) const
|
||||
{
|
||||
this->print(color::cyan, message, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void warn(const char* message, Args... args) const
|
||||
{
|
||||
this->print(color::yellow, message, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void error(const char* message, Args... args) const
|
||||
{
|
||||
this->print(color::red, message, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void success(const char* message, Args... args) const
|
||||
{
|
||||
this->print(color::green, message, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void log(const char* message, Args... args) const
|
||||
{
|
||||
this->print(color::gray, message, args...);
|
||||
}
|
||||
void info(const char* message, ...) const FORMAT_ATTRIBUTE(2, 3);
|
||||
void warn(const char* message, ...) const FORMAT_ATTRIBUTE(2, 3);
|
||||
void error(const char* message, ...) const FORMAT_ATTRIBUTE(2, 3);
|
||||
void success(const char* message, ...) const FORMAT_ATTRIBUTE(2, 3);
|
||||
void log(const char* message, ...) const FORMAT_ATTRIBUTE(2, 3);
|
||||
|
||||
void disable_output(const bool value)
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ mapped_module* module_manager::map_module(const std::filesystem::path& file, log
|
||||
{
|
||||
auto mod = map_module_from_file(*this->emu_, std::move(canonical_file));
|
||||
|
||||
logger.log("Mapped %s at 0x%llX\n", mod.path.generic_string().c_str(), mod.image_base);
|
||||
logger.log("Mapped %s at 0x%" PRIx64 "\n", mod.path.generic_string().c_str(), mod.image_base);
|
||||
|
||||
const auto image_base = mod.image_base;
|
||||
const auto entry = this->modules_.try_emplace(image_base, std::move(mod));
|
||||
|
||||
Reference in New Issue
Block a user