summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-12-03 19:10:44 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-12-03 19:15:37 +0100
commita4c845ab6c54172ea305f33734c83238c75d421a (patch)
tree3ed5393e993f0e9b72fabd9413453fadbfe9a9a9 /src/xmpp
parent2662ed89e2cd41477582140e482f1ddbbfdb235e (diff)
downloadbiboumi-a4c845ab6c54172ea305f33734c83238c75d421a.tar.gz
biboumi-a4c845ab6c54172ea305f33734c83238c75d421a.tar.bz2
biboumi-a4c845ab6c54172ea305f33734c83238c75d421a.tar.xz
biboumi-a4c845ab6c54172ea305f33734c83238c75d421a.zip
Use the logger everywhere
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/xmpp_component.cpp27
-rw-r--r--src/xmpp/xmpp_stanza.cpp5
-rw-r--r--src/xmpp/xmpp_stanza.hpp1
3 files changed, 12 insertions, 21 deletions
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 <utils/make_unique.hpp>
+#include <logger/logger.hpp>
#include <xmpp/xmpp_component.hpp>
#include <xmpp/jid.hpp>
@@ -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<void(const Stanza&)> 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 << "</stream:stream>" << std::endl;
+ log_debug("XMPP SENDING: </stream:stream>");
this->send_data("</stream:stream>");
}
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)