Inject logger instead of using a singleton

This commit is contained in:
2019-06-16 11:33:23 +02:00
parent 14740e4a64
commit 9ba225cbde
14 changed files with 76 additions and 56 deletions

View File

@@ -15,17 +15,18 @@ void HttpServer::Execute()
}
catch (std::runtime_error & e)
{
Logger::GetInstance().Info("Connection dropped on accept");
logger.Info("Connection dropped on accept");
}
}
}
HttpServer::HttpServer()
: listeningSocket(ServerConfiguration::GetInstance().GetPort()),
connectionOperator(),
HttpServer::HttpServer(Logger & _logger)
: logger(_logger),
listeningSocket(ServerConfiguration::GetInstance().GetPort()),
connectionOperator(_logger),
isOpen(true)
{
std::stringstream ss;
ss << "Listening on port " << ServerConfiguration::GetInstance().GetPort();
Logger::GetInstance().Info(ss.str());
logger.Info(ss.str());
}