mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +12:00
Optimize logging via logs::channel
Use constant-initialized severity subobjects instead of temporaries
This commit is contained in:
parent
b94e98aed5
commit
ed8aa774bb
3 changed files with 15 additions and 19 deletions
|
@ -239,7 +239,7 @@ void logs::listener::add(logs::listener* _new)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u64* args)
|
void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u64* args) const
|
||||||
{
|
{
|
||||||
// Get timestamp
|
// Get timestamp
|
||||||
const u64 stamp = get_stamp();
|
const u64 stamp = get_stamp();
|
||||||
|
|
|
@ -23,14 +23,17 @@ namespace logs
|
||||||
|
|
||||||
struct channel;
|
struct channel;
|
||||||
|
|
||||||
// Message information (temporary data)
|
// Message information
|
||||||
struct message
|
struct message
|
||||||
{
|
{
|
||||||
channel* ch;
|
channel* ch;
|
||||||
level sev;
|
level sev;
|
||||||
|
|
||||||
|
private:
|
||||||
// Send log message to global logger instance
|
// Send log message to global logger instance
|
||||||
void broadcast(const char*, const fmt_type_info*, const u64*);
|
void broadcast(const char*, const fmt_type_info*, const u64*) const;
|
||||||
|
|
||||||
|
friend struct channel;
|
||||||
};
|
};
|
||||||
|
|
||||||
class listener
|
class listener
|
||||||
|
@ -67,22 +70,16 @@ namespace logs
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formatting function
|
|
||||||
template<typename... Args>
|
|
||||||
SAFE_BUFFERS FORCE_INLINE void format(level sev, const char* fmt, const Args&... args)
|
|
||||||
{
|
|
||||||
if (UNLIKELY(sev <= enabled))
|
|
||||||
{
|
|
||||||
static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make<fmt_unveil_t<Args>>()...};
|
|
||||||
message{this, sev}.broadcast(fmt, type_list, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GEN_LOG_METHOD(_sev)\
|
#define GEN_LOG_METHOD(_sev)\
|
||||||
template<typename... Args>\
|
const message msg_##_sev{this, level::_sev};\
|
||||||
SAFE_BUFFERS void _sev(const char* fmt, const Args&... args)\
|
template <typename... Args>\
|
||||||
|
void _sev(const char* fmt, const Args&... args)\
|
||||||
{\
|
{\
|
||||||
return format<Args...>(level::_sev, fmt, args...);\
|
if (UNLIKELY(level::_sev <= enabled))\
|
||||||
|
{\
|
||||||
|
static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make<fmt_unveil_t<Args>>()...};\
|
||||||
|
msg_##_sev.broadcast(fmt, type_list, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});\
|
||||||
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
GEN_LOG_METHOD(fatal)
|
GEN_LOG_METHOD(fatal)
|
||||||
|
|
|
@ -1465,7 +1465,6 @@ s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_i
|
||||||
}
|
}
|
||||||
|
|
||||||
logs::channel* channel = &logs::GENERAL;
|
logs::channel* channel = &logs::GENERAL;
|
||||||
logs::level level = logs::level::error;
|
|
||||||
const char* func = "Unknown function";
|
const char* func = "Unknown function";
|
||||||
|
|
||||||
if (auto thread = get_current_cpu_thread())
|
if (auto thread = get_current_cpu_thread())
|
||||||
|
@ -1490,7 +1489,7 @@ s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_i
|
||||||
|
|
||||||
if (stat <= 3)
|
if (stat <= 3)
|
||||||
{
|
{
|
||||||
channel->format(level, "%s [%u]", g_tls_error_str, stat);
|
channel->error("%s [%u]", g_tls_error_str, stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<s32>(arg);
|
return static_cast<s32>(arg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue