libt2n: (gerd) fix & improve logging
[libt2n] / src / command_server.cpp
index d3721a8..3bfc0e3 100644 (file)
@@ -49,6 +49,14 @@ void command_server::handle_packet(const std::string& packet, server_connection*
     // TODO: catch
     ia >> ccont;
 
+    std::ostream* ostr;
+    if ((ostr=s.get_logstream(fulldebug))!=NULL)
+    {
+        (*ostr) << "decoded packet data: " << std::endl;
+        boost::archive::xml_oarchive xo(*ostr);
+        xo << BOOST_SERIALIZATION_NVP(ccont);
+    }
+
     // TODO: cast to command subclass (template)
     command *cmd=ccont.get_command();
 
@@ -74,6 +82,13 @@ void command_server::handle_packet(const std::string& packet, server_connection*
     // TODO: catch
     oa << res;
 
+    if ((ostr=s.get_logstream(fulldebug))!=NULL)
+    {
+        (*ostr) << "returning result, decoded data: " << std::endl;
+        boost::archive::xml_oarchive xo(*ostr);
+        xo << BOOST_SERIALIZATION_NVP(res);
+    }
+
     conn->write(ofs.str());
 }