iceoryx_hoofs  2.0.2
logging_free_function_building_block.hpp
1 // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2 // Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
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 #ifndef IOX_HOOFS_LOG_LOGGING_FREE_FUNCTION_BUILDING_BLOCK_HPP
18 #define IOX_HOOFS_LOG_LOGGING_FREE_FUNCTION_BUILDING_BLOCK_HPP
19 
57 
58 #include "iceoryx_hoofs/log/logger.hpp"
59 #include "iceoryx_hoofs/log/logging.hpp"
60 #include "iceoryx_hoofs/log/logmanager.hpp"
61 
62 namespace iox
63 {
64 namespace log
65 {
66 namespace ffbb
67 {
68 template <typename T>
69 static Logger& ComponentLogger() noexcept
70 {
71  static auto& logger = createLogger(T::Ctx, T::Description, LogManager::GetLogManager().DefaultLogLevel());
72  return logger;
73 }
74 
75 template <typename T>
76 inline LogStream LogFatal() noexcept
77 {
78  return ComponentLogger<T>().LogFatal();
79 }
80 
81 template <typename T>
82 inline LogStream LogError() noexcept
83 {
84  return ComponentLogger<T>().LogError();
85 }
86 
87 template <typename T>
88 inline LogStream LogWarn() noexcept
89 {
90  return ComponentLogger<T>().LogWarn();
91 }
92 
93 template <typename T>
94 inline LogStream LogInfo() noexcept
95 {
96  return ComponentLogger<T>().LogInfo();
97 }
98 
99 template <typename T>
100 inline LogStream LogDebug() noexcept
101 {
102  return ComponentLogger<T>().LogDebug();
103 }
104 
105 template <typename T>
106 inline LogStream LogVerbose() noexcept
107 {
108  return ComponentLogger<T>().LogVerbose();
109 }
110 } // namespace ffbb
111 } // namespace log
112 } // namespace iox
113 
114 #endif // IOX_HOOFS_LOG_LOGGING_FREE_FUNCTION_BUILDING_BLOCK_HPP
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:29