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 ++++++++++++--------------- src/xmpp/xmpp_stanza.cpp | 5 ----- src/xmpp/xmpp_stanza.hpp | 1 - 3 files changed, 12 insertions(+), 21 deletions(-) (limited to 'src/xmpp') 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(""); } diff --git a/src/xmpp/xmpp_stanza.cpp b/src/xmpp/xmpp_stanza.cpp index 5af53e1..34ba85f 100644 --- a/src/xmpp/xmpp_stanza.cpp +++ b/src/xmpp/xmpp_stanza.cpp @@ -209,11 +209,6 @@ std::string XmlNode::to_string() const return res; } -void XmlNode::display() const -{ - std::cout << this->to_string() << std::endl; -} - bool XmlNode::has_children() const { return !this->children.empty(); diff --git a/src/xmpp/xmpp_stanza.hpp b/src/xmpp/xmpp_stanza.hpp index 87a80e9..d9bf81d 100644 --- a/src/xmpp/xmpp_stanza.hpp +++ b/src/xmpp/xmpp_stanza.hpp @@ -97,7 +97,6 @@ public: * Serialize the stanza into a string */ std::string to_string() const; - void display() const; /** * Whether or not this node has at least one child (if not, this is a leaf * node) -- cgit v1.2.3