mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-22 19:35:42 +01:00
common/logging: Make logging get checked at compile time
- ensures log strings match the amount and type (if the format specifies an integer, for example) of the arguments - if at any later point a runtime-generated string is used as the log format, FmtLogMessage might require an overload taking a fmt::runtime_format_string<> as the format argument type, everything else being equal. wrap the generated string with fmt::runtime() before passing to the LOG_X functio
This commit is contained in:
parent
1bec420695
commit
ee8ba5965b
@ -343,7 +343,7 @@ void SetColorConsoleBackendEnabled(bool enabled) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
||||||
unsigned int line_num, const char* function, const char* format,
|
unsigned int line_num, const char* function, fmt::string_view format,
|
||||||
const fmt::format_args& args) {
|
const fmt::format_args& args) {
|
||||||
if (!initialization_in_progress_suppress_logging) {
|
if (!initialization_in_progress_suppress_logging) {
|
||||||
Impl::Instance().PushEntry(log_class, log_level, filename, line_num, function,
|
Impl::Instance().PushEntry(log_class, log_level, filename, line_num, function,
|
||||||
|
@ -24,12 +24,12 @@ constexpr const char* TrimSourcePath(std::string_view source) {
|
|||||||
|
|
||||||
/// Logs a message to the global logger, using fmt
|
/// Logs a message to the global logger, using fmt
|
||||||
void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
||||||
unsigned int line_num, const char* function, const char* format,
|
unsigned int line_num, const char* function, fmt::string_view format,
|
||||||
const fmt::format_args& args);
|
const fmt::format_args& args);
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
||||||
const char* function, const char* format, const Args&... args) {
|
const char* function, fmt::format_string<Args...> format, const Args&... args) {
|
||||||
FmtLogMessageImpl(log_class, log_level, filename, line_num, function, format,
|
FmtLogMessageImpl(log_class, log_level, filename, line_num, function, format,
|
||||||
fmt::make_format_args(args...));
|
fmt::make_format_args(args...));
|
||||||
}
|
}
|
||||||
|
@ -105,12 +105,4 @@ VirtualDir PartitionFilesystem::GetParentDirectory() const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartitionFilesystem::PrintDebugInfo() const {
|
|
||||||
LOG_DEBUG(Service_FS, "Magic: {:.4}", pfs_header.magic);
|
|
||||||
LOG_DEBUG(Service_FS, "Files: {}", pfs_header.num_entries);
|
|
||||||
for (u32 i = 0; i < pfs_header.num_entries; i++) {
|
|
||||||
LOG_DEBUG(Service_FS, " > File {}: {} (0x{:X} bytes)", i,
|
|
||||||
pfs_files[i]->GetName(), pfs_files[i]->GetSize());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // namespace FileSys
|
} // namespace FileSys
|
||||||
|
@ -35,7 +35,6 @@ public:
|
|||||||
std::vector<VirtualDir> GetSubdirectories() const override;
|
std::vector<VirtualDir> GetSubdirectories() const override;
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
VirtualDir GetParentDirectory() const override;
|
VirtualDir GetParentDirectory() const override;
|
||||||
void PrintDebugInfo() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Header {
|
struct Header {
|
||||||
|
@ -71,7 +71,7 @@ const char* GetType(GLenum type) {
|
|||||||
|
|
||||||
void APIENTRY DebugHandler(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
|
void APIENTRY DebugHandler(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
|
||||||
const GLchar* message, const void* user_param) {
|
const GLchar* message, const void* user_param) {
|
||||||
const char format[] = "{} {} {}: {}";
|
constexpr std::string_view format = "{} {} {}: {}";
|
||||||
const char* const str_source = GetSource(source);
|
const char* const str_source = GetSource(source);
|
||||||
const char* const str_type = GetType(type);
|
const char* const str_type = GetType(type);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user