2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "remote_logger.hh"
28 #include <unordered_map>
30 #include <fstrm/iothr.h>
31 #include <fstrm/unix_writer.h>
32 #ifdef HAVE_FSTRM_TCP_WRITER_INIT
33 #include <fstrm/tcp_writer.h>
36 class FrameStreamLogger : public RemoteLoggerInterface, boost::noncopyable
39 FrameStreamLogger(int family, const std::string& address, bool connect, const std::unordered_map<string,unsigned>& options = std::unordered_map<string,unsigned>());
40 virtual ~FrameStreamLogger();
41 virtual void queueData(const std::string& data) override;
42 virtual std::string toString() const override
44 return "FrameStreamLogger to " + d_address;
46 bool logQueries(void) const { return d_logQueries; }
47 bool logResponses(void) const { return d_logResponses; }
48 void setLogQueries(bool flag) { d_logQueries = flag; }
49 void setLogResponses(bool flag) { d_logResponses = flag; }
54 const std::string d_address;
55 struct fstrm_iothr_queue *d_ioqueue{nullptr};
56 struct fstrm_writer_options *d_fwopt{nullptr};
57 struct fstrm_unix_writer_options *d_uwopt{nullptr};
58 #ifdef HAVE_FSTRM_TCP_WRITER_INIT
59 struct fstrm_tcp_writer_options *d_twopt{nullptr};
61 struct fstrm_writer *d_writer{nullptr};
62 struct fstrm_iothr_options *d_iothropt{nullptr};
63 struct fstrm_iothr *d_iothr{nullptr};
67 bool d_logQueries{true};
68 bool d_logResponses{true};
72 class FrameStreamLogger : public RemoteLoggerInterface, boost::noncopyable {};
73 #endif /* HAVE_FSTRM */