iceoryx_hoofs 2.0.3
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
62namespace iox
63{
64namespace log
65{
66namespace ffbb
67{
68template <typename T>
69static Logger& ComponentLogger() noexcept
70{
71 static auto& logger = createLogger(T::Ctx, T::Description, LogManager::GetLogManager().DefaultLogLevel());
72 return logger;
73}
74
75template <typename T>
76inline LogStream LogFatal() noexcept
77{
78 return ComponentLogger<T>().LogFatal();
79}
80
81template <typename T>
82inline LogStream LogError() noexcept
83{
84 return ComponentLogger<T>().LogError();
85}
86
87template <typename T>
88inline LogStream LogWarn() noexcept
89{
90 return ComponentLogger<T>().LogWarn();
91}
92
93template <typename T>
94inline LogStream LogInfo() noexcept
95{
96 return ComponentLogger<T>().LogInfo();
97}
98
99template <typename T>
100inline LogStream LogDebug() noexcept
101{
102 return ComponentLogger<T>().LogDebug();
103}
104
105template <typename T>
106inline 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