mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 14:31:24 +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
|
@ -267,13 +267,11 @@ void logs::listener::add(logs::listener* _new)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logs::channel::channel(const char* name)
|
logs::registerer::registerer(channel& _ch)
|
||||||
: name(name)
|
|
||||||
, enabled(level::notice)
|
|
||||||
{
|
{
|
||||||
std::lock_guard lock(g_mutex);
|
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
|
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)
|
// The lowest logging level enabled for this channel (used for early filtering)
|
||||||
std::atomic<level> enabled;
|
std::atomic<level> enabled;
|
||||||
|
|
||||||
// Initialize and register channel
|
// Initialize channel
|
||||||
channel(const char* name);
|
constexpr channel(const char* name) noexcept
|
||||||
|
: name(name)
|
||||||
|
, enabled(level::notice)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#define GEN_LOG_METHOD(_sev)\
|
#define GEN_LOG_METHOD(_sev)\
|
||||||
const message msg_##_sev{this, level::_sev};\
|
const message msg_##_sev{this, level::_sev};\
|
||||||
|
@ -87,6 +91,11 @@ namespace logs
|
||||||
#undef GEN_LOG_METHOD
|
#undef GEN_LOG_METHOD
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct registerer
|
||||||
|
{
|
||||||
|
registerer(channel& _ch);
|
||||||
|
};
|
||||||
|
|
||||||
// Log level control: set all channels to level::notice
|
// Log level control: set all channels to level::notice
|
||||||
void reset();
|
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");
|
LOG_CHANNEL(rsx_log, "RSX");
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "Crypto/sha1.h"
|
#include "Crypto/sha1.h"
|
||||||
#include "Utilities/StrUtil.h"
|
#include "Utilities/StrUtil.h"
|
||||||
|
|
||||||
LOG_CHANNEL(trp_log);
|
LOG_CHANNEL(trp_log, "Trophy");
|
||||||
|
|
||||||
TRPLoader::TRPLoader(const fs::file& f)
|
TRPLoader::TRPLoader(const fs::file& f)
|
||||||
: trp_f(f)
|
: trp_f(f)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue