7 #ifndef __LIBCAMERA_INTERNAL_LOG_H__ 8 #define __LIBCAMERA_INTERNAL_LOG_H__ 32 const char *
name()
const {
return name_; }
43 #define LOG_DECLARE_CATEGORY(name) \ 44 extern const LogCategory &_LOG_CATEGORY(name)(); 46 #define LOG_DEFINE_CATEGORY(name) \ 47 const LogCategory &_LOG_CATEGORY(name)() \ 49 static LogCategory category(#name); \ 56 LogMessage(
const char *fileName,
unsigned int line,
58 LogMessage(
const char *fileName,
unsigned int line,
64 std::ostream &
stream() {
return msgStream_; }
69 const std::string &
fileInfo()
const {
return fileInfo_; }
70 const std::string
msg()
const {
return msgStream_.str(); }
73 void init(
const char *fileName,
unsigned int line);
75 std::ostringstream msgStream_;
79 std::string fileInfo_;
88 virtual std::string logPrefix()
const = 0;
92 LogMessage _log(
const char *file,
unsigned int line,
98 LogMessage _log(
const char *file,
unsigned int line,
102 #define _LOG_CATEGORY(name) logCategory##name 104 #define _LOG1(severity) \ 105 _log(__FILE__, __LINE__, Log##severity).stream() 106 #define _LOG2(category, severity) \ 107 _log(__FILE__, __LINE__, _LOG_CATEGORY(category)(), Log##severity).stream() 113 #define _LOG_MACRO(_1, _2, NAME, ...) NAME 114 #define LOG(...) _LOG_MACRO(__VA_ARGS__, _LOG2, _LOG1)(__VA_ARGS__) 116 #define LOG(category, severity) 120 #define ASSERT(condition) static_cast<void>(({ \ 122 LOG(Fatal) << "assertion \"" #condition "\" failed"; \ 125 #define ASSERT(condition) static_cast<void>(false && (condition)) const char * name() const
Retrieve the log category name.
Definition: log.h:32
Base class to support log message extensions.
Definition: log.h:82
Definition: bound_method.h:15
Internal log message representation.
Definition: log.h:53
std::chrono::steady_clock::time_point time_point
The libcamera time point related to libcamera::utils::clock.
Definition: utils.h:67
Miscellaneous utility functions.
LogSeverity severity() const
Retrieve the severity of the log category.
Definition: log.h:33
LogSeverity severity() const
Retrieve the severity of the log message.
Definition: log.h:67
const std::string & fileInfo() const
Retrieve the file info of the log message.
Definition: log.h:69
const LogCategory & category() const
Retrieve the category of the log message.
Definition: log.h:68
LogCategory(const char *name)
Construct a log category.
Definition: log.cpp:707
LogSeverity
Definition: log.h:17
const std::string msg() const
Retrieve the message text of the log message.
Definition: log.h:70
static const LogCategory & defaultCategory()
Retrieve the default log category.
Definition: log.cpp:750
LogMessage _log(const char *file, unsigned int line, LogSeverity severity)
Create a temporary LogMessage object to log a message.
Definition: log.cpp:968
A category of log message.
Definition: log.h:26
const utils::time_point & timestamp() const
Retrieve the timestamp of the log message.
Definition: log.h:66
std::ostream & stream()
Definition: log.h:64
void setSeverity(LogSeverity severity)
Set the severity of the log category.
Definition: log.cpp:737