]> git.sesse.net Git - casparcg/commitdiff
More pretty printing.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 23 Dec 2011 14:15:29 +0000 (14:15 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 23 Dec 2011 14:15:29 +0000 (14:15 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/trunk@1935 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

common/log/log.cpp
modules/ffmpeg/producer/audio/audio_decoder.cpp
modules/ffmpeg/producer/audio/audio_decoder.h
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/ffmpeg/producer/video/video_decoder.cpp
modules/ffmpeg/producer/video/video_decoder.h
modules/flash/producer/FlashAxContainer.cpp
protocol/amcp/AMCPProtocolStrategy.cpp
protocol/cii/CIIProtocolStrategy.cpp
protocol/util/AsyncEventServer.cpp
shell/shell.vcxproj

index d76debf77e83c27b6017e602de70261aea18a820..9dd218384ac5ac22254bbfb5d08c974a92fb0a5b 100644 (file)
@@ -85,9 +85,16 @@ void my_formatter(std::wostream& strm, boost::log::basic_record<wchar_t> const&
     if(boost::log::extract<boost::log::attributes::current_thread_id::held_type>(L"ThreadID", rec.attribute_values(), lambda::var(thread_id) = lambda::_1))\r
         strm << L"[" << thread_id << L"] ";\r
 \r
+\r
     severity_level severity;\r
     if(boost::log::extract<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get(), rec.attribute_values(), lambda::var(severity) = lambda::_1))\r
+       {\r
+               std::stringstream ss;\r
+               ss << severity;\r
         strm << L"[" << severity << L"] ";\r
+               for(int n = 0; n < 7-static_cast<int>(ss.str().size()); ++n)\r
+                       strm << L" ";\r
+       }\r
 \r
     strm << rec.message();\r
 }\r
@@ -158,17 +165,17 @@ void add_file_sink(const std::wstring& folder)
 \r
 void set_log_level(const std::wstring& lvl)\r
 {      \r
-       if(boost::iequals(lvl, L"trace  "))\r
+       if(boost::iequals(lvl, L"trace"))\r
                boost::log::wcore::get()->set_filter(boost::log::filters::attr<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get()) >= trace);\r
-       else if(boost::iequals(lvl, L"debug  "))\r
+       else if(boost::iequals(lvl, L"debug"))\r
                boost::log::wcore::get()->set_filter(boost::log::filters::attr<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get()) >= debug);\r
-       else if(boost::iequals(lvl, L"info   "))\r
+       else if(boost::iequals(lvl, L"info"))\r
                boost::log::wcore::get()->set_filter(boost::log::filters::attr<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get()) >= info);\r
        else if(boost::iequals(lvl, L"warning"))\r
                boost::log::wcore::get()->set_filter(boost::log::filters::attr<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get()) >= warning);\r
-       else if(boost::iequals(lvl, L"error  "))\r
+       else if(boost::iequals(lvl, L"error"))\r
                boost::log::wcore::get()->set_filter(boost::log::filters::attr<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get()) >= error);\r
-       else if(boost::iequals(lvl, L"fatal  "))\r
+       else if(boost::iequals(lvl, L"fatal"))\r
                boost::log::wcore::get()->set_filter(boost::log::filters::attr<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get()) >= fatal);\r
 }\r
 \r
index 4f00bfaaa12805603388f2c6caefc2664db8e771..3b26c9ef52dca19695542a92a2b365b7ef551e6e 100644 (file)
@@ -134,13 +134,18 @@ public:
 \r
        bool ready() const\r
        {\r
-               return packets_.size() >= 8;\r
+               return packets_.size() > 10;\r
        }\r
 \r
        uint32_t nb_frames() const\r
        {\r
                return 0;//std::max<int64_t>(nb_frames_, file_frame_number_);\r
        }\r
+\r
+       std::wstring print() const\r
+       {               \r
+               return L"[audio_decoder] " + widen(codec_context_->codec->long_name);\r
+       }\r
 };\r
 \r
 audio_decoder::audio_decoder(const safe_ptr<AVFormatContext>& context, const core::video_format_desc& format_desc) : impl_(new implementation(context, format_desc)){}\r
@@ -149,5 +154,6 @@ bool audio_decoder::ready() const{return impl_->ready();}
 std::shared_ptr<core::audio_buffer> audio_decoder::poll(){return impl_->poll();}\r
 uint32_t audio_decoder::nb_frames() const{return impl_->nb_frames();}\r
 uint32_t audio_decoder::file_frame_number() const{return impl_->file_frame_number_;}\r
+std::wstring audio_decoder::print() const{return impl_->print();}\r
 \r
 }}
\ No newline at end of file
index 415886e1b45873616769335b10e1036a09d13186..bb5c120925b841a0db55c45919692a64f5bd9f9b 100644 (file)
@@ -52,6 +52,8 @@ public:
        uint32_t nb_frames() const;\r
        \r
        uint32_t file_frame_number() const;\r
+\r
+       std::wstring print() const;\r
 private:\r
        struct implementation;\r
        safe_ptr<implementation> impl_;\r
index 491b31c7f36a518c2f774ca8e62c854eef5d965b..7b98d4135d8a13f439f648a784bbe25adc97aa52 100644 (file)
@@ -104,10 +104,11 @@ public:
                try\r
                {\r
                        video_decoder_.reset(new video_decoder(input_.context()));\r
+                       CASPAR_LOG(info) << print() << L" " << video_decoder_->print();\r
                }\r
                catch(averror_stream_not_found&)\r
                {\r
-                       CASPAR_LOG(warning) << print() << " No video-stream found. Running without video.";     \r
+                       //CASPAR_LOG(warning) << print() << " No video-stream found. Running without video.";   \r
                }\r
                catch(...)\r
                {\r
@@ -118,10 +119,11 @@ public:
                try\r
                {\r
                        audio_decoder_.reset(new audio_decoder(input_.context(), frame_factory->get_video_format_desc()));\r
+                       CASPAR_LOG(info) << print() << L" " << audio_decoder_->print();\r
                }\r
                catch(averror_stream_not_found&)\r
                {\r
-                       CASPAR_LOG(warning) << print() << " No audio-stream found. Running without audio.";     \r
+                       //CASPAR_LOG(warning) << print() << " No audio-stream found. Running without audio.";   \r
                }\r
                catch(...)\r
                {\r
index bb11ad3e5c6fd360f19854d52e82fb8a04968b41..43c1b0602f72abe59789c173faf21b182ed8cef1 100644 (file)
@@ -73,7 +73,6 @@ public:
                , height_(codec_context_->height)\r
        {\r
                file_frame_number_ = 0;\r
-               CASPAR_LOG(debug) << "[video_decoder] " << context->streams[index_]->codec->codec->long_name;\r
        }\r
 \r
        void push(const std::shared_ptr<AVPacket>& packet)\r
@@ -144,6 +143,11 @@ public:
        {\r
                return std::max<uint32_t>(nb_frames_, file_frame_number_);\r
        }\r
+\r
+       std::wstring print() const\r
+       {               \r
+               return L"[video_decoder] " + widen(codec_context_->codec->long_name);\r
+       }\r
 };\r
 \r
 video_decoder::video_decoder(const safe_ptr<AVFormatContext>& context) : impl_(new implementation(context)){}\r
@@ -155,5 +159,6 @@ size_t video_decoder::height() const{return impl_->height_;}
 uint32_t video_decoder::nb_frames() const{return impl_->nb_frames();}\r
 uint32_t video_decoder::file_frame_number() const{return impl_->file_frame_number_;}\r
 bool   video_decoder::is_progressive() const{return impl_->is_progressive_;}\r
+std::wstring video_decoder::print() const{return impl_->print();}\r
 \r
 }}
\ No newline at end of file
index 8f981e411d14c894711de51883bbc05968e793fe..d84ae6abc0f28e99b0d432a863409d17106b6784 100644 (file)
@@ -55,6 +55,8 @@ public:
 \r
        bool     is_progressive() const;\r
 \r
+       std::wstring print() const;\r
+\r
 private:\r
        struct implementation;\r
        safe_ptr<implementation> impl_;\r
index 0dce5b17917897a86360aa946d7905b88711092f..62038ac2510bfdee45356a9b7b4e9e5f1c7ccf05 100644 (file)
@@ -608,12 +608,12 @@ void STDMETHODCALLTYPE FlashAxContainer::OnFlashCall(BSTR request)
        }\r
        else if(str.find(TEXT("OnCommand")) != std::wstring::npos) {\r
                //this is how templatehost 1.8 reports that a command has been received\r
-               CASPAR_LOG(debug)  << print_()  << L" Command: " << str;\r
+               CASPAR_LOG(debug)  << print_()  << L" [command]      " << str;\r
                bCallSuccessful_ = true;\r
        }\r
        else if(str.find(TEXT("Activity")) != std::wstring::npos)\r
        {\r
-               CASPAR_LOG(debug) << print_() << L" Activity: " << str;\r
+               CASPAR_LOG(debug) << print_() << L" [activity]     " << str;\r
 \r
                //this is how templatehost 1.7 reports that a command has been received\r
                if(str.find(TEXT("Command recieved")) != std::wstring::npos)\r
@@ -627,7 +627,7 @@ void STDMETHODCALLTYPE FlashAxContainer::OnFlashCall(BSTR request)
        }\r
        else if(str.find(TEXT("OnNotify")) != std::wstring::npos)\r
        {\r
-               CASPAR_LOG(info) << print_() << L" Notification: " << str;\r
+               CASPAR_LOG(info) << print_() << L" [notification] " << str;\r
 \r
                //if(pFlashProducer_ != 0 && pFlashProducer_->pMonitor_) {\r
                //      std::wstring::size_type pos = str.find(TEXT('@'));\r
@@ -637,17 +637,17 @@ void STDMETHODCALLTYPE FlashAxContainer::OnFlashCall(BSTR request)
        }\r
        else if(str.find(TEXT("IsEmpty")) != std::wstring::npos)\r
        {\r
-               CASPAR_LOG(info) << print_() << L" Empty.";\r
+               CASPAR_LOG(trace) << print_() << L" Empty.";\r
                ATLTRACE(_T("ShockwaveFlash::IsEmpty\n"));\r
                bIsEmpty_ = true;\r
        }\r
        else if(str.find(TEXT("OnError")) != std::wstring::npos)\r
        {\r
-               CASPAR_LOG(error) << print_() << L" Error: " << str;\r
+               CASPAR_LOG(error) << print_() << L" [error]        " << str;\r
        }\r
        else if(str.find(TEXT("OnDebug")) != std::wstring::npos)\r
        {\r
-               CASPAR_LOG(error) << print_() << L" Debug: " << str;\r
+               CASPAR_LOG(debug) << print_() << L" [debug]        " << str;\r
        }\r
        //else if(str.find(TEXT("OnTemplateDescription")) != std::wstring::npos)\r
        //{\r
index b40ae6f303dff76529c1bc97eb3fd5a81f937a18..d7bc190edef200f547493c7c6ce784c8f241fe4e 100644 (file)
@@ -156,8 +156,6 @@ AMCPCommandPtr AMCPProtocolStrategy::InterpretCommandString(const std::wstring&
        AMCPCommandPtr pCommand;\r
        MessageParserState state = New;\r
 \r
-       CASPAR_LOG(info) << L"Received: " << message;\r
-\r
        std::size_t tokensInMessage = TokenizeMessage(message, &tokens);\r
 \r
        //parse the message one token at the time\r
index 0c4b719b4c7a344d609467bc98955484570c1bf6..79e2732495bd82f35dc419075d959dd78dffbd6d 100644 (file)
@@ -83,8 +83,6 @@ void CIIProtocolStrategy::Parse(const TCHAR* pData, int charCount, IO::ClientInf
 \r
 void CIIProtocolStrategy::ProcessMessage(const std::wstring& message)\r
 {\r
-       CASPAR_LOG(debug) << L"Received: " << message.c_str();\r
-\r
        std::vector<std::wstring> tokens;\r
        int tokenCount = TokenizeMessage(message, &tokens);\r
 \r
index 98fbd7d2e1dc2c457c419bd7ed8734f3f6b72ef7..036541c100481eb6970234c0293688f79379a556 100644 (file)
@@ -31,6 +31,8 @@
 \r
 #include <common/log/log.h>\r
 \r
+#include <boost/algorithm/string/replace.hpp>\r
+\r
 #include <string>\r
 #include <algorithm>\r
 \r
@@ -355,12 +357,17 @@ bool AsyncEventServer::OnRead(SocketInfoPtr& pSI) {
 \r
                //Convert to widechar\r
                if(ConvertMultiByteToWideChar(pProtocolStrategy_->GetCodepage(), pSI->recvBuffer_, recvResult + pSI->recvLeftoverOffset_, pSI->wideRecvBuffer_, pSI->recvLeftoverOffset_))\r
+               {\r
+                       auto msg =      std::wstring(pSI->wideRecvBuffer_.begin(), pSI->wideRecvBuffer_.end());\r
+                       boost::replace_all(msg, L"\n", L"\\n");\r
+                       boost::replace_all(msg, L"\r", L"\\r");\r
+\r
+                       CASPAR_LOG(info) << L"Received message from " << pSI->host_.c_str() << ": "<< msg;\r
                        pProtocolStrategy_->Parse(&pSI->wideRecvBuffer_[0], pSI->wideRecvBuffer_.size(), pSI);\r
+               }\r
                else                    \r
                        CASPAR_LOG(error) << "Read from " << pSI->host_.c_str() << TEXT(" failed, could not convert command to UNICODE");\r
                        \r
-               \r
-\r
                maxRecvLength = sizeof(pSI->recvBuffer_)-pSI->recvLeftoverOffset_;\r
                recvResult = recv(pSI->socket_, pSI->recvBuffer_+pSI->recvLeftoverOffset_, maxRecvLength, 0);\r
        }\r
@@ -434,8 +441,13 @@ void AsyncEventServer::DoSend(SocketInfo& socketInfo) {
                        }\r
                        else {\r
                                if(sentBytes == bytesToSend) {\r
+                                       \r
                                        if(sentBytes < 512)\r
+                                       {\r
+                                               boost::replace_all(socketInfo.sendQueue_.front(), L"\n", L"\\n");\r
+                                               boost::replace_all(socketInfo.sendQueue_.front(), L"\r", L"\\r");\r
                                                CASPAR_LOG(info) << L"Sent message to " << socketInfo.host_.c_str() << L": " << socketInfo.sendQueue_.front().c_str();\r
+                                       }\r
                                        else\r
                                                CASPAR_LOG(info) << "Sent more than 512 bytes to " << socketInfo.host_.c_str();\r
 \r
index 33ff4ab60cd3a83da6397651cc1a330dbe619ed3..21d8c075f340792ea1864d170b641ba96a80b746 100644 (file)
@@ -244,8 +244,8 @@ copy "$(ProjectDir)casparcg.config" "$(OutDir)"</Command>
       <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r
       <IgnoreSpecificDefaultLibraries>LIBC.lib</IgnoreSpecificDefaultLibraries>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
-      <GenerateMapFile>false</GenerateMapFile>\r
-      <MapExports>false</MapExports>\r
+      <GenerateMapFile>true</GenerateMapFile>\r
+      <MapExports>true</MapExports>\r
       <SubSystem>Console</SubSystem>\r
       <OptimizeReferences>\r
       </OptimizeReferences>\r