ADTF
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1
14
15
#ifndef A_UTIL_UTIL_LOG_HEADER_INCLUDED
16
#define A_UTIL_UTIL_LOG_HEADER_INCLUDED
17
18
#include <
a_util/base/delegate.h
>
19
#include <
a_util/base/types.h
>
20
#include <
a_util/preprocessor/to_string.h
>
// A_UTIL_TO_STRING()
21
#include <
a_util/strings/strings_format.h
>
22
#include <
a_util/strings/strings_functions.h
>
23
24
namespace
a_util
{
25
namespace
logging
{
30
enum
LogLevel
{
31
None
= 0,
32
Error
= 10,
33
Warning
= 20,
34
Info
= 30,
35
Dump
= 40,
36
Debug
=
Dump
,
37
All
= 0xFF
38
};
39
41
struct
LogEntry
{
42
timestamp_t
time_stamp
;
43
std::uint8_t
log_level
;
44
std::string
message
;
45
std::string
source
;
46
};
47
52
void
addEntry
(
const
LogEntry
& entry);
53
61
void
addEntry
(std::uint8_t log_level,
62
const
std::string& message =
a_util::strings::empty_string
,
63
const
std::string& source =
a_util::strings::empty_string
);
64
68
typedef
experimental::UnaryDelegate<void, const LogEntry&>
Logger
;
69
74
void
setLogger
(
Logger
log);
75
80
Logger
getLogger
();
81
87
std::string
defaultFormat
(
const
LogEntry
& entry);
88
93
void
defaultLogger
(
const
LogEntry
& entry);
94
100
#define LOG_ADD_ENTRY(__level, ...) \
101
a_util::logging::addEntry(__level, \
102
a_util::strings::format(__VA_ARGS__), \
103
__FILE__ "(" A_UTIL_TO_STRING(__LINE__) ")")
104
110
#ifdef _DEBUG
111
#define LOG_DUMP(...) LOG_ADD_ENTRY(a_util::logging::Dump, __VA_ARGS__)
112
#else
113
#define LOG_DUMP(...)
114
#endif
115
117
#define LOG_INFO(...) LOG_ADD_ENTRY(a_util::logging::Info, __VA_ARGS__)
118
123
#define LOG_WARNING(...) LOG_ADD_ENTRY(a_util::logging::Warning, __VA_ARGS__)
124
129
#define LOG_ERROR(...) LOG_ADD_ENTRY(a_util::logging::Error, __VA_ARGS__)
130
131
}
// namespace logging
132
}
// namespace a_util
133
134
#endif
// A_UTIL_UTIL_LOG_HEADER_INCLUDED
a_util::experimental::UnaryDelegate
Definition
delegate_decl.h:163
delegate.h
timestamp_t
std::int64_t timestamp_t
Type of a timestamp value. If not otherwise stated, always in microseconds.
Definition
types.h:31
a_util::logging
Serves as component for basic logging functionality.
Definition
logging.h:20
a_util::logging::addEntry
void addEntry(const LogEntry &entry)
a_util::logging::defaultFormat
std::string defaultFormat(const LogEntry &entry)
a_util::logging::getLogger
Logger getLogger()
a_util::logging::setLogger
void setLogger(Logger log)
a_util::logging::Logger
experimental::UnaryDelegate< void, const LogEntry & > Logger
Definition
log.h:68
a_util::logging::LogLevel
LogLevel
Definition
log.h:30
a_util::logging::All
@ All
Log all messages.
Definition
log.h:37
a_util::logging::Debug
@ Debug
Same as Dump.
Definition
log.h:36
a_util::logging::Error
@ Error
Log errors only.
Definition
log.h:32
a_util::logging::Info
@ Info
Log errors, warnings and info messages.
Definition
log.h:34
a_util::logging::None
@ None
Log nothing.
Definition
log.h:31
a_util::logging::Dump
@ Dump
Log errors, warnings, info and debug messages.
Definition
log.h:35
a_util::logging::Warning
@ Warning
Log errors and warnings.
Definition
log.h:33
a_util::logging::defaultLogger
void defaultLogger(const LogEntry &entry)
a_util::strings::empty_string
const std::string empty_string
Contains the empty string.
a_util
Serves as the root component, with common functionality documented in core functionality.
Definition
base.h:24
strings_format.h
strings_functions.h
a_util::logging::LogEntry
A log entry.
Definition
log.h:41
a_util::logging::LogEntry::message
std::string message
the message text
Definition
log.h:44
a_util::logging::LogEntry::source
std::string source
the origin of the entry
Definition
log.h:45
a_util::logging::LogEntry::time_stamp
timestamp_t time_stamp
time stamp of the log message.
Definition
log.h:42
a_util::logging::LogEntry::log_level
std::uint8_t log_level
the log level, see LogLevel.
Definition
log.h:43
to_string.h
types.h
workspace
conan
dev_essential
1.6.3
dw
stable
package
65324bff46e457721a7ba250afe9d61dc2b0e57a
include
a_util
logging
log.h
Copyright © CARIAD SE. All rights reserved | Generated on Thu Aug 6 2026 by doxygen 1.13.2 | GIT Commit Hash: 07d2f84367192978b2a55ca6aee7f968758b7220