iceoryx_hoofs 2.0.3
logcommon.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_LOGCOMMON_HPP
18#define IOX_HOOFS_LOG_LOGCOMMON_HPP
19
20#include <chrono>
21#include <string>
22
23namespace iox
24{
25namespace log
26{
27enum class LogLevel : uint8_t
28{
29 kOff = 0,
30 kFatal,
31 kError,
32 kWarn,
33 kInfo,
34 kDebug,
35 kVerbose
36};
37
38enum class LogMode : uint8_t
39{
40 kRemote = 0x01,
41 kFile = 0x02,
42 kConsole = 0x04
43};
44
45constexpr const char* LogLevelColor[] = {
46 "", // nothing
47 "\033[0;1;97;41m", // bold bright white on red
48 "\033[0;1;31;103m", // bold red on light yellow
49 "\033[0;1;93m", // bold bright yellow
50 "\033[0;1;92m", // bold bright green
51 "\033[0;1;96m", // bold bright cyan
52 "\033[0;1;36m", // bold cyan
53};
54
55constexpr const char* LogLevelText[] = {
56 "[ Off ]", // nothing
57 "[ Fatal ]", // bold bright white on red
58 "[ Error ]", // bold red on light yellow
59 "[Warning]", // bold bright yellow
60 "[ Info ]", // bold bright green
61 "[ Debug ]", // bold bright cyan
62 "[Verbose]", // bold cyan
63};
64
65LogMode operator|(LogMode lhs, LogMode rhs) noexcept;
66LogMode& operator|=(LogMode& lhs, LogMode rhs) noexcept;
67LogMode operator&(LogMode lhs, LogMode rhs) noexcept;
68LogMode& operator&=(LogMode& lhs, LogMode rhs) noexcept;
69
71{
72 LogLevel level{LogLevel::kVerbose};
73 std::chrono::milliseconds time{0};
74 std::string message;
75};
76
77} // namespace log
78} // namespace iox
79
80#endif // IOX_HOOFS_LOG_LOGCOMMON_HPP
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:29
Definition: logcommon.hpp:71