#include <boost/log/sources/severity_logger.hpp>\r
#include <boost/log/sources/record_ostream.hpp>\r
\r
+#include <string>\r
+#include <locale>\r
+\r
namespace caspar { namespace log {\r
\r
namespace internal{\r
\r
void set_log_level(const std::wstring& lvl);\r
\r
+template<typename T>\r
+inline void replace_nonprintable(std::basic_string<T, std::char_traits<T>, std::allocator<T>>& str, T with)\r
+{\r
+ std::locale loc;\r
+ std::replace_if(str.begin(), str.end(), [&](T c)->bool { return !std::isprint(c, loc); }, with);\r
+}\r
+\r
+template<typename T>\r
+inline std::basic_string<T> replace_nonprintable_copy(std::basic_string<T, std::char_traits<T>, std::allocator<T>> str, T with)\r
+{\r
+ replace_nonprintable(str, with);\r
+ return str;\r
+}\r
+\r
}}\r
\r
#if defined(_MSC_VER)\r
\r
void AMCPProtocolStrategy::ProcessMessage(const std::wstring& message, ClientInfoPtr& pClientInfo)\r
{ \r
- CASPAR_LOG(info) << L"Received message from " << pClientInfo->print() << ": " << message + L"\\r\\n";\r
+ CASPAR_LOG(info) << L"Received message from " << pClientInfo->print() << ": " << log::replace_nonprintable_copy(message, L'?') + L"\\r\\n";\r
\r
bool bError = true;\r
MessageParserState state = New;\r
\r
void CIIProtocolStrategy::ProcessMessage(const std::wstring& message, IO::ClientInfoPtr pClientInfo)\r
{ \r
- CASPAR_LOG(info) << L"Received message from " << pClientInfo->print() << ": " << message + L"\\r\\n";\r
+ CASPAR_LOG(info) << L"Received message from " << pClientInfo->print() << ": " << log::replace_nonprintable_copy(message, L'?') + L"\\r\\n";\r
\r
std::vector<std::wstring> tokens;\r
int tokenCount = TokenizeMessage(message, &tokens);\r