iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
logformat.hpp
Go to the documentation of this file.
1// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved.
3// Copyright (c) 2025 Contributors to the Eclipse Foundation
4//
5// See the NOTICE file(s) distributed with this work for additional
6// information regarding copyright ownership.
7//
8// This program and the accompanying materials are made available under the
9// terms of the Apache Software License 2.0 which is available at
10// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
11// which is available at https://opensource.org/licenses/MIT.
12//
13// SPDX-License-Identifier: Apache-2.0 OR MIT
14
15#ifndef IOX2_BB_REPORTING_LOG_BUILDING_BLOCKS_LOGFORMAT_HPP
16#define IOX2_BB_REPORTING_LOG_BUILDING_BLOCKS_LOGFORMAT_HPP
17
19
20#include <cstdint>
21
22namespace iox2 {
23namespace legacy {
24namespace log {
25// AXIVION DISABLE STYLE AutosarC++19_03-A3.9.1 : Basic numeric types are used in order to get the correct format string
26// on all platforms. Fixed width types are used on a higher abstraction layer. Furthermore are 'const char*' used for
27// string literals with static lifetime and as a pointer to a buffer of character
28
32constexpr const char* logLevelDisplayColor(const LogLevel value) noexcept;
33
37constexpr const char* logLevelDisplayText(const LogLevel value) noexcept;
38
40struct LogBuffer {
41 const char* buffer { nullptr };
43};
44
45namespace internal {
46template <typename T>
47constexpr const char* logFormatDec() noexcept;
48template <>
50template <>
51constexpr const char* logFormatDec<signed char>() noexcept;
52template <>
53constexpr const char* logFormatDec<unsigned char>() noexcept;
54template <>
56template <>
57constexpr const char* logFormatDec<unsigned short>() noexcept;
58template <>
60template <>
61constexpr const char* logFormatDec<unsigned int>() noexcept;
62template <>
64template <>
65constexpr const char* logFormatDec<unsigned long>() noexcept;
66template <>
68template <>
69constexpr const char* logFormatDec<unsigned long long>() noexcept;
70template <>
72template <>
74template <>
75constexpr const char* logFormatDec<long double>() noexcept;
76
79template <>
80constexpr const char* logFormatHex<unsigned char>() noexcept;
81template <>
82constexpr const char* logFormatHex<unsigned short>() noexcept;
83template <>
84constexpr const char* logFormatHex<unsigned int>() noexcept;
85template <>
86constexpr const char* logFormatHex<unsigned long>() noexcept;
87template <>
88constexpr const char* logFormatHex<unsigned long long>() noexcept;
89template <>
91template <>
93template <>
94constexpr const char* logFormatHex<long double>() noexcept;
95template <>
97
100template <>
101constexpr const char* logFormatOct<unsigned char>() noexcept;
102template <>
103constexpr const char* logFormatOct<unsigned short>() noexcept;
104template <>
105constexpr const char* logFormatOct<unsigned int>() noexcept;
106template <>
107constexpr const char* logFormatOct<unsigned long>() noexcept;
108template <>
109constexpr const char* logFormatOct<unsigned long long>() noexcept;
110} // namespace internal
111
114static constexpr const char* LOG_FORMAT_DEC { internal::logFormatDec<T>() };
115
117template <typename T>
118static constexpr const char* LOG_FORMAT_HEX { internal::logFormatHex<T>() };
119
121template <typename T>
122static constexpr const char* LOG_FORMAT_OCT { internal::logFormatOct<T>() };
123
124// AXIVION ENABLE STYLE AutosarC++19_03-A3.9.1
125
126} // namespace log
127} // namespace legacy
128} // namespace iox2
129
130#include "iox2/legacy/detail/log/building_blocks/logformat.inl"
131
132#endif // IOX2_BB_REPORTING_LOG_BUILDING_BLOCKS_LOGFORMAT_HPP
constexpr const char * logFormatOct() noexcept
constexpr const char * logFormatHex() noexcept
constexpr const char * logFormatDec() noexcept
constexpr const char * logLevelDisplayText(const LogLevel value) noexcept
converts LogLevel into a string literal display text
LogLevel
This enum defines the log levels used for logging.
Definition logger.hpp:30
constexpr const char * logLevelDisplayColor(const LogLevel value) noexcept
converts LogLevel into a string literal color code
static constexpr const char * LOG_FORMAT_HEX
printf-like format string for hexadecimal formatting of numbers
static constexpr const char * LOG_FORMAT_OCT
printf-like format string for octal formatting of numbers
static constexpr const char * LOG_FORMAT_DEC
printf-like format string for decimal formatting of numbers
constexpr bool always_false_v
Helper value to bind a static_assert to a type.
void log(LogLevel log_level, const char *origin, const char *message)
Adds a log message to the logger.
Provides access to the log buffer if direct access is required.
Definition logformat.hpp:40