mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-29 23:41:19 -06:00
Fix log async thread name and custom setting not loaded (#4319)
* Log fix thread name in async * Log always load custom settings * Log always in color like before spdlog
This commit is contained in:
parent
99f2480e21
commit
5a15eb4d94
@ -176,7 +176,7 @@ void Setup(std::string_view log_filename) {
|
||||
}
|
||||
|
||||
#else
|
||||
g_console_sink = UpdateColorLevels(std::make_shared<spdlog_stdout>());
|
||||
g_console_sink = UpdateColorLevels(std::make_shared<spdlog_stdout>(spdlog::color_mode::always));
|
||||
#endif
|
||||
|
||||
g_console_sink->set_formatter(std::make_unique<thread_name_formatter>(UNLIMITED_SIZE));
|
||||
|
||||
@ -23,6 +23,7 @@ using spdlog_stdout = spdlog::sinks::stdout_color_sink_mt;
|
||||
|
||||
#include "common/logging/classes.h"
|
||||
#include "common/path_util.h"
|
||||
#include "common/thread.h"
|
||||
|
||||
namespace Common::Log {
|
||||
extern bool g_should_append;
|
||||
@ -33,13 +34,24 @@ void Setup(std::string_view log_filename);
|
||||
void Shutdown();
|
||||
|
||||
void Flush();
|
||||
|
||||
static constexpr std::array level_string_views{"Trace", "Debug", "Info", "Warning",
|
||||
"Error", "Critical", "Off"};
|
||||
|
||||
[[nodiscard]] static constexpr std::string_view to_string_view(spdlog::level lvl) noexcept {
|
||||
return level_string_views.at(level_to_number(lvl));
|
||||
}
|
||||
} // namespace Common::Log
|
||||
|
||||
// Define the fmt lib macros
|
||||
#define LOG_GENERIC(log_class, log_level, ...) \
|
||||
#define LOG_GENERIC(log_class, log_level, format, ...) \
|
||||
do { \
|
||||
if (auto logger = Common::Log::ALL_LOGGERS[log_class]) { \
|
||||
SPDLOG_LOGGER_CALL(logger, log_level, __VA_ARGS__); \
|
||||
logger->log(log_level, "[{}] <{}> ({}) {}:{} {}: " format, log_class, \
|
||||
Common::Log::to_string_view(log_level), Common::GetCurrentThreadName(), \
|
||||
spdlog::source_loc::basename(__FILE__), __LINE__, \
|
||||
std::string_view(__func__) == "operator()" ? "lambda" : __func__, \
|
||||
##__VA_ARGS__); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
|
||||
@ -9,18 +9,9 @@
|
||||
#include <spdlog/details/log_msg.h>
|
||||
#include <spdlog/formatter.h>
|
||||
|
||||
#include "common/thread.h"
|
||||
|
||||
namespace Common::Log {
|
||||
static constexpr unsigned long long UNLIMITED_SIZE = 0;
|
||||
|
||||
static constexpr std::array level_string_views{"Trace", "Debug", "Info", "Warning",
|
||||
"Error", "Critical", "Off"};
|
||||
|
||||
[[nodiscard]] static constexpr std::string_view to_string_view(spdlog::level lvl) noexcept {
|
||||
return level_string_views.at(level_to_number(lvl));
|
||||
}
|
||||
|
||||
struct thread_name_formatter : spdlog::formatter {
|
||||
~thread_name_formatter() override = default;
|
||||
|
||||
@ -33,27 +24,6 @@ struct thread_name_formatter : spdlog::formatter {
|
||||
|
||||
msg.color_range_start = dest.size();
|
||||
|
||||
dest.push_back('[');
|
||||
spdlog::details::fmt_helper::append_string_view(msg.logger_name, dest);
|
||||
dest.push_back(']');
|
||||
dest.push_back(' ');
|
||||
dest.push_back('<');
|
||||
spdlog::details::fmt_helper::append_string_view(Log::to_string_view(msg.log_level), dest);
|
||||
dest.push_back('>');
|
||||
dest.push_back(' ');
|
||||
dest.push_back('(');
|
||||
spdlog::details::fmt_helper::append_string_view(GetCurrentThreadName(), dest);
|
||||
dest.push_back(')');
|
||||
dest.push_back(' ');
|
||||
spdlog::details::fmt_helper::append_string_view(msg.source.short_filename, dest);
|
||||
dest.push_back(':');
|
||||
spdlog::details::fmt_helper::append_int(msg.source.line, dest);
|
||||
dest.push_back(' ');
|
||||
spdlog::details::fmt_helper::append_string_view(
|
||||
std::string_view(msg.source.funcname) == "operator()" ? "lambda" : msg.source.funcname,
|
||||
dest);
|
||||
dest.push_back(':');
|
||||
dest.push_back(' ');
|
||||
spdlog::details::fmt_helper::append_string_view(msg.payload, dest);
|
||||
spdlog::details::fmt_helper::append_string_view(spdlog::details::os::default_eol, dest);
|
||||
|
||||
|
||||
@ -243,11 +243,10 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> args,
|
||||
|
||||
EmulatorSettings.Load(id);
|
||||
|
||||
Common::Log::Shutdown();
|
||||
// Initialize logging as soon as possible
|
||||
if (!id.empty() && EmulatorSettings.IsLogSeparate()) {
|
||||
Common::Log::Shutdown();
|
||||
Common::Log::Setup(id + ".log");
|
||||
}
|
||||
Common::Log::Setup((!id.empty() && EmulatorSettings.IsLogSeparate()) ? id + ".log"
|
||||
: "shad_log.txt");
|
||||
|
||||
if (!std::filesystem::exists(file)) {
|
||||
LOG_CRITICAL(Loader, "eboot.bin does not exist: {}",
|
||||
|
||||
@ -169,7 +169,7 @@ Block* Inst::PhiBlock(size_t index) const {
|
||||
UNREACHABLE_MSG("{} is not a Phi instruction", op);
|
||||
}
|
||||
if (index >= phi_args.size()) {
|
||||
UNREACHABLE_MSG("Out of bounds argument index {} in phi instruction");
|
||||
UNREACHABLE_MSG("Out of bounds argument index {} in phi instruction", index);
|
||||
}
|
||||
return phi_args[index].first;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user