mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-13 02:08:49 +12:00
Move logs::channel registration out of the constructor
Allow constinit initialization of logs::channel.
This commit is contained in:
parent
e57c01907e
commit
87a5dd66ab
3 changed files with 22 additions and 8 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue