Gazebo Utils

API Reference

3.0.0
Logger.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#ifndef GZ_UTILS_LOG_LOGGER_HH_
18#define GZ_UTILS_LOG_LOGGER_HH_
19
20#if !defined(SPDLOG_ACTIVE_LEVEL)
21 #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
22#endif
23
24#include <spdlog/spdlog.h>
25#include <memory>
26#include <string>
27#include <gz/utils/config.hh>
28#include <gz/utils/ImplPtr.hh>
29#include <gz/utils/log/Export.hh>
30
31namespace gz
32{
33namespace utils
34{
35namespace log
36{
37inline namespace GZ_UTILS_VERSION_NAMESPACE {
38
42class GZ_UTILS_LOG_VISIBLE Logger
43{
46 public: explicit Logger(const std::string &_loggerName);
47
50 public: void SetLogDestination(const std::string &_filename);
51
54 public: std::string LogDestination() const;
55
58 public: [[nodiscard]] spdlog::logger &RawLogger() const;
59
62 public: [[nodiscard]] std::shared_ptr<spdlog::logger> RawLoggerPtr() const;
63
66 public: void SetConsoleSinkLevel(spdlog::level::level_enum _level);
67
70};
71} // namespace GZ_UTILS_LOG_VERSION_NAMESPACE
72} // namespace log
73} // namespace utils
74} // namespace gz
75
76#endif // GZ_UTILS_LOG_LOGGER_HH_