2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Helge Norberg, helge.norberg@svt.se
22 #include "graph_to_log_sink.h"
24 #include "call_context.h"
26 #include <common/diagnostics/graph.h>
27 #include <common/memory.h>
28 #include <common/log.h>
30 #include <tbb/spin_mutex.h>
32 namespace caspar { namespace core { namespace diagnostics {
34 class graph_to_log_sink : public caspar::diagnostics::spi::graph_sink
36 tbb::spin_mutex mutex_;
38 std::wstring context_ = call_context::for_thread().to_string();
40 void activate() override
44 void set_text(const std::wstring& value) override
46 tbb::spin_mutex::scoped_lock lock(mutex_);
50 void set_value(const std::string& name, double value) override
54 void set_color(const std::string& name, int color) override
58 void set_tag(caspar::diagnostics::tag_severity severity, const std::string& name) override
60 tbb::spin_mutex::scoped_lock lock(mutex_);
64 case caspar::diagnostics::tag_severity::INFO:
65 CASPAR_LOG(trace) << L"[diagnostics] [" << text_ << L"] " << name << L" " << context_;
67 case caspar::diagnostics::tag_severity::WARNING:
68 CASPAR_LOG(debug) << L"[diagnostics] [" << text_ << L"] " << name << L" " << context_;
73 void auto_reset() override
78 void register_graph_to_log_sink()
80 caspar::diagnostics::spi::register_sink_factory([] { return spl::make_shared<graph_to_log_sink>(); });