summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Client/ClientXMLTracer.h')
-rw-r--r--Swiften/Client/ClientXMLTracer.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/Swiften/Client/ClientXMLTracer.h b/Swiften/Client/ClientXMLTracer.h
new file mode 100644
index 0000000..85224c8
--- /dev/null
+++ b/Swiften/Client/ClientXMLTracer.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include "Swiften/Client/Client.h"
+
+namespace Swift {
+ class ClientXMLTracer {
+ public:
+ ClientXMLTracer(Client* client) {
+ client->onDataRead.connect(boost::bind(&ClientXMLTracer::printData, '<', _1));
+ client->onDataWritten.connect(boost::bind(&ClientXMLTracer::printData, '>', _1));
+ }
+
+ private:
+ static void printData(char direction, const String& data) {
+ printLine(direction);
+ std::cerr << data << std::endl;
+ }
+
+ static void printLine(char c) {
+ for (unsigned int i = 0; i < 80; ++i) {
+ std::cerr << c;
+ }
+ std::cerr << std::endl;
+ }
+ };
+}