IcingaDB: Log where we are connecting to

This commit is contained in:
Michael Friedrich 2019-11-02 15:43:58 +01:00
parent 2dbf5bd0d0
commit 36d18ed23a
1 changed files with 6 additions and 2 deletions

View File

@ -144,14 +144,18 @@ void RedisConnection::Connect(asio::yield_context& yc)
{
Defer notConnecting ([this]() { m_Connecting.store(m_Connected.load()); });
Log(LogInformation, "IcingaDB", "Trying to connect to Redis server (async)");
try {
if (m_Path.IsEmpty()) {
Log(LogInformation, "IcingaDB")
<< "Trying to connect to Redis server (async) on host '" << m_Host << ":" << m_Port << "'";
decltype(m_TcpConn) conn (new TcpConn(m_Strand.context()));
icinga::Connect(conn->next_layer(), m_Host, Convert::ToString(m_Port), yc);
m_TcpConn = std::move(conn);
} else {
Log(LogInformation, "IcingaDB")
<< "Trying to connect to Redis server (async) on unix socket path '" << m_Path << "'";
decltype(m_UnixConn) conn (new UnixConn(m_Strand.context()));
conn->next_layer().async_connect(Unix::endpoint(m_Path.CStr()), yc);
m_UnixConn = std::move(conn);