From a4c845ab6c54172ea305f33734c83238c75d421a Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 3 Dec 2013 19:10:44 +0100 Subject: Use the logger everywhere --- src/xmpp/xmpp_component.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src/xmpp/xmpp_component.cpp') diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index 9245fde..5e65595 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -52,14 +53,14 @@ void XmppComponent::start() void XmppComponent::send_stanza(const Stanza& stanza) { - std::cout << "====== Sending ========" << std::endl; - std::cout << stanza.to_string() << std::endl; - this->send_data(stanza.to_string()); + std::string str = stanza.to_string(); + log_debug("XMPP SENDING: " << str); + this->send_data(std::move(str)); } void XmppComponent::on_connected() { - std::cout << "connected to XMPP server" << std::endl; + log_info("connected to XMPP server"); XmlNode node("stream:stream", nullptr); node["xmlns"] = COMPONENT_NS; node["xmlns:stream"] = STREAM_NS; @@ -69,7 +70,7 @@ void XmppComponent::on_connected() void XmppComponent::on_connection_close() { - std::cout << "XMPP server closed connection" << std::endl; + log_info("XMPP server closed connection"); } void XmppComponent::parse_in_buffer() @@ -80,15 +81,14 @@ void XmppComponent::parse_in_buffer() void XmppComponent::on_remote_stream_open(const XmlNode& node) { - std::cout << "====== DOCUMENT_OPEN =======" << std::endl; - std::cout << node.to_string() << std::endl; + log_debug("XMPP DOCUMENT OPEN: " << node.to_string()); try { this->stream_id = node["id"]; } catch (const AttributeNotFound& e) { - std::cout << "Error: no attribute 'id' found" << std::endl; + log_error("Error: no attribute 'id' found"); this->send_stream_error("bad-format", "missing 'id' attribute"); this->close_document(); return ; @@ -109,14 +109,12 @@ void XmppComponent::on_remote_stream_open(const XmlNode& node) void XmppComponent::on_remote_stream_close(const XmlNode& node) { - std::cout << "====== DOCUMENT_CLOSE =======" << std::endl; - std::cout << node.to_string() << std::endl; + log_debug("XMPP DOCUMENT CLOSE " << node.to_string()); } void XmppComponent::on_stanza(const Stanza& stanza) { - std::cout << "=========== STANZA ============" << std::endl; - std::cout << stanza.to_string() << std::endl; + log_debug("XMPP RECEIVING: " << stanza.to_string()); std::function handler; try { @@ -124,7 +122,7 @@ void XmppComponent::on_stanza(const Stanza& stanza) } catch (const std::out_of_range& exception) { - std::cout << "No handler for stanza of type " << stanza.get_name() << std::endl; + log_warning("No handler for stanza of type " << stanza.get_name()); return; } handler(stanza); @@ -145,8 +143,7 @@ void XmppComponent::send_stream_error(const std::string& name, const std::string void XmppComponent::close_document() { - std::cout << "====== Sending ========" << std::endl; - std::cout << "" << std::endl; + log_debug("XMPP SENDING: "); this->send_data(""); } -- cgit v1.2.3