mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Move logs::channel registration out of the constructor
Allow constinit initialization of logs::channel.
This commit is contained in:
parent
e57c01907e
commit
87a5dd66ab
@ -267,13 +267,11 @@ void logs::listener::add(logs::listener* _new)
|
||||
}
|
||||
}
|
||||
|
||||
logs::channel::channel(const char* name)
|
||||
: name(name)
|
||||
, enabled(level::notice)
|
||||
logs::registerer::registerer(channel& _ch)
|
||||
{
|
||||
std::lock_guard lock(g_mutex);
|
||||
|
||||
get_logger()->channels.emplace(name, this);
|
||||
get_logger()->channels.emplace(_ch.name, &_ch);
|
||||
}
|
||||
|
||||
void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) const
|
||||
|
@ -61,8 +61,12 @@ namespace logs
|
||||
// The lowest logging level enabled for this channel (used for early filtering)
|
||||
std::atomic<level> enabled;
|
||||
|
||||
// Initialize and register channel
|
||||
channel(const char* name);
|
||||
// Initialize channel
|
||||
constexpr channel(const char* name) noexcept
|
||||
: name(name)
|
||||
, enabled(level::notice)
|
||||
{
|
||||
}
|
||||
|
||||
#define GEN_LOG_METHOD(_sev)\
|
||||
const message msg_##_sev{this, level::_sev};\
|
||||
@ -87,6 +91,11 @@ namespace logs
|
||||
#undef GEN_LOG_METHOD
|
||||
};
|
||||
|
||||
struct registerer
|
||||
{
|
||||
registerer(channel& _ch);
|
||||
};
|
||||
|
||||
// Log level control: set all channels to level::notice
|
||||
void reset();
|
||||
|
||||
@ -115,6 +124,13 @@ namespace logs
|
||||
}
|
||||
}
|
||||
|
||||
#define LOG_CHANNEL(ch, ...) inline ::logs::channel ch(::logs::make_channel_name(#ch, ##__VA_ARGS__))
|
||||
#if __cpp_constinit >= 201907
|
||||
#define LOG_CONSTINIT constinit
|
||||
#else
|
||||
#define LOG_CONSTINIT
|
||||
#endif
|
||||
|
||||
#define LOG_CHANNEL(ch, ...) LOG_CONSTINIT inline ::logs::channel ch(::logs::make_channel_name(#ch, ##__VA_ARGS__)); \
|
||||
namespace logs { inline ::logs::registerer reg_##ch{ch}; }
|
||||
|
||||
LOG_CHANNEL(rsx_log, "RSX");
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "Crypto/sha1.h"
|
||||
#include "Utilities/StrUtil.h"
|
||||
|
||||
LOG_CHANNEL(trp_log);
|
||||
LOG_CHANNEL(trp_log, "Trophy");
|
||||
|
||||
TRPLoader::TRPLoader(const fs::file& f)
|
||||
: trp_f(f)
|
||||
|
Loading…
Reference in New Issue
Block a user