| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
FileConsumer.hpp
1// Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
19
20#ifndef FASTDDS_DDS_LOG__FILECONSUMER_HPP
21#define FASTDDS_DDS_LOG__FILECONSUMER_HPP
22
23#include <fastdds/dds/log/Log.hpp>
24#include <fastdds/dds/log/OStreamConsumer.hpp>
25
26#include <fstream>
27
28 namespace eprosima {
29 namespace fastdds {
30 namespace dds {
31
37 class FileConsumer : public OStreamConsumer
38{
39 public:
40
42 FASTDDS_EXPORTED_API FileConsumer();
43
48 FASTDDS_EXPORTED_API FileConsumer(
49 const std::string& filename,
50 bool append = false);
51
52 virtual ~FileConsumer();
53
54 private:
55
60 FASTDDS_EXPORTED_API virtual std::ostream& get_stream(
61 const Log::Entry& entry) override;
62
63 std::string output_file_;
64 std::ofstream file_;
65 bool append_;
66};
67
68} // namespace dds
69} // namespace fastdds
70} // namespace eprosima
71
72#endif // FASTDDS_DDS_LOG__FILECONSUMER_HPP
eprosima::fastdds::dds::FileConsumer::FileConsumer
FASTDDS_EXPORTED_API FileConsumer()
Default constructor: filename = "output.log", append = false.
eprosima::fastdds::dds::FileConsumer::FileConsumer
FASTDDS_EXPORTED_API FileConsumer(const std::string &filename, bool append=false)
Constructor with parameters.
eprosima::fastdds::dds::FileConsumer::~FileConsumer
virtual ~FileConsumer()
eprosima::fastdds::dds::OStreamConsumer
Definition OStreamConsumer.hpp:32
eprosima::fastdds::dds
Definition BuiltinTopicKey.hpp:26
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::dds::Log::Entry
Definition Log.hpp:174