Gazebo Utils

API Reference

3.0.0
SplitSink.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef GZ_UTILS_LOG_SPLITSINK_HH_
19#define GZ_UTILS_LOG_SPLITSINK_HH_
20
21#include <memory>
22#include <string>
23
24#include <gz/utils/config.hh>
25#include <gz/utils/ImplPtr.hh>
26#include <gz/utils/log/Export.hh>
27
28#include <spdlog/details/log_msg.h>
29#include <spdlog/pattern_formatter.h>
30#include <spdlog/sinks/base_sink.h>
31#include <spdlog/sinks/stdout_color_sinks.h>
32
33namespace gz
34{
35namespace utils
36{
37namespace log
38{
39inline namespace GZ_UTILS_VERSION_NAMESPACE {
40
45class GZ_UTILS_LOG_VISIBLE SplitConsoleSink : public spdlog::sinks::sink
46{
49
51 public: ~SplitConsoleSink() override = default;
52
55 public: void log(const spdlog::details::log_msg &_msg) override;
56
58 public: void flush() override;
59
62 public: void set_pattern(const std::string &_pattern) override;
63
67 override;
68
71 public: void set_color_mode(spdlog::color_mode _mode);
72
75};
76} // namespace GZ_UTILS_LOG_VERSION_NAMESPACE
77} // namespace log
78} // namespace utils
79} // namespace gz
80
81#endif // GZ_UTILS_LOG_SPLITSINK_HH__