#include <string>\r
#include <ostream>\r
\r
+#include <boost/bind.hpp>\r
#include <boost/shared_ptr.hpp>\r
#include <boost/make_shared.hpp>\r
#include <boost/filesystem/convenience.hpp>\r
\r
using namespace boost;\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) && c != '\r' && c != '\n'; }, 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
-void my_formatter(std::wostream& strm, boost::log::basic_record<wchar_t> const& rec)\r
+void my_formatter(bool print_all_characters, std::wostream& strm, boost::log::basic_record<wchar_t> const& rec)\r
{\r
namespace lambda = boost::lambda;\r
\r
strm << L" ";\r
}\r
\r
- strm << replace_nonprintable_copy(rec.message(), L'?');\r
+ if (print_all_characters)\r
+ {\r
+ strm << rec.message();\r
+ }\r
+ else\r
+ {\r
+ strm << replace_nonprintable_copy(rec.message(), L'?');\r
+ }\r
}\r
\r
namespace internal{\r
// stream_sink->set_filter(boost::log::filters::attr<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get()) >= debug);\r
//#endif\r
\r
- stream_sink->locked_backend()->set_formatter(&my_formatter);\r
+ stream_sink->locked_backend()->set_formatter(boost::bind(my_formatter, false, _1, _2));\r
\r
boost::log::wcore::get()->add_sink(stream_sink);\r
}\r
boost::log::keywords::open_mode = std::ios::app\r
);\r
\r
- file_sink->locked_backend()->set_formatter(&my_formatter);\r
+ file_sink->locked_backend()->set_formatter(boost::bind(my_formatter, true, _1, _2));\r
\r
//#ifdef NDEBUG\r
// file_sink->set_filter(boost::log::filters::attr<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get()) >= debug);\r
std::wstring get_call_stack();\r
}\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 {\r
+ return \r
+ (!std::isprint(c, loc) \r
+ && c != '\r' \r
+ && c != '\n')\r
+ || c > static_cast<T>(127);\r
+ }, 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
void add_file_sink(const std::wstring& folder);\r
\r
enum severity_level\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() << ": " << message << 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() << ": " << message << L"\\r\\n";\r
\r
std::vector<std::wstring> tokens;\r
int tokenCount = TokenizeMessage(message, &tokens);\r
#include <string>\r
#include <iostream>\r
\r
+#include <common/log.h>\r
+\r
namespace caspar { namespace IO {\r
\r
class ClientInfo \r
{\r
void Send(const std::wstring& data)\r
{\r
- std::wcout << (L"#" + data);\r
+ std::wcout << (L"#" + caspar::log::replace_nonprintable_copy(data, L'?'));\r
}\r
void Disconnect(){}\r
virtual std::wstring print() const {return L"Console";}\r
#include <boost/property_tree/detail/file_parser_error.hpp>\r
#include <boost/property_tree/xml_parser.hpp>\r
#include <boost/foreach.hpp>\r
+#include <boost/locale.hpp>\r
\r
#include <signal.h>\r
\r
::FreeLibrary(hMod);\r
}\r
\r
+void setup_global_locale()\r
+{\r
+ boost::locale::generator gen;\r
+ gen.categories(boost::locale::codepage_facet);\r
+\r
+ std::locale::global(gen(""));\r
+}\r
+\r
void setup_console_window()\r
{ \r
auto hOut = GetStdHandle(STD_OUTPUT_HANDLE);\r
SetUnhandledExceptionFilter(UserUnhandledExceptionFilter);\r
signal(SIGABRT, on_abort);\r
\r
+ setup_global_locale();\r
+\r
std::wcout << L"Type \"q\" to close application." << std::endl;\r
\r
// Set debug mode.\r