|  | @@ -5,6 +5,8 @@
 | 
	
		
			
				|  |  |  #include <boost/log/core.hpp>
 | 
	
		
			
				|  |  |  #include <boost/log/trivial.hpp>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +#include <regex>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  #include "session.h"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #include <string>
 | 
	
	
		
			
				|  | @@ -29,11 +31,23 @@ bool replace(std::string &str, const char *from, const char *to) {
 | 
	
		
			
				|  |  |    return true;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +void ansi_clean(std::string &str) {
 | 
	
		
			
				|  |  | +  static std::regex ansi_cleaner("\x1b\[[0-9;]*[A-Zmh]", std::regex_constants::ECMAScript);
 | 
	
		
			
				|  |  | +  str = std::regex_replace(str, ansi_cleaner, "");
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  std::string clean_string(const std::string &source) {
 | 
	
		
			
				|  |  | +  // BOOST_LOG_NAMED_SCOPE("clean_string");
 | 
	
		
			
				|  |  |    std::string clean = source;
 | 
	
		
			
				|  |  |    replace(clean, "\n", "\\n");
 | 
	
		
			
				|  |  |    replace(clean, "\r", "\\r");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // ANSI too
 | 
	
		
			
				|  |  | +  ansi_clean(clean);
 | 
	
		
			
				|  |  | +  // BOOST_LOG_TRIVIAL(error) << "cleaned: " << clean;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    replace(clean, "\x1b", "^");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    return clean;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -112,7 +126,8 @@ void session::on_connect(const boost::system::error_code error) {
 | 
	
		
			
				|  |  |  void session::dispatch_line(std::string line) {
 | 
	
		
			
				|  |  |    // Does this have \n\r still on it?  I don't want them.
 | 
	
		
			
				|  |  |    BOOST_LOG_NAMED_SCOPE("session");
 | 
	
		
			
				|  |  | -  BOOST_LOG_TRIVIAL(info) << "SL: " << clean_string(line);
 | 
	
		
			
				|  |  | +  std::string temp = clean_string(line);
 | 
	
		
			
				|  |  | +  BOOST_LOG_TRIVIAL(info) << "SL: " << temp; // clean_string(line);
 | 
	
		
			
				|  |  |    // std::cout << "SL: " << line << std::endl;
 | 
	
		
			
				|  |  |    // is echo on?  if so:
 | 
	
		
			
				|  |  |  }
 |