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 "../StdAfx.h"
24 #include "tcp_logger_protocol_strategy.h"
26 #include <common/log.h>
28 namespace caspar { namespace protocol { namespace log {
30 class tcp_logger_protocol_strategy : public IO::protocol_strategy<char>
32 spl::shared_ptr<IO::client_connection<char>> client_connection_;
33 std::shared_ptr<void> log_sink_ = caspar::log::add_preformatted_line_sink([=](std::string line)
35 handle_log_line(std::move(line));
38 tcp_logger_protocol_strategy(spl::shared_ptr<IO::client_connection<char>> client_connection)
39 : client_connection_(std::move(client_connection))
43 void handle_log_line(std::string line)
46 client_connection_->send(std::move(line));
49 void parse(const std::string& data) override
54 spl::shared_ptr<IO::protocol_strategy<char>> tcp_logger_protocol_strategy_factory::create(
55 const spl::shared_ptr<IO::client_connection<char>>& client_connection)
57 return spl::make_shared<tcp_logger_protocol_strategy>(client_connection);