0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 22:41:12 +01:00

ircd::mods: Minor cleanup.

This commit is contained in:
Jason Volk 2018-08-30 20:56:03 -07:00
parent 5f9c12bddc
commit 32a67c82c9

View file

@ -50,9 +50,13 @@ ircd::mods::available()
} }
catch(const filesystem::filesystem_error &e) catch(const filesystem::filesystem_error &e)
{ {
log.warning("Module path [%s]: %s", log::warning
{
log, "Module path [%s]: %s",
dir, dir,
e.what()); e.what()
};
continue; continue;
} }
@ -67,9 +71,12 @@ ircd::mods::fullpath(const string_view &name)
if(path.empty()) if(path.empty())
{ {
for(const auto &str : why) for(const auto &str : why)
log.error("candidate for module '%s' failed: %s", log::error
{
log, "candidate for module '%s' failed: %s",
name, name,
str); str
};
throw error throw error
{ {
@ -259,9 +266,12 @@ try
}; };
const auto path(fullpath(name)); const auto path(fullpath(name));
log.debug("Attempting to load '%s' @ `%s'", log::debug
{
log, "Attempting to load '%s' @ `%s'",
name, name,
path.string()); path.string()
};
const auto ret const auto ret
{ {
@ -274,10 +284,15 @@ try
if(ret->header->init) if(ret->header->init)
ret->header->init(); ret->header->init();
log.info("Loaded module %s v%u \"%s\"", log::info
{
log, "Loaded module %s v%u \"%s\"",
ret->name(), ret->name(),
ret->header->version, ret->header->version,
!ret->description().empty()? ret->description() : "<no description>"s); !ret->description().empty()?
ret->description():
"<no description>"s
};
return ret; return ret;
}()} }()}
@ -285,10 +300,12 @@ try
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
log.error("Failed to load '%s': %s", log::error
{
log, "Failed to load '%s': %s",
name, name,
e.what()); e.what()
throw; };
} }
ircd::string_view ircd::string_view
@ -579,7 +596,11 @@ try
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
log.error("Failed to add path: %s", e.what()); log::error
{
log, "Failed to add path: %s", e.what()
};
return false; return false;
} }
@ -664,7 +685,10 @@ try
const auto ours([] const auto ours([]
{ {
log.critical("std::terminate() called during the static construction of a module."); log::critical
{
log, "std::terminate() called during the static construction of a module."
};
if(std::current_exception()) try if(std::current_exception()) try
{ {
@ -672,7 +696,10 @@ try
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
log.error("%s", e.what()); log::error
{
log, "%s", e.what()
};
} }
}); });
@ -700,10 +727,13 @@ try
&handle.get<mapi::header>(mapi::header_symbol_name) &handle.get<mapi::header>(mapi::header_symbol_name)
} }
{ {
log.debug("Loaded static segment of '%s' @ `%s' with %zu symbols", log::debug
{
log, "Loaded static segment of '%s' @ `%s' with %zu symbols",
name(), name(),
location(), location(),
mangles.size()); mangles.size()
};
if(unlikely(!header)) if(unlikely(!header))
throw error throw error
@ -729,9 +759,12 @@ try
{ {
const auto &m(mod::loading.top()); const auto &m(mod::loading.top());
m->children.emplace_back(this); m->children.emplace_back(this);
log.debug("Module '%s' recursively loaded by '%s'", log::debug
{
log, "Module '%s' recursively loaded by '%s'",
name(), name(),
m->path.filename().string()); m->path.filename().string()
};
} }
// Without init exception, the module is now considered loaded. // Without init exception, the module is now considered loaded.
@ -776,9 +809,12 @@ bool ircd::mapi::static_destruction;
ircd::mods::mod::~mod() ircd::mods::mod::~mod()
noexcept try noexcept try
{ {
log.debug("Attempting unload module '%s' @ `%s'", log::debug
{
log, "Attempting unload module '%s' @ `%s'",
name(), name(),
location()); location()
};
unload(); unload();
@ -787,9 +823,12 @@ noexcept try
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
log.critical("Module @%p unload: %s", log::critical
{
log, "Module @%p unload: %s",
(const void *)this, (const void *)this,
e.what()); e.what()
};
if(!ircd::debugmode) if(!ircd::debugmode)
return; return;
@ -816,9 +855,12 @@ ircd::mods::mod::unload()
ptr->unload(); ptr->unload();
}); });
log.debug("Attempting static unload for '%s' @ `%s'", log::debug
{
log, "Attempting static unload for '%s' @ `%s'",
name(), name(),
location()); location()
};
mapi::static_destruction = false; mapi::static_destruction = false;
handle.unload(); handle.unload();
@ -828,9 +870,11 @@ ircd::mods::mod::unload()
{ {
log.critical("Module \"%s\" is stuck and failing to unload.", name()); log.critical("Module \"%s\" is stuck and failing to unload.", name());
log.critical("Module \"%s\" may result in undefined behavior if not fixed.", name()); log.critical("Module \"%s\" may result in undefined behavior if not fixed.", name());
} else {
log.info("Unloaded '%s'", name());
} }
else log::info
{
log, "Unloaded '%s'", name()
};
return true; return true;
} }