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