]> git.sesse.net Git - casparcg/commitdiff
* Added logging of severe diagnostics events to log at warning level. graph::set_tag...
authorHelge Norberg <helge.norberg@svt.se>
Wed, 28 Oct 2015 14:01:06 +0000 (15:01 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Wed, 28 Oct 2015 14:01:06 +0000 (15:01 +0100)
18 files changed:
common/CMakeLists.txt
common/diagnostics/graph.cpp
common/diagnostics/graph.h
common/diagnostics/graph_to_log_sink.cpp [new file with mode: 0644]
common/diagnostics/graph_to_log_sink.h [new file with mode: 0644]
core/diagnostics/osd_graph.cpp
core/diagnostics/subject_diagnostics.cpp
modules/decklink/consumer/decklink_consumer.cpp
modules/decklink/producer/decklink_producer.cpp
modules/ffmpeg/consumer/ffmpeg_consumer.cpp
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/ffmpeg/producer/input/input.cpp
modules/flash/producer/flash_producer.cpp
modules/html/producer/html_producer.cpp
modules/newtek/consumer/newtek_ivga_consumer.cpp
modules/oal/consumer/oal_consumer.cpp
modules/screen/consumer/screen_consumer.cpp
shell/server.cpp

index b441b27b5c592e60f850e28eb93ecc17b092e97d..cd1bfb9fa0eb3defd73b67bb6e68079df41359da 100644 (file)
@@ -3,6 +3,7 @@ project (common)
 
 set(SOURCES
                diagnostics/graph.cpp
+               diagnostics/graph_to_log_sink.cpp
 
                gl/gl_check.cpp
 
@@ -44,6 +45,7 @@ elseif (CMAKE_COMPILER_IS_GNUCXX)
 endif ()
 set(HEADERS
                diagnostics/graph.h
+               diagnostics/graph_to_log_sink.h
 
                gl/gl_check.h
 
index 4cd3fc5829573af71d9ef2de34a4796d0aa1c0d2..539a92be63dd3016ddce77ebc189d00b0100a729 100644 (file)
@@ -91,10 +91,10 @@ public:
                        sink->set_value(name, value);
        }
 
-       void set_tag(const std::string& name)
+       void set_tag(tag_severity severity, const std::string& name)
        {
                for (auto& sink : sinks_)
-                       sink->set_tag(name);
+                       sink->set_tag(severity, name);
        }
 
        void set_color(const std::string& name, int color)
@@ -121,7 +121,7 @@ graph::graph() : impl_(new impl)
 void graph::set_text(const std::wstring& value) { impl_->set_text(value); }
 void graph::set_value(const std::string& name, double value) { impl_->set_value(name, value); }
 void graph::set_color(const std::string& name, int color) { impl_->set_color(name, color); }
-void graph::set_tag(const std::string& name) { impl_->set_tag(name); }
+void graph::set_tag(tag_severity severity, const std::string& name) { impl_->set_tag(severity, name); }
 void graph::auto_reset() { impl_->auto_reset(); }
 
 void register_graph(const spl::shared_ptr<graph>& graph)
index f925b78b690be9f3237e81cbce2feae9438ec37c..0b8888013609fd45a9ae806084125d14de46c309 100644 (file)
@@ -34,6 +34,12 @@ namespace caspar { namespace diagnostics {
 int color(float r, float g, float b, float a = 1.0f);
 std::tuple<float, float, float, float> color(int code);
 
+enum class tag_severity
+{
+       WARNING,
+       INFO
+};
+
 class graph : boost::noncopyable
 {
        friend void register_graph(const spl::shared_ptr<graph>& graph);
@@ -42,7 +48,7 @@ public:
        void set_text(const std::wstring& value);
        void set_value(const std::string& name, double value);
        void set_color(const std::string& name, int color);
-       void set_tag(const std::string& name);
+       void set_tag(tag_severity severity, const std::string& name);
        void auto_reset();
 private:
        struct impl;
@@ -61,7 +67,7 @@ public:
        virtual void set_text(const std::wstring& value) = 0;
        virtual void set_value(const std::string& name, double value) = 0;
        virtual void set_color(const std::string& name, int color) = 0;
-       virtual void set_tag(const std::string& name) = 0;
+       virtual void set_tag(tag_severity severity, const std::string& name) = 0;
        virtual void auto_reset() = 0;
 };
 
diff --git a/common/diagnostics/graph_to_log_sink.cpp b/common/diagnostics/graph_to_log_sink.cpp
new file mode 100644 (file)
index 0000000..214a545
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Helge Norberg, helge.norberg@svt.se
+*/
+
+#include "graph_to_log_sink.h"
+
+#include "../log.h"
+
+#include <tbb/spin_mutex.h>
+
+namespace caspar { namespace diagnostics {
+
+class graph_to_log_sink : public spi::graph_sink
+{
+       tbb::spin_mutex mutex_;
+       std::wstring    text_;
+public:
+       void activate() override
+       {
+       }
+
+       void set_text(const std::wstring& value) override
+       {
+               tbb::spin_mutex::scoped_lock lock(mutex_);
+               text_ = value;
+       }
+
+       void set_value(const std::string& name, double value) override
+       {
+       }
+
+       void set_color(const std::string& name, int color) override
+       {
+       }
+
+       void set_tag(tag_severity severity, const std::string& name) override
+       {
+               tbb::spin_mutex::scoped_lock lock(mutex_);
+
+               switch (severity)
+               {
+               case tag_severity::INFO:
+                       CASPAR_LOG(trace) << L"[diagnostics] [" << text_ << L"] " << name;
+                       break;
+               case tag_severity::WARNING:
+                       CASPAR_LOG(warning) << L"[diagnostics] [" << text_ << L"] " << name;
+                       break;
+               }
+       }
+
+       void auto_reset() override
+       {
+       }
+};
+
+void register_graph_to_log_sink()
+{
+       spi::register_sink_factory([] { return spl::make_shared<graph_to_log_sink>(); });
+}
+
+}}
diff --git a/common/diagnostics/graph_to_log_sink.h b/common/diagnostics/graph_to_log_sink.h
new file mode 100644 (file)
index 0000000..1a15599
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Helge Norberg, helge.norberg@svt.se
+*/
+
+#pragma once
+
+#include "../memory.h"
+#include "graph.h"
+
+namespace caspar { namespace diagnostics {
+
+void register_graph_to_log_sink();
+
+}}
index 1753284c48562a1d9e5c55d10f26b21fe8744ff1..c4a8c518a7ce3686e03e86a0d86fbd264782cfa0 100644 (file)
@@ -422,7 +422,7 @@ struct graph : public drawable, public caspar::diagnostics::spi::graph_sink, pub
                lines_[name].set_value(value);
        }
 
-       void set_tag(const std::string& name) override
+       void set_tag(caspar::diagnostics::tag_severity /*severity*/, const std::string& name) override
        {
                lines_[name].set_tag();
        }
index c9b8acbf9e780772c62fa1b088e34f8106db59aa..84f846169b99f592f32c692d3d011cead18a0880 100644 (file)
@@ -92,9 +92,21 @@ public:
                *subject_ << monitor::message("/color/" + name) % color;
        }
        
-       void set_tag(const std::string& name) override
+       void set_tag(caspar::diagnostics::tag_severity severity, const std::string& name) override
        {
-               *subject_ << monitor::message("/tag/" + name);
+               std::string severity_path;
+
+               switch (severity)
+               {
+               case caspar::diagnostics::tag_severity::INFO:
+                       severity_path = "info/";
+                       break;
+               case caspar::diagnostics::tag_severity::WARNING:
+                       severity_path = "warning/";
+                       break;
+               }
+
+               *subject_ << monitor::message("/tag/" + severity_path + name);
 
                send_full_state_if_long_ago();
        }
index 41817958659ba6c073e806e54b3f5e4ab5a42792..c9fb588fbdac57c386b25d23eb472b4fcdc6cbd1 100644 (file)
@@ -505,7 +505,7 @@ public:
 
                        if(result == bmdOutputFrameDisplayedLate)
                        {
-                               graph_->set_tag("late-frame");
+                               graph_->set_tag(diagnostics::tag_severity::WARNING, "late-frame");
                                video_scheduled_ += format_desc_.duration;
                                audio_scheduled_ += dframe->audio_data().size() / out_channel_layout_.num_channels;
                                //++video_scheduled_;
@@ -513,9 +513,9 @@ public:
                                //++audio_scheduled_;
                        }
                        else if(result == bmdOutputFrameDropped)
-                               graph_->set_tag("dropped-frame");
+                               graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame");
                        else if(result == bmdOutputFrameFlushed)
-                               graph_->set_tag("flushed-frame");
+                               graph_->set_tag(diagnostics::tag_severity::WARNING, "flushed-frame");
 
                        auto frame = core::const_frame::empty();        
                        video_frame_buffer_.pop(frame);
index 3f6cc8b7d1c26b18ff19113bd752376776f2b3b1..19521f1f17dbcb72fe0051c949da700e816457cc 100644 (file)
@@ -269,7 +269,7 @@ public:
                                        frame_buffer_.try_pop(dummy);
                                        frame_buffer_.try_push(frame);
                                                
-                                       graph_->set_tag("dropped-frame");
+                                       graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame");
                                }
                        }
                        
@@ -295,7 +295,7 @@ public:
                
                core::draw_frame frame = core::draw_frame::late();
                if(!frame_buffer_.try_pop(frame))
-                       graph_->set_tag("late-frame");
+                       graph_->set_tag(diagnostics::tag_severity::WARNING, "late-frame");
                graph_->set_value("output-buffer", static_cast<float>(frame_buffer_.size())/static_cast<float>(frame_buffer_.capacity()));      
                return frame;
        }
index 44394b9a835512fc107e0a287d060aeebb880fe9..15eaf4a29cfcdcc55589b74f1cc0c190b8ded393 100644 (file)
@@ -389,7 +389,7 @@ public:
 
        void mark_dropped()
        {
-               graph_->set_tag("dropped-frame");
+               graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame");
        }
 
        std::wstring print() const
index 9e65e7562660cfb2851b66e5e11ec49448f88173..7896dce56ac6fe2656da6703d6751c60047c148a 100644 (file)
@@ -205,8 +205,8 @@ public:
                        muxer_->pop();
                }
                else
-                       graph_->set_tag("underflow");
-                                                                       
+                       graph_->set_tag(diagnostics::tag_severity::WARNING, "underflow");
+
                graph_->set_value("frame-time", frame_timer.elapsed()*format_desc_.fps*0.5);
                *monitor_subject_
                                << core::monitor::message("/profiler/time")     % frame_timer.elapsed() % (1.0/format_desc_.fps);                       
index 1f9490443083b396abb5e81f934e94929fcfce97..9a4befa0bd7f8f427c630e1d42cd4384092b926b 100644 (file)
@@ -213,7 +213,7 @@ struct input::impl : boost::noncopyable
 private:
        void internal_seek(uint32_t target)
        {
-               graph_->set_tag("seek");        
+               graph_->set_tag(diagnostics::tag_severity::INFO, "seek");
 
                CASPAR_LOG(debug) << print() << " Seeking: " << target;
 
index 90b04c316a69c4b8475ab7771ab8cf1410d6b124..2f7aaea8d7b600b020220b8818e4cb8ac932dbae 100644 (file)
@@ -270,7 +270,7 @@ public:
                if (boost::starts_with(result, L"<exception>"))
                        CASPAR_LOG(warning) << print() << L" Flash call failed:" << result;
 
-               graph_->set_tag("param");
+               graph_->set_tag(diagnostics::tag_severity::INFO, "param");
 
                return result;
        }
@@ -412,7 +412,7 @@ public:
                if (output_buffer_.try_pop(frame))
                        last_frame_ = frame;
                else            
-                       graph_->set_tag("late-frame");
+                       graph_->set_tag(diagnostics::tag_severity::WARNING, "late-frame");
 
                fill_buffer();
                                
index e890a93f30ea5159b1911e41796459604ea7dc2a..3e6aba7771668ca722714258866839baef0a0154 100644 (file)
@@ -229,7 +229,7 @@ private:
                        while (frames_.size() > max_in_queue)
                        {
                                frames_.pop();
-                               graph_->set_tag("dropped-frame");
+                               graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame");
                        }
                });
                graph_->set_value("copy-time", copy_timer.elapsed()
@@ -416,7 +416,7 @@ private:
                }
                else
                {
-                       graph_->set_tag("late-frame");
+                       graph_->set_tag(diagnostics::tag_severity::WARNING, "late-frame");
 
                        if (format_desc_.field_mode != core::field_mode::progressive)
                        {
index 44d7e1010d381ea0a336a9624819c498beb6b65a..139a4040db4f18149ed88c563f27862231c30869 100644 (file)
@@ -138,7 +138,7 @@ public:
 
                if (executor_.size() > 0 || executor_.is_currently_in_task())
                {
-                       graph_->set_tag("dropped-frame");
+                       graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame");
 
                        return make_ready_future(true);
                }
index 8099d5b0f714994d3bdf5b599fba2cef9d4acd83..58e87e8b0c6ae5f763310ef0373e5bcee3c46a25 100644 (file)
@@ -212,7 +212,7 @@ public:
                                        }
                                }
                                alSourcePlay(source_);          
-                               graph_->set_tag("late-frame");  
+                               graph_->set_tag(diagnostics::tag_severity::WARNING, "late-frame");
                        }
 
                        auto audio = core::audio_32_to_16(channel_remapper_->mix_and_rearrange(frame.audio_data()));
@@ -225,7 +225,7 @@ public:
                                alSourceQueueBuffers(source_, 1, &buffer);
                        }
                        else
-                               graph_->set_tag("dropped-frame");
+                               graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame");
 
                        graph_->set_value("tick-time", perf_timer_.elapsed()*format_desc_.fps*0.5);             
                        perf_timer_.restart();
index a8938a027bf9e9c9758b44f8f50a15f699a2772e..303e824487c35b6354b18a62d329d15fef50effb 100644 (file)
@@ -517,7 +517,7 @@ public:
        std::future<bool> send(core::const_frame frame)
        {
                if(!frame_buffer_.try_push(frame))
-                       graph_->set_tag("dropped-frame");
+                       graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame");
 
                return make_ready_future(is_running_.load());
        }
index 76b0d3556d75276859d420484dffd4ece8ec575a..f80db3495d94b23c68d253935c558295cb120a48 100644 (file)
@@ -32,6 +32,7 @@
 #include <common/utf.h>
 #include <common/memory.h>
 #include <common/polling_filesystem_monitor.h>
+#include <common/diagnostics/graph_to_log_sink.h>
 
 #include <core/video_channel.h>
 #include <core/video_format.h>
@@ -149,7 +150,8 @@ struct server::impl : boost::noncopyable
                , shutdown_server_now_(shutdown_server_now)
        {
                running_ = false;
-               core::diagnostics::osd::register_sink();
+               caspar::diagnostics::register_graph_to_log_sink();
+               caspar::core::diagnostics::osd::register_sink();
                diag_subject_->attach_parent(monitor_subject_);
 
                module_dependencies dependencies(