From 57eb5cdb61b34a83030eee6a3fe2973d2c2fd48f Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Wed, 25 May 2016 16:04:15 +0200
Subject: Remove unnecessary include of iostream header

Move std::cout/cerr logging to SWIFT_LOG.

Test-Information:

Builds and all tests pass on OS X 10.11.5.

Change-Id: I0a0c24654a8b3abf3244a79fd6d970eee90559d0

diff --git a/Slimber/MainController.cpp b/Slimber/MainController.cpp
index 90a1b94..dcec6d5 100644
--- a/Slimber/MainController.cpp
+++ b/Slimber/MainController.cpp
@@ -6,8 +6,6 @@
 
 #include <Slimber/MainController.h>
 
-#include <iostream>
-
 #include <boost/bind.hpp>
 #include <boost/lexical_cast.hpp>
 
diff --git a/Slimber/MenuletController.cpp b/Slimber/MenuletController.cpp
index 5868128..fdf2fc7 100644
--- a/Slimber/MenuletController.cpp
+++ b/Slimber/MenuletController.cpp
@@ -6,7 +6,6 @@
 
 #include <Slimber/MenuletController.h>
 
-#include <iostream>
 #include <string>
 
 #include <Swiften/Base/foreach.h>
diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp
index ff5f883..7e24abe 100644
--- a/Slimber/Server.cpp
+++ b/Slimber/Server.cpp
@@ -6,11 +6,11 @@
 
 #include <Slimber/Server.h>
 
-#include <iostream>
 #include <string>
 
 #include <boost/bind.hpp>
 
+#include <Swiften/Base/Log.h>
 #include <Swiften/Base/String.h>
 #include <Swiften/Base/foreach.h>
 #include <Swiften/Elements/IQ.h>
@@ -306,7 +306,7 @@ void Server::handleLinkLocalElementReceived(std::shared_ptr<ToplevelElement> ele
 
 void Server::handleConnectFinished(std::shared_ptr<LinkLocalConnector> connector, bool error) {
     if (error) {
-        std::cerr << "Error connecting" << std::endl;
+        SWIFT_LOG(warning) << "Error connecting" << std::endl;
         // TODO: Send back queued stanzas
     }
     else {
diff --git a/Sluift/ElementConvertors/DOMElementConvertor.cpp b/Sluift/ElementConvertors/DOMElementConvertor.cpp
index 1e0e1bb..c03eb8c 100644
--- a/Sluift/ElementConvertors/DOMElementConvertor.cpp
+++ b/Sluift/ElementConvertors/DOMElementConvertor.cpp
@@ -6,7 +6,6 @@
 
 #include <Sluift/ElementConvertors/DOMElementConvertor.h>
 
-#include <iostream>
 #include <memory>
 
 #include <lua.hpp>
diff --git a/Sluift/ElementConvertors/DefaultElementConvertor.cpp b/Sluift/ElementConvertors/DefaultElementConvertor.cpp
index f422139..75e6706 100644
--- a/Sluift/ElementConvertors/DefaultElementConvertor.cpp
+++ b/Sluift/ElementConvertors/DefaultElementConvertor.cpp
@@ -6,10 +6,11 @@
 
 #include <Sluift/ElementConvertors/DefaultElementConvertor.h>
 
-#include <iostream>
 #include <string>
 #include <typeinfo>
 
+#include <Swiften/Base/Log.h>
+
 using namespace Swift;
 
 DefaultElementConvertor::DefaultElementConvertor() {
@@ -19,7 +20,7 @@ DefaultElementConvertor::~DefaultElementConvertor() {
 }
 
 std::shared_ptr<Element> DefaultElementConvertor::convertFromLua(lua_State*, int, const std::string& type) {
-    std::cerr << "Warning: Unable to convert type '" << type << "'" << std::endl;
+    SWIFT_LOG(warning) << "Unable to convert type '" << type << "'" << std::endl;
     return std::shared_ptr<Element>();
 }
 
diff --git a/Sluift/ElementConvertors/RawXMLElementConvertor.cpp b/Sluift/ElementConvertors/RawXMLElementConvertor.cpp
index a8ccb91..9688677 100644
--- a/Sluift/ElementConvertors/RawXMLElementConvertor.cpp
+++ b/Sluift/ElementConvertors/RawXMLElementConvertor.cpp
@@ -6,7 +6,6 @@
 
 #include <Sluift/ElementConvertors/RawXMLElementConvertor.h>
 
-#include <iostream>
 #include <memory>
 
 #include <lua.hpp>
diff --git a/Sluift/Lua/Check.cpp b/Sluift/Lua/Check.cpp
index 74a247a..b956623 100644
--- a/Sluift/Lua/Check.cpp
+++ b/Sluift/Lua/Check.cpp
@@ -6,7 +6,6 @@
 
 #include <Sluift/Lua/Check.h>
 
-#include <iostream>
 #include <sstream>
 
 #include <boost/numeric/conversion/cast.hpp>
diff --git a/Sluift/Lua/LuaUtils.cpp b/Sluift/Lua/LuaUtils.cpp
index 1088624..c677381 100644
--- a/Sluift/Lua/LuaUtils.cpp
+++ b/Sluift/Lua/LuaUtils.cpp
@@ -7,7 +7,6 @@
 #include <Sluift/Lua/LuaUtils.h>
 
 #include <cassert>
-#include <iostream>
 #include <sstream>
 
 #include <boost/algorithm/string/trim.hpp>
diff --git a/Sluift/client.cpp b/Sluift/client.cpp
index f82d314..7d0924f 100644
--- a/Sluift/client.cpp
+++ b/Sluift/client.cpp
@@ -4,8 +4,6 @@
  * See the COPYING file for more information.
  */
 
-#include <iostream>
-
 #include <boost/assign/list_of.hpp>
 #include <boost/lambda/bind.hpp>
 #include <boost/lambda/lambda.hpp>
diff --git a/Sluift/component.cpp b/Sluift/component.cpp
index 0196a09..9c2bc3a 100644
--- a/Sluift/component.cpp
+++ b/Sluift/component.cpp
@@ -4,8 +4,6 @@
  * See the COPYING file for more information.
  */
 
-#include <iostream>
-
 #include <boost/assign/list_of.hpp>
 #include <boost/lambda/bind.hpp>
 #include <boost/lambda/lambda.hpp>
diff --git a/SwifTools/Application/ApplicationPathProvider.cpp b/SwifTools/Application/ApplicationPathProvider.cpp
index 3a86f28..a5080f9 100644
--- a/SwifTools/Application/ApplicationPathProvider.cpp
+++ b/SwifTools/Application/ApplicationPathProvider.cpp
@@ -6,10 +6,9 @@
 
 #include <SwifTools/Application/ApplicationPathProvider.h>
 
-#include <iostream>
-
 #include <boost/filesystem.hpp>
 
+#include <Swiften/Base/Log.h>
 #include <Swiften/Base/Paths.h>
 #include <Swiften/Base/foreach.h>
 
@@ -27,7 +26,7 @@ boost::filesystem::path ApplicationPathProvider::getProfileDir(const std::string
         boost::filesystem::create_directory(result);
     }
     catch (const boost::filesystem::filesystem_error& e) {
-        std::cerr << "ERROR: " << e.what() << std::endl;
+        SWIFT_LOG(error) << e.what() << std::endl;
     }
     return result;
 }
diff --git a/SwifTools/Application/MacOSXApplicationPathProvider.cpp b/SwifTools/Application/MacOSXApplicationPathProvider.cpp
index 086bbaa..684d8b2 100644
--- a/SwifTools/Application/MacOSXApplicationPathProvider.cpp
+++ b/SwifTools/Application/MacOSXApplicationPathProvider.cpp
@@ -6,10 +6,10 @@
 
 #include <SwifTools/Application/MacOSXApplicationPathProvider.h>
 
-#include <iostream>
-
 #include <mach-o/dyld.h>
 
+#include <Swiften/Base/Log.h>
+
 namespace Swift {
 
 MacOSXApplicationPathProvider::MacOSXApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) {
@@ -23,7 +23,7 @@ boost::filesystem::path MacOSXApplicationPathProvider::getDataDir() const {
         boost::filesystem::create_directory(result);
     }
     catch (const boost::filesystem::filesystem_error& e) {
-        std::cerr << "ERROR: " << e.what() << std::endl;
+        SWIFT_LOG(error) << e.what() << std::endl;
     }
     return result;
 }
diff --git a/Swiften/Client/ClientSessionStanzaChannel.cpp b/Swiften/Client/ClientSessionStanzaChannel.cpp
index f1cba5d..f48b306 100644
--- a/Swiften/Client/ClientSessionStanzaChannel.cpp
+++ b/Swiften/Client/ClientSessionStanzaChannel.cpp
@@ -6,10 +6,10 @@
 
 #include <Swiften/Client/ClientSessionStanzaChannel.h>
 
-#include <iostream>
-
 #include <boost/bind.hpp>
 
+#include <Swiften/Base/Log.h>
+
 namespace Swift {
 
 ClientSessionStanzaChannel::~ClientSessionStanzaChannel() {
@@ -49,7 +49,7 @@ std::string ClientSessionStanzaChannel::getNewIQID() {
 
 void ClientSessionStanzaChannel::send(std::shared_ptr<Stanza> stanza) {
     if (!isAvailable()) {
-        std::cerr << "Warning: Client: Trying to send a stanza while disconnected." << std::endl;
+        SWIFT_LOG(warning) << "Client: Trying to send a stanza while disconnected." << std::endl;
         return;
     }
     session->sendStanza(stanza);
diff --git a/Swiften/Component/ComponentConnector.cpp b/Swiften/Component/ComponentConnector.cpp
index 632eb84..a7375a7 100644
--- a/Swiften/Component/ComponentConnector.cpp
+++ b/Swiften/Component/ComponentConnector.cpp
@@ -6,8 +6,6 @@
 
 #include <Swiften/Component/ComponentConnector.h>
 
-#include <iostream>
-
 #include <boost/bind.hpp>
 
 #include <Swiften/Network/ConnectionFactory.h>
diff --git a/Swiften/Component/ComponentSessionStanzaChannel.cpp b/Swiften/Component/ComponentSessionStanzaChannel.cpp
index 282d9f1..fd61594 100644
--- a/Swiften/Component/ComponentSessionStanzaChannel.cpp
+++ b/Swiften/Component/ComponentSessionStanzaChannel.cpp
@@ -6,10 +6,10 @@
 
 #include <Swiften/Component/ComponentSessionStanzaChannel.h>
 
-#include <iostream>
-
 #include <boost/bind.hpp>
 
+#include <Swiften/Base/Log.h>
+
 namespace Swift {
 
 void ComponentSessionStanzaChannel::setSession(std::shared_ptr<ComponentSession> session) {
@@ -38,7 +38,7 @@ std::string ComponentSessionStanzaChannel::getNewIQID() {
 
 void ComponentSessionStanzaChannel::send(std::shared_ptr<Stanza> stanza) {
     if (!isAvailable()) {
-        std::cerr << "Warning: Component: Trying to send a stanza while disconnected." << std::endl;
+        SWIFT_LOG(warning) << "Component: Trying to send a stanza while disconnected." << std::endl;
         return;
     }
     session->sendStanza(stanza);
diff --git a/Swiften/Component/CoreComponent.cpp b/Swiften/Component/CoreComponent.cpp
index dfa0896..3896bdd 100644
--- a/Swiften/Component/CoreComponent.cpp
+++ b/Swiften/Component/CoreComponent.cpp
@@ -6,11 +6,10 @@
 
 #include <Swiften/Component/CoreComponent.h>
 
-#include <iostream>
-
 #include <boost/bind.hpp>
 
 #include <Swiften/Base/IDGenerator.h>
+#include <Swiften/Base/Log.h>
 #include <Swiften/Component/ComponentSession.h>
 #include <Swiften/Component/ComponentSessionStanzaChannel.h>
 #include <Swiften/Network/Connector.h>
@@ -34,7 +33,7 @@ CoreComponent::CoreComponent(const JID& jid, const std::string& secret, NetworkF
 
 CoreComponent::~CoreComponent() {
     if (session_ || connection_) {
-        std::cerr << "Warning: Component not disconnected properly" << std::endl;
+        SWIFT_LOG(warning) << "Component not disconnected properly" << std::endl;
     }
     delete iqRouter_;
 
diff --git a/Swiften/Disco/CapsManager.cpp b/Swiften/Disco/CapsManager.cpp
index 337bad6..794cf74 100644
--- a/Swiften/Disco/CapsManager.cpp
+++ b/Swiften/Disco/CapsManager.cpp
@@ -6,10 +6,9 @@
 
 #include <Swiften/Disco/CapsManager.h>
 
-#include <iostream>
-
 #include <boost/bind.hpp>
 
+#include <Swiften/Base/Log.h>
 #include <Swiften/Client/StanzaChannel.h>
 #include <Swiften/Disco/CapsInfoGenerator.h>
 #include <Swiften/Disco/CapsStorage.h>
@@ -54,7 +53,7 @@ void CapsManager::handleDiscoInfoReceived(const JID& from, const std::string& ha
     requestedDiscoInfos.erase(hash);
     if (error || !discoInfo || CapsInfoGenerator("", crypto).generateCapsInfo(*discoInfo.get()).getVersion() != hash) {
         if (warnOnInvalidHash && !error &&  discoInfo) {
-            std::cerr << "Warning: Caps from " << from.toString() << " do not verify" << std::endl;
+            SWIFT_LOG(warning) << "Caps from " << from.toString() << " do not verify" << std::endl;
         }
         failingCaps.insert(std::make_pair(from, hash));
         std::map<std::string, std::set< std::pair<JID, std::string> > >::iterator i = fallbacks.find(hash);
diff --git a/Swiften/Disco/DummyEntityCapsProvider.cpp b/Swiften/Disco/DummyEntityCapsProvider.cpp
index 6e9d898..fce38fe 100644
--- a/Swiften/Disco/DummyEntityCapsProvider.cpp
+++ b/Swiften/Disco/DummyEntityCapsProvider.cpp
@@ -1,13 +1,11 @@
 /*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
  * All rights reserved.
  * See the COPYING file for more information.
  */
 
 #include <Swiften/Disco/DummyEntityCapsProvider.h>
 
-#include <iostream>
-
 namespace Swift {
 
 DiscoInfo::ref DummyEntityCapsProvider::getCaps(const JID& jid) const {
diff --git a/Swiften/Elements/Whiteboard/WhiteboardColor.cpp b/Swiften/Elements/Whiteboard/WhiteboardColor.cpp
index 6bf7e03..037fde4 100644
--- a/Swiften/Elements/Whiteboard/WhiteboardColor.cpp
+++ b/Swiften/Elements/Whiteboard/WhiteboardColor.cpp
@@ -14,7 +14,6 @@
 
 #include <cstdio>
 #include <iomanip>
-#include <iostream>
 #include <sstream>
 
 #include <Swiften/Base/String.h>
diff --git a/Swiften/Entity/PayloadPersister.cpp b/Swiften/Entity/PayloadPersister.cpp
index 4b3fb52..3fd246c 100644
--- a/Swiften/Entity/PayloadPersister.cpp
+++ b/Swiften/Entity/PayloadPersister.cpp
@@ -6,12 +6,11 @@
 
 #include <Swiften/Entity/PayloadPersister.h>
 
-#include <iostream>
-
 #include <boost/filesystem.hpp>
 #include <boost/filesystem/fstream.hpp>
 
 #include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/Log.h>
 #include <Swiften/Parser/PayloadParser.h>
 #include <Swiften/Parser/PayloadParserFactory.h>
 #include <Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h>
@@ -35,7 +34,7 @@ void PayloadPersister::savePayload(std::shared_ptr<Payload> payload, const boost
         file.close();
     }
     catch (const boost::filesystem::filesystem_error& e) {
-        std::cerr << "ERROR: " << e.what() << std::endl;
+        SWIFT_LOG(error) << e.what() << std::endl;
     }
 }
 
@@ -51,7 +50,7 @@ std::shared_ptr<Payload> PayloadPersister::loadPayload(const boost::filesystem::
         }
     }
     catch (const boost::filesystem::filesystem_error& e) {
-        std::cerr << "ERROR: " << e.what() << std::endl;
+        SWIFT_LOG(error) << e.what() << std::endl;
     }
     return std::shared_ptr<Payload>();
 }
diff --git a/Swiften/JID/JID.cpp b/Swiften/JID/JID.cpp
index 6825443..54084d6 100644
--- a/Swiften/JID/JID.cpp
+++ b/Swiften/JID/JID.cpp
@@ -8,7 +8,6 @@
 
 #include <vector>
 #include <list>
-#include <iostream>
 
 #include <string>
 #ifdef SWIFTEN_CACHE_JID_PREP
@@ -19,7 +18,6 @@
 #include <boost/algorithm/string/find_format.hpp>
 #include <boost/algorithm/string/finder.hpp>
 #include <boost/optional.hpp>
-#include <iostream>
 #include <sstream>
 
 #include <Swiften/Base/String.h>
diff --git a/Swiften/MUC/MUCBookmarkManager.cpp b/Swiften/MUC/MUCBookmarkManager.cpp
index 602e876..a06a0a2 100644
--- a/Swiften/MUC/MUCBookmarkManager.cpp
+++ b/Swiften/MUC/MUCBookmarkManager.cpp
@@ -6,7 +6,6 @@
 
 #include <Swiften/MUC/MUCBookmarkManager.h>
 
-#include <iostream>
 #include <memory>
 
 #include <boost/bind.hpp>
diff --git a/Swiften/Network/UnixProxyProvider.cpp b/Swiften/Network/UnixProxyProvider.cpp
index 848de52..6c23add 100644
--- a/Swiften/Network/UnixProxyProvider.cpp
+++ b/Swiften/Network/UnixProxyProvider.cpp
@@ -10,12 +10,9 @@
  * See the COPYING file for more information.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <iostream>
+#include <Swiften/Network/UnixProxyProvider.h>
 
 #include <Swiften/Base/foreach.h>
-#include <Swiften/Network/UnixProxyProvider.h>
 #if defined(HAVE_GCONF)
 #  include "Swiften/Network/GConfProxyProvider.h"
 #endif
diff --git a/Swiften/Network/WindowsProxyProvider.cpp b/Swiften/Network/WindowsProxyProvider.cpp
index 8f90d1e..75e087a 100644
--- a/Swiften/Network/WindowsProxyProvider.cpp
+++ b/Swiften/Network/WindowsProxyProvider.cpp
@@ -16,15 +16,13 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <iostream>
-
 #include <boost/lexical_cast.hpp>
 
 #include <windows.h>
 
 #include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/Log.h>
 #include <Swiften/Base/foreach.h>
-#include <Swiften/Base/log.h>
 
 namespace Swift {
 
@@ -86,7 +84,7 @@ HostAddressPort WindowsProxyProvider::getAsHostAddressPort(std::string proxy) {
         ret = HostAddressPort(HostAddress(tmp.first), port);
     }
     catch(...) {
-            std::cerr << "Exception occured while parsing windows proxy \"getHostAddressPort\"." << std::endl;
+            SWIFT_LOG(error) << "Exception occured while parsing windows proxy \"getHostAddressPort\"." << std::endl;
     }
 
     return ret;
diff --git a/Swiften/Parser/ExpatParser.cpp b/Swiften/Parser/ExpatParser.cpp
index fba82e2..2a6b227 100644
--- a/Swiften/Parser/ExpatParser.cpp
+++ b/Swiften/Parser/ExpatParser.cpp
@@ -1,14 +1,15 @@
 /*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
  * All rights reserved.
  * See the COPYING file for more information.
  */
 
 #include <Swiften/Parser/ExpatParser.h>
 
-#include <iostream>
 #include <string>
+
 #include <expat.h>
+
 #include <boost/numeric/conversion/cast.hpp>
 
 #include <Swiften/Base/String.h>
diff --git a/Swiften/Parser/IQParser.cpp b/Swiften/Parser/IQParser.cpp
index 573ce07..5cfae34 100644
--- a/Swiften/Parser/IQParser.cpp
+++ b/Swiften/Parser/IQParser.cpp
@@ -6,10 +6,10 @@
 
 #include <Swiften/Parser/IQParser.h>
 
-#include <iostream>
-
 #include <boost/optional.hpp>
 
+#include <Swiften/Base/Log.h>
+
 namespace Swift {
 
 IQParser::IQParser(PayloadParserFactoryCollection* factories) :
@@ -32,7 +32,7 @@ void IQParser::handleStanzaAttributes(const AttributeMap& attributes) {
             getStanzaGeneric()->setType(IQ::Error);
         }
         else {
-            std::cerr << "Unknown IQ type: " << *type << std::endl;
+            SWIFT_LOG(warning) << "Unknown IQ type: " << *type << std::endl;
             getStanzaGeneric()->setType(IQ::Get);
         }
     }
diff --git a/Swiften/Parser/LibXMLParser.cpp b/Swiften/Parser/LibXMLParser.cpp
index 10de4f8..a880141 100644
--- a/Swiften/Parser/LibXMLParser.cpp
+++ b/Swiften/Parser/LibXMLParser.cpp
@@ -8,13 +8,13 @@
 
 #include <cassert>
 #include <cstring>
-#include <iostream>
 #include <string>
 
 #include <boost/numeric/conversion/cast.hpp>
 
 #include <libxml/parser.h>
 
+#include <Swiften/Base/Log.h>
 #include <Swiften/Parser/XMLParserClient.h>
 
 namespace Swift {
@@ -28,7 +28,7 @@ static void handleStartElement(void* parser, const xmlChar* name, const xmlChar*
     AttributeMap attributeValues;
     if (nbDefaulted != 0) {
         // Just because i don't understand what this means yet :-)
-        std::cerr << "Unexpected nbDefaulted on XML element" << std::endl;
+        SWIFT_LOG(error) << "Unexpected nbDefaulted on XML element" << std::endl;
     }
     for (int i = 0; i < nbAttributes*5; i += 5) {
         std::string attributeNS = "";
diff --git a/Swiften/Parser/PayloadParsers/FormParser.cpp b/Swiften/Parser/PayloadParsers/FormParser.cpp
index 4a0a26f..5ea75c5 100644
--- a/Swiften/Parser/PayloadParsers/FormParser.cpp
+++ b/Swiften/Parser/PayloadParsers/FormParser.cpp
@@ -5,7 +5,6 @@
  */
 #include <Swiften/Parser/PayloadParsers/FormParser.h>
 
-#include <iostream>
 #include <map>
 
 #include <Swiften/Base/foreach.h>
diff --git a/Swiften/Parser/PayloadParsers/MUCItemParser.cpp b/Swiften/Parser/PayloadParsers/MUCItemParser.cpp
index 0486cb4..ce74671 100644
--- a/Swiften/Parser/PayloadParsers/MUCItemParser.cpp
+++ b/Swiften/Parser/PayloadParsers/MUCItemParser.cpp
@@ -7,7 +7,6 @@
 #include <Swiften/Parser/PayloadParsers/MUCItemParser.h>
 
 #include <cassert>
-#include <iostream>
 
 #include <boost/lexical_cast.hpp>
 
diff --git a/Swiften/Parser/PresenceParser.cpp b/Swiften/Parser/PresenceParser.cpp
index 4a27a24..0235a12 100644
--- a/Swiften/Parser/PresenceParser.cpp
+++ b/Swiften/Parser/PresenceParser.cpp
@@ -6,10 +6,10 @@
 
 #include <Swiften/Parser/PresenceParser.h>
 
-#include <iostream>
-
 #include <boost/optional.hpp>
 
+#include <Swiften/Base/Log.h>
+
 namespace Swift {
 
 PresenceParser::PresenceParser(PayloadParserFactoryCollection* factories) :
@@ -41,7 +41,7 @@ void PresenceParser::handleStanzaAttributes(const AttributeMap& attributes) {
             getStanzaGeneric()->setType(Presence::Error);
         }
         else {
-            std::cerr << "Unknown Presence type: " << *type << std::endl;
+            SWIFT_LOG(error) << "Unknown Presence type: " << *type << std::endl;
             getStanzaGeneric()->setType(Presence::Available);
         }
     }
diff --git a/Swiften/Parser/StanzaParser.cpp b/Swiften/Parser/StanzaParser.cpp
index da252bf..8be4103 100644
--- a/Swiften/Parser/StanzaParser.cpp
+++ b/Swiften/Parser/StanzaParser.cpp
@@ -7,7 +7,6 @@
 #include <Swiften/Parser/StanzaParser.h>
 
 #include <cassert>
-#include <iostream>
 
 #include <boost/optional.hpp>
 
diff --git a/Swiften/Parser/Tree/ParserElement.cpp b/Swiften/Parser/Tree/ParserElement.cpp
index 27bd790..5415945 100644
--- a/Swiften/Parser/Tree/ParserElement.cpp
+++ b/Swiften/Parser/Tree/ParserElement.cpp
@@ -7,8 +7,6 @@
 
 #include <Swiften/Parser/Tree/ParserElement.h>
 
-#include <iostream>
-
 #include <boost/lambda/bind.hpp>
 #include <boost/lambda/lambda.hpp>
 
diff --git a/Swiften/Parser/XMPPParser.cpp b/Swiften/Parser/XMPPParser.cpp
index 29c02a0..2b45a12 100644
--- a/Swiften/Parser/XMPPParser.cpp
+++ b/Swiften/Parser/XMPPParser.cpp
@@ -7,7 +7,6 @@
 #include <Swiften/Parser/XMPPParser.h>
 
 #include <cassert>
-#include <iostream>
 #include <string>
 
 #include <Swiften/Elements/ProtocolHeader.h>
diff --git a/Swiften/Roster/XMPPRosterController.cpp b/Swiften/Roster/XMPPRosterController.cpp
index b5e72f5..57b0645 100644
--- a/Swiften/Roster/XMPPRosterController.cpp
+++ b/Swiften/Roster/XMPPRosterController.cpp
@@ -6,10 +6,9 @@
 
 #include <Swiften/Roster/XMPPRosterController.h>
 
-#include <iostream>
-
 #include <boost/bind.hpp>
 
+#include <Swiften/Base/Log.h>
 #include <Swiften/Base/foreach.h>
 #include <Swiften/Elements/RosterItemPayload.h>
 #include <Swiften/Queries/IQRouter.h>
@@ -68,7 +67,7 @@ void XMPPRosterController::handleRosterReceived(std::shared_ptr<RosterPayload> r
                 xmppRoster_->addContact(item.getJID(), item.getName(), item.getGroups(), item.getSubscription());
             }
             else {
-                std::cerr << "ERROR: Stored invalid roster item" << std::endl;
+                SWIFT_LOG(error) << "Stored invalid roster item" << std::endl;
             }
         }
     }
diff --git a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp
index 9a05431..ed010b4 100644
--- a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp
@@ -6,7 +6,6 @@
 
 #include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
 
-#include <iostream>
 #include <memory>
 #include <string>
 
diff --git a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp
index 5aebca3..34fd149 100644
--- a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp
@@ -12,11 +12,11 @@
 
 #include <Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h>
 
-#include <iostream>
 #include <memory>
 
 #include <boost/lexical_cast.hpp>
 
+#include <Swiften/Base/Log.h>
 #include <Swiften/Elements/Whiteboard/WhiteboardDeleteOperation.h>
 #include <Swiften/Elements/Whiteboard/WhiteboardInsertOperation.h>
 #include <Swiften/Elements/Whiteboard/WhiteboardUpdateOperation.h>
@@ -199,7 +199,7 @@ namespace Swift {
             case WhiteboardPayload::SessionTerminate:
                 return "session-terminate";
             case WhiteboardPayload::UnknownType:
-                std::cerr << "Warning: Serializing unknown action value." << std::endl;
+                SWIFT_LOG(warning) << "Serializing unknown action value." << std::endl;
                 return "";
         }
         assert(false);
diff --git a/Swiften/Serializer/StanzaSerializer.cpp b/Swiften/Serializer/StanzaSerializer.cpp
index de1e8f1..6440fbb 100644
--- a/Swiften/Serializer/StanzaSerializer.cpp
+++ b/Swiften/Serializer/StanzaSerializer.cpp
@@ -6,10 +6,10 @@
 
 #include <Swiften/Serializer/StanzaSerializer.h>
 
-#include <iostream>
 #include <sstream>
 #include <typeinfo>
 
+#include <Swiften/Base/Log.h>
 #include <Swiften/Base/foreach.h>
 #include <Swiften/Elements/Stanza.h>
 #include <Swiften/Serializer/PayloadSerializer.h>
@@ -53,7 +53,7 @@ SafeByteArray StanzaSerializer::serialize(std::shared_ptr<ToplevelElement> eleme
             serializedPayloads += serializer->serialize(payload);
         }
         else {
-            std::cerr << "Could not find serializer for " << typeid(*(payload.get())).name() << std::endl;
+            SWIFT_LOG(warning) << "Could not find serializer for " << typeid(*(payload.get())).name() << std::endl;
         }
     }
     if (!serializedPayloads.empty()) {
diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp
index 8b2fd5c..08b5485 100644
--- a/Swiften/Serializer/XMPPSerializer.cpp
+++ b/Swiften/Serializer/XMPPSerializer.cpp
@@ -7,11 +7,11 @@
 #include <Swiften/Serializer/XMPPSerializer.h>
 
 #include <cassert>
-#include <iostream>
 #include <memory>
 
 #include <boost/bind.hpp>
 
+#include <Swiften/Base/Log.h>
 #include <Swiften/Base/foreach.h>
 #include <Swiften/Elements/ProtocolHeader.h>
 #include <Swiften/Serializer/AuthChallengeSerializer.h>
@@ -90,7 +90,7 @@ SafeByteArray XMPPSerializer::serializeElement(std::shared_ptr<ToplevelElement>
         return (*i)->serialize(element);
     }
     else {
-        std::cerr << "Could not find serializer for " << typeid(*(element.get())).name() << std::endl;
+        SWIFT_LOG(warning) << "Could not find serializer for " << typeid(*(element.get())).name() << std::endl;
         return createSafeByteArray("");
     }
 }
diff --git a/Swiften/StreamManagement/StanzaAckRequester.cpp b/Swiften/StreamManagement/StanzaAckRequester.cpp
index 8e9e7f3..8941f4a 100644
--- a/Swiften/StreamManagement/StanzaAckRequester.cpp
+++ b/Swiften/StreamManagement/StanzaAckRequester.cpp
@@ -6,10 +6,9 @@
 
 #include <Swiften/StreamManagement/StanzaAckRequester.h>
 
-#include <iostream>
-
 #include <boost/numeric/conversion/cast.hpp>
 
+#include <Swiften/Base/Log.h>
 #include <Swiften/Elements/Message.h>
 
 namespace Swift {
@@ -31,7 +30,7 @@ void StanzaAckRequester::handleAckReceived(unsigned int handledStanzasCount) {
     unsigned int i = lastHandledStanzasCount;
     while (i != handledStanzasCount) {
         if (unackedStanzas.empty()) {
-            std::cerr << "Warning: Server acked more stanzas than we sent" << std::endl;
+            SWIFT_LOG(warning) << "Server acked more stanzas than we sent" << std::endl;
             break;
         }
         std::shared_ptr<Stanza> ackedStanza = unackedStanzas.front();
diff --git a/Swiften/Whiteboard/WhiteboardSession.cpp b/Swiften/Whiteboard/WhiteboardSession.cpp
index befef4f..c90475a 100644
--- a/Swiften/Whiteboard/WhiteboardSession.cpp
+++ b/Swiften/Whiteboard/WhiteboardSession.cpp
@@ -12,7 +12,6 @@
 
 #include <Swiften/Whiteboard/WhiteboardSession.h>
 
-#include <iostream>
 #include <memory>
 
 #include <Swiften/Elements/ErrorPayload.h>
-- 
cgit v0.10.2-6-g49f6