]> WPIA git - cassiopeia.git/blobdiff - src/record.cpp
add: Add more verbose logging
[cassiopeia.git] / src / record.cpp
index 5993b6065eadec6409c85552239660919ce0bb4e..8f81d02e683679fb764db59d16527e023d38f565 100644 (file)
@@ -23,13 +23,18 @@ std::string toHexAndChecksum( const std::string& src ) {
     return ss.str();
 }
 
-void sendCommand( RecordHeader& head, const std::string& data, std::shared_ptr<OpensslBIO> bio ) {
+void sendCommand( RecordHeader& head, const std::string& data, std::shared_ptr<OpensslBIO> bio, std::shared_ptr<std::ostream> log ) {
     head.payloadLength = data.size();
     std::string s;
     s += head.packToString();
     s += data;
 
     std::string res = toHexAndChecksum( s );
+
+    if( log ) {
+        ( *log.get() ) << "FINE: RECORD output: " << res << std::endl;
+    }
+
     bio->write( res.data(), res.size() );
 }
 
@@ -47,7 +52,11 @@ int32_t fromHexDigit( char c ) {
     return res;
 }
 
-std::string parseCommand( RecordHeader& head, const std::string& input ) {
+std::string parseCommand( RecordHeader& head, const std::string input, std::shared_ptr<std::ostream> log ) {
+    if( log ) {
+        ( *log.get() ) << "FINE: RECORD input: " << input << std::endl;
+    }
+
     int32_t dlen = ( input.size() - 2 ) / 2;
     char checksum = 0;
     bool error = false;