mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd:Ⓜ️🪝 Add integer for easier ident; improve log msgs; console cmd.
This commit is contained in:
parent
a247334744
commit
38a12ec0f7
3 changed files with 74 additions and 21 deletions
|
@ -67,6 +67,7 @@ struct ircd::m::hook::base
|
|||
size_t calling {0};
|
||||
|
||||
public:
|
||||
uint id() const;
|
||||
site *find_site() const;
|
||||
string_view site_name() const;
|
||||
|
||||
|
@ -93,6 +94,7 @@ struct ircd::m::hook::base::site
|
|||
size_t calling {0};
|
||||
|
||||
public:
|
||||
uint id() const;
|
||||
string_view name() const;
|
||||
|
||||
protected:
|
||||
|
@ -213,9 +215,10 @@ catch(const std::exception &e)
|
|||
|
||||
log::critical
|
||||
{
|
||||
log, "Unhandled hookfn(%p) %s error :%s",
|
||||
&hfn,
|
||||
log, "Unhandled site:%u hook:%u %s error :%s",
|
||||
id(),
|
||||
hfn.id(),
|
||||
string_view{hfn.feature},
|
||||
e.what()
|
||||
e.what(),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -291,6 +291,23 @@ const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
uint
|
||||
ircd::m::hook::base::id()
|
||||
const
|
||||
{
|
||||
uint ret(0);
|
||||
for(auto *const &hook : m::hook::base::list)
|
||||
if(hook != this)
|
||||
++ret;
|
||||
else
|
||||
return ret;
|
||||
|
||||
throw std::out_of_range
|
||||
{
|
||||
"Hook not found in instance list."
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// hook::site
|
||||
//
|
||||
|
@ -364,9 +381,12 @@ ircd::m::hook::base::site::add(base &hook)
|
|||
{
|
||||
log::warning
|
||||
{
|
||||
log, "Hook %p already registered to site %s",
|
||||
log, "Hook:%u (%p) already registered to site:%u (%p) :%s",
|
||||
hook.id(),
|
||||
&hook,
|
||||
name()
|
||||
id(),
|
||||
this,
|
||||
name(),
|
||||
};
|
||||
|
||||
return false;
|
||||
|
@ -385,9 +405,12 @@ ircd::m::hook::base::site::add(base &hook)
|
|||
|
||||
log::debug
|
||||
{
|
||||
log, "Registered hook %p to site %s",
|
||||
log, "Registered hook:%u (%p) to site:%u (%p) :%s",
|
||||
hook.id(),
|
||||
&hook,
|
||||
name()
|
||||
id(),
|
||||
this,
|
||||
name(),
|
||||
};
|
||||
|
||||
return true;
|
||||
|
@ -398,9 +421,12 @@ ircd::m::hook::base::site::del(base &hook)
|
|||
{
|
||||
log::debug
|
||||
{
|
||||
log, "Removing hook %p from site %s",
|
||||
log, "Removing hook:%u (%p) from site:%u (%p) :%s",
|
||||
hook.id(),
|
||||
&hook,
|
||||
name()
|
||||
id(),
|
||||
this,
|
||||
name(),
|
||||
};
|
||||
|
||||
assert(hook.registered);
|
||||
|
@ -439,6 +465,22 @@ catch(const std::out_of_range &e)
|
|||
};
|
||||
}
|
||||
|
||||
uint
|
||||
ircd::m::hook::base::site::id()
|
||||
const
|
||||
{
|
||||
uint ret(0);
|
||||
for(auto *const &site : m::hook::base::site::list)
|
||||
if(site != this)
|
||||
++ret;
|
||||
else
|
||||
return ret;
|
||||
|
||||
throw std::out_of_range
|
||||
{
|
||||
"Hook site not found in instance list."
|
||||
};
|
||||
}
|
||||
//
|
||||
// hook<void>
|
||||
//
|
||||
|
@ -502,10 +544,11 @@ catch(const std::exception &e)
|
|||
|
||||
log::critical
|
||||
{
|
||||
log, "Unhandled hookfn(%p) %s error :%s",
|
||||
&hfn,
|
||||
log, "Unhandled site:%u hook:%u %s error :%s",
|
||||
this->id(),
|
||||
hfn.id(),
|
||||
string_view{hfn.feature},
|
||||
e.what()
|
||||
e.what(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2082,18 +2082,25 @@ console_cmd__hook__list(opt &out, const string_view &line)
|
|||
{
|
||||
for(const auto &site : m::hook::base::site::list)
|
||||
{
|
||||
out << std::setw(24) << std::left << site->name()
|
||||
<< std::endl;
|
||||
|
||||
out << string_view{site->feature}
|
||||
<< std::endl;
|
||||
out
|
||||
<< std::setw(24) << std::left << site->name() << ':'
|
||||
<< std::endl
|
||||
<< string_view{site->feature}
|
||||
<< std::endl
|
||||
<< std::endl
|
||||
;
|
||||
|
||||
for(const auto &hookp : site->hooks)
|
||||
out << (hookp->registered? '+' : '-')
|
||||
<< " " << string_view{hookp->feature}
|
||||
<< std::endl;
|
||||
out
|
||||
<< std::setw(4) << std::right << hookp->id()
|
||||
<< " " << (hookp->registered? '+' : '-')
|
||||
<< " " << string_view{hookp->feature}
|
||||
<< std::endl
|
||||
;
|
||||
|
||||
out << std::endl;
|
||||
out
|
||||
<< std::endl
|
||||
;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue