$darkmode
logger.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020 Robert Bosch GmbH
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  * SPDX-License-Identifier: Apache-2.0
17  */
34 #pragma once
35 
36 #include <functional> // for function<>
37 #include <memory> // for shared_ptr<>
38 #include <string> // for string
39 
40 #include <fable/enum.hpp> // for FABLE_ENUM_SERIALIZATION
41 
42 #pragma GCC diagnostic push
43 #pragma GCC diagnostic ignored "-Wconversion"
44 #include <spdlog/spdlog.h>
45 #pragma GCC diagnostic pop
46 
47 // clang-format off
48 FABLE_ENUM_SERIALIZATION(spdlog::level::level_enum, ({
49  {spdlog::level::level_enum::trace, "trace"},
50  {spdlog::level::level_enum::debug, "debug"},
51  {spdlog::level::level_enum::info, "info"},
52  {spdlog::level::level_enum::warn, "warning"},
53  {spdlog::level::level_enum::err, "error"},
54  {spdlog::level::level_enum::critical, "fatal"},
55  {spdlog::level::level_enum::off, "off"},
56 }))
57 // clang-format on
58 
59 namespace cloe {
60 
101 using Logger = std::shared_ptr<spdlog::logger>;
102 
115 using LogLevel = spdlog::level::level_enum;
116 
117 namespace logger {
118 
126 Logger get(std::string name);
127 
174 void set_factory(std::function<Logger(std::string)> factory);
175 
185 void set_level(LogLevel l);
186 
191 LogLevel into_level(std::string s);
192 
197 std::string to_string(LogLevel l);
198 
199 } // namespace logger
200 } // namespace cloe
FABLE_ENUM_SERIALIZATION(spdlog::level::level_enum,({ {spdlog::level::level_enum::trace, "trace"}, {spdlog::level::level_enum::debug, "debug"}, {spdlog::level::level_enum::info, "info"}, {spdlog::level::level_enum::warn, "warning"}, {spdlog::level::level_enum::err, "error"}, {spdlog::level::level_enum::critical, "fatal"}, {spdlog::level::level_enum::off, "off"}, })) namespace cloe
Definition: logger.hpp:48