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_;
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))
A category of log message.
Definition: log.h:27
const char * name() const
Retrieve the log category name.
Definition: log.h:32
LogSeverity severity() const
Retrieve the severity of the log category.
Definition: log.h:33
static const LogCategory & defaultCategory()
Retrieve the default log category.
Definition: log.cpp:750
LogCategory(const char *name)
Construct a log category.
Definition: log.cpp:707
void setSeverity(LogSeverity severity)
Set the severity of the log category.
Definition: log.cpp:737
Internal log message representation.
Definition: log.h:54
const LogCategory & category() const
Retrieve the category of the log message.
Definition: log.h:68
LogMessage(const char *fileName, unsigned int line, LogSeverity severity)
Construct a log message for the default category.
Definition: log.cpp:776
const std::string msg() const
Retrieve the message text of the log message.
Definition: log.h:70
const std::string & fileInfo() const
Retrieve the file info of the log message.
Definition: log.h:69
const utils::time_point & timestamp() const
Retrieve the timestamp of the log message.
Definition: log.h:66
std::ostream & stream()
Definition: log.h:64
LogSeverity severity() const
Retrieve the severity of the log message.
Definition: log.h:67
Base class to support log message extensions.
Definition: log.h:83
virtual std::string logPrefix() const =0
Retrieve a string to be prefixed to the log message.
LogMessage _log(const char *file, unsigned int line, LogSeverity severity) const
Create a temporary LogMessage object to log a message.
Definition: log.cpp:926
LogSeverity
Definition: log.h:17
@ LogWarning
Definition: log.h:21
@ LogFatal
Definition: log.h:23
@ LogError
Definition: log.h:22
@ LogDebug
Definition: log.h:19
@ LogInfo
Definition: log.h:20
LogMessage _log(const char *file, unsigned int line, LogSeverity severity)
Create a temporary LogMessage object to log a message.
Definition: log.cpp:968
Miscellaneous utility functions.
std::chrono::steady_clock::time_point time_point
The libcamera time point related to libcamera::utils::clock.
Definition: utils.h:67