]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 10 Aug 2011 10:28:08 +0000 (10:28 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 10 Aug 2011 10:28:08 +0000 (10:28 +0000)
common/log/log.cpp
common/log/log.h
core/producer/frame_producer.cpp
modules/ffmpeg/ffmpeg.cpp
modules/ffmpeg/producer/input.cpp
protocol/amcp/AMCPCommandsImpl.cpp
protocol/amcp/AMCPCommandsImpl.h
protocol/amcp/AMCPProtocolStrategy.cpp

index ebb25cbb483d88e7b446f418bbd773825b2ed279..f7f3b9b40659c23ebe031982f47602414d7d8306 100644 (file)
@@ -36,6 +36,7 @@
 #include <boost/make_shared.hpp>\r
 #include <boost/filesystem/convenience.hpp>\r
 #include <boost/date_time/posix_time/posix_time.hpp>\r
+#include <boost/algorithm/string.hpp>\r
 \r
 #include <boost/log/core/core.hpp>\r
 \r
@@ -106,6 +107,12 @@ void init()
 \r
        auto stream_sink = boost::make_shared<stream_sink_type>(stream_backend);\r
        \r
+#ifdef NDEBUG\r
+       stream_sink->set_filter(boost::log::filters::attr<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get()) >= info);\r
+#else\r
+       stream_sink->set_filter(boost::log::filters::attr<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get()) >= trace);\r
+#endif\r
+\r
        stream_sink->locked_backend()->set_formatter(&my_formatter);\r
 \r
        boost::log::wcore::get()->add_sink(stream_sink);\r
@@ -148,4 +155,20 @@ void add_file_sink(const std::wstring& folder)
        }\r
 }\r
 \r
+void set_log_level(const std::wstring& lvl)\r
+{      \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
+               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
+               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
+               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
+               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
 }}
\ No newline at end of file
index 1e81522a7796e5665aea698fe99e7f010cbbbdc3..f95b1066bf05c01842ab965f7f1544092c28d14f 100644 (file)
@@ -91,6 +91,8 @@ BOOST_LOG_DECLARE_GLOBAL_LOGGER_INIT(logger, caspar_logger)
        {CASPAR_LOG(error) << boost::current_exception_diagnostic_information().c_str();}\\r
        catch(...){}\r
 \r
+void set_log_level(const std::wstring& lvl);\r
+\r
 }}\r
 \r
 #if defined(_MSC_VER)\r
index 25725299ba038a3a62749cabd3af1f5d0d6d00be..7b86eb795015aecea9712072e9ee38c28dda6847 100644 (file)
@@ -109,7 +109,12 @@ safe_ptr<core::frame_producer> do_create_producer(const safe_ptr<frame_factory>&
                producer = create_color_producer(my_frame_factory, params);\r
 \r
        if(producer == frame_producer::empty())\r
-               BOOST_THROW_EXCEPTION(file_not_found() << msg_info("No match found for supplied commands. Check syntax.") << arg_value_info(params.size() > 0 ? narrow(params[0]) : ""));\r
+       {\r
+               std::wstring str;\r
+               BOOST_FOREACH(auto& param, params)\r
+                       str += param + L" ";\r
+               BOOST_THROW_EXCEPTION(file_not_found() << msg_info("No match found for supplied commands. Check syntax.") << arg_value_info(narrow(str)));\r
+       }\r
 \r
        return producer;\r
 }\r
index 5fa7aab5bc8228e4910c7fdb376640c5d5f08e69..ae0e4240faffd1dccf51135b21d4adf3e497cb06 100644 (file)
@@ -135,7 +135,18 @@ void log_callback(void* ptr, int level, const char* fmt, va_list vl)
     strcpy(prev, line);\r
     sanitize((uint8_t*)line);\r
        \r
-       CASPAR_LOG(trace) << L"[FFMPEG] [" << av_clip(level>>3, 0, 6) << L"] " << line;\r
+       if(level == AV_LOG_DEBUG)\r
+               CASPAR_LOG(debug) << L"[FFMPEG] " << line;\r
+       else if(level == AV_LOG_INFO)\r
+               CASPAR_LOG(info) << L"[FFMPEG] " << line;\r
+       else if(level == AV_LOG_WARNING)\r
+               CASPAR_LOG(warning) << L"[FFMPEG] " << line;\r
+       else if(level == AV_LOG_ERROR)\r
+               CASPAR_LOG(error) << L"[FFMPEG] " << line;\r
+       else if(level == AV_LOG_FATAL)\r
+               CASPAR_LOG(fatal) << L"[FFMPEG] " << line;\r
+       else\r
+               CASPAR_LOG(trace) << L"[FFMPEG] " << line;\r
 \r
     //colored_fputs(av_clip(level>>3, 0, 6), line);\r
 }\r
index a38f311afdfccb1b46ba3b23b54ac8c990db5f54..04dc3a5dbbd86ea35fa4ee994881ece42dce0a7c 100644 (file)
@@ -97,6 +97,8 @@ public:
                THROW_ON_ERROR2(avformat_open_input(&weak_format_context_, narrow(filename).c_str(), nullptr, nullptr), print());\r
 \r
                format_context_.reset(weak_format_context_, av_close_input_file);\r
+\r
+               av_dump_format(weak_format_context_, 0, narrow(filename).c_str(), 0);\r
                        \r
                THROW_ON_ERROR2(avformat_find_stream_info(format_context_.get(), nullptr), print());\r
                \r
index 5f917d04e31bb53fb438fff745e9ac5e359219ed..726e4bdfdfa2b054ee6b2a2d4f9b49eb450d22a7 100644 (file)
 \r
 #include <common/env.h>\r
 \r
+#include <common/log/log.h>\r
+\r
 #include <core/producer/frame_producer.h>\r
 #include <core/video_format.h>\r
-#include <modules/flash/flash.h>\r
-#include <modules/flash/producer/flash_producer.h>\r
-#include <modules/flash/producer/cg_producer.h>\r
 #include <core/producer/transition/transition_producer.h>\r
-\r
 #include <core/producer/frame/image_transform.h>\r
 #include <core/producer/frame/audio_transform.h>\r
 #include <core/mixer/mixer.h>\r
 #include <core/consumer/output.h>\r
 \r
+#include <modules/flash/flash.h>\r
+#include <modules/flash/producer/flash_producer.h>\r
+#include <modules/flash/producer/cg_producer.h>\r
+\r
 #include <algorithm>\r
 #include <locale>\r
 #include <fstream>\r
@@ -796,6 +798,16 @@ bool PrintCommand::DoExecute()
        return true;\r
 }\r
 \r
+bool LogCommand::DoExecute()\r
+{\r
+       if(_parameters.at(0) == L"LEVEL")\r
+               log::set_log_level(_parameters.at(1));\r
+\r
+       SetReplyString(TEXT("202 LOG OK\r\n"));\r
+\r
+       return true;\r
+}\r
+\r
 bool CGCommand::DoExecute()\r
 {\r
        std::wstring command = _parameters[0];\r
index 0ba71f57b9094781b09142b85f0d623a8feb5a12..3f50f34a7f48f4d30383dd192eeb2a212bedba6e 100644 (file)
@@ -102,6 +102,11 @@ class PrintCommand : public AMCPCommandBase<true, AddToQueue, 0>
        bool DoExecute();\r
 };\r
 \r
+class LogCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
+{\r
+       std::wstring print() const { return L"LogCommand";}\r
+       bool DoExecute();\r
+};\r
 \r
 class CGCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
 {\r
index 4ad90ea2d0e533a552cbeefd77d342f6baabee35..937922f22a455a181339fb12ac6a8a54f4c2df80 100644 (file)
@@ -322,6 +322,7 @@ AMCPCommandPtr AMCPProtocolStrategy::CommandFactory(const std::wstring& str)
        else if(s == TEXT("STOP"))              return std::make_shared<StopCommand>();\r
        else if(s == TEXT("CLEAR"))             return std::make_shared<ClearCommand>();\r
        else if(s == TEXT("PRINT"))             return std::make_shared<PrintCommand>();\r
+       else if(s == TEXT("LOG"))               return std::make_shared<LogCommand>();\r
        else if(s == TEXT("CG"))                return std::make_shared<CGCommand>();\r
        else if(s == TEXT("DATA"))              return std::make_shared<DataCommand>();\r
        else if(s == TEXT("CINF"))              return std::make_shared<CinfCommand>();\r