This commit is contained in:
Timur A. Fatkhullin
2024-11-12 01:00:22 +03:00
parent 6acc1f94ba
commit 9769c24005
6 changed files with 48 additions and 15 deletions

View File

@@ -21,12 +21,11 @@ ABSTRACT DEVICE COMPONENTS LIBRARY
namespace adc::spdlog
{
template <interfaces::adc_generic_netserver_c ServerT>
requires traits::formattable<typename ServerT::server_ident_t>
class AdcGenericNetServerSpdlog : public AdcSpdlogGenericMarkDecorator<ServerT>
template <traits::formattable IdentT = std::string>
class AdcGenericNetServerSpdlog : public AdcSpdlogGenericMarkDecorator<AdcGenericNetServer<IdentT>>
{
protected:
using base_t = AdcSpdlogGenericMarkDecorator<ServerT>;
using base_t = AdcSpdlogGenericMarkDecorator<AdcGenericNetServer<IdentT>>;
std::string _serverID;
@@ -36,7 +35,7 @@ protected:
}
public:
using typename ServerT::server_ident_t;
using typename base_t::server_ident_t;
using base_t::logCritical;
using base_t::logDebug;
@@ -53,7 +52,7 @@ public:
{
this->logMethodCalling(__PRETTY_FUNCTION__);
fmt::format_to(std::back_inserter(_serverID), "{}", ServerT::_serverIdent);
fmt::format_to(std::back_inserter(_serverID), "{}", base_t::_serverIdent);
this->setPattern(base_t::constructPattern(_serverID));
@@ -75,7 +74,7 @@ public:
{
this->logMethodCalling(__PRETTY_FUNCTION__);
return ServerT::ident();
return base_t::ident();
}
template <interfaces::adc_netsession_c SessionT, typename... AcceptorCtorArgTs>
@@ -89,7 +88,7 @@ public:
logInfo("Start accepting client connections for server session ID hash: {} ...", std::hash<SessionT>(id));
}
ServerT::start(std::move(id), std::move(sess_ctx), std::forward<AcceptorCtorArgTs>(ctor_args)...);
base_t::start(std::move(id), std::move(sess_ctx), std::forward<AcceptorCtorArgTs>(ctor_args)...);
}
virtual void stop()
@@ -98,7 +97,7 @@ public:
logInfo("Stopping network server ...");
ServerT::stop();
base_t::stop();
logInfo("Network server is stopped");
}
@@ -109,18 +108,17 @@ public:
{
this->logMethodCalling(__PRETTY_FUNCTION__);
ServerT::_isListening(id);
base_t::_isListening(id);
}
void daemonize()
requires std::derived_from<AdcPosixGenericDaemon, ServerT>
{
this->logMethodCalling(__PRETTY_FUNCTION__);
logInfo("Daemonizing server ...");
ServerT::daemonize();
base_t::daemonize();
logInfo("The server was daemonized");
}