From f8f37ecbdd59e36dc4709d5a7a689369a2c371a3 Mon Sep 17 00:00:00 2001 From: HanzZ Date: Sun, 10 Jul 2011 12:38:26 +0200 Subject: [PATCH] Better logging in gateway mode --- src/transport.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/transport.cpp b/src/transport.cpp index 6385adb8..c46499d7 100644 --- a/src/transport.cpp +++ b/src/transport.cpp @@ -69,7 +69,7 @@ Component::Component(Swift::EventLoop *loop, Config *config, Factory *factory, T m_factories = new BoostNetworkFactories(loop); - m_reconnectTimer = m_factories->getTimerFactory()->createTimer(1000); + m_reconnectTimer = m_factories->getTimerFactory()->createTimer(3000); m_reconnectTimer->onTick.connect(bind(&Component::start, this)); if (CONFIG_BOOL(m_config, "service.server_mode")) { @@ -98,6 +98,7 @@ Component::Component(Swift::EventLoop *loop, Config *config, Factory *factory, T m_server->onDataWritten.connect(bind(&Component::handleDataWritten, this, _1)); } else { + LOG4CXX_INFO(logger, "Creating component in gateway mode"); m_component = new Swift::Component(loop, m_factories, m_jid, CONFIG_STRING(m_config, "service.password")); m_component->setSoftwareVersion("", ""); m_component->onConnected.connect(bind(&Component::handleConnected, this)); @@ -159,6 +160,7 @@ void Component::setBuddyFeatures(std::list &features) { void Component::start() { if (m_component) { + LOG4CXX_INFO(logger, "Connecting XMPP server " << CONFIG_STRING(m_config, "service.server") << " port " << CONFIG_INT(m_config, "service.port")); m_reconnectCount++; m_component->connect(CONFIG_STRING(m_config, "service.server"), CONFIG_INT(m_config, "service.port")); m_reconnectTimer->stop(); @@ -190,6 +192,17 @@ void Component::handleConnectionError(const ComponentError &error) { onConnectionError(error); // if (m_reconnectCount == 2) // Component::instance()->userManager()->removeAllUsers(); + std::string str = "Unknown error"; + switch (error.getType()) { + case ComponentError::UnknownError: str = "Unknown error"; break; + case ComponentError::ConnectionError: str = "Connection error"; break; + case ComponentError::ConnectionReadError: str = "Connection read error"; break; + case ComponentError::ConnectionWriteError: str = "Connection write error"; break; + case ComponentError::XMLError: str = "XML Error"; break; + case ComponentError::AuthenticationFailedError: str = "Authentication failed error"; break; + case ComponentError::UnexpectedElementError: str = "Unexpected element error"; break; + } + LOG4CXX_INFO(logger, "Disconnected from XMPP server. Error: " << str); m_reconnectTimer->start(); }