0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-02 13:48:53 +02:00

ircd::log: Add assertion for log calls from non-main threads.

This commit is contained in:
Jason Volk 2017-03-23 14:59:38 -07:00
parent 1f6d83b5b1
commit 99d75648f0

View file

@ -73,6 +73,13 @@ static void open(const facility &fac);
static void prefix(const facility &fac, const char *const &date);
static void suffix(const facility &fac);
const auto main_thread_id
{
std::this_thread::get_id()
};
void thread_assertion();
} // namespace log
} // namespace ircd
@ -265,6 +272,8 @@ void
log::slog(const facility &fac,
const std::function<void (std::ostream &)> &closure)
{
void thread_assertion();
if(!file[fac].is_open() && !console_out[fac] && !console_err[fac])
return;
@ -367,7 +376,6 @@ log::reflect(const facility &f)
return "??????";
}
const char *
ircd::smalldate(const time_t &ltime)
{
@ -387,3 +395,10 @@ ircd::smalldate(const time_t &ltime)
return buf;
}
void
ircd::log::thread_assertion()
{
// Trying to log from another thread is not yet allowed
assert(std::this_thread::get_id() == main_thread_id);
}