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