13 #include <libcamera/base/private.h>
34 const char *
name()
const {
return name_; }
45 #define LOG_DECLARE_CATEGORY(name) \
46 extern const LogCategory &_LOG_CATEGORY(name)();
48 #define LOG_DEFINE_CATEGORY(name) \
49 const LogCategory &_LOG_CATEGORY(name)() \
52 static LogCategory *category = new LogCategory(#name); \
59 LogMessage(
const char *fileName,
unsigned int line,
65 std::ostream &
stream() {
return msgStream_; }
70 const std::string &
fileInfo()
const {
return fileInfo_; }
71 const std::string
msg()
const {
return msgStream_.str(); }
76 void init(
const char *fileName,
unsigned int line);
78 std::ostringstream msgStream_;
82 std::string fileInfo_;
94 const char *fileName = __builtin_FILE(),
95 unsigned int line = __builtin_LINE())
const;
99 const char *fileName = __builtin_FILE(),
100 unsigned int line = __builtin_LINE());
103 #define _LOG_CATEGORY(name) logCategory##name
105 #define _LOG1(severity) \
106 _log(nullptr, Log##severity).stream()
107 #define _LOG2(category, severity) \
108 _log(&_LOG_CATEGORY(category)(), Log##severity).stream()
114 #define _LOG_MACRO(_1, _2, NAME, ...) NAME
115 #define LOG(...) _LOG_MACRO(__VA_ARGS__, _LOG2, _LOG1)(__VA_ARGS__)
117 #define LOG(category, severity)
121 #define ASSERT(condition) static_cast<void>(({ \
123 LOG(Fatal) << "assertion \"" #condition "\" failed in " \
124 << __func__ << "()"; \
127 #define ASSERT(condition) static_cast<void>(false && (condition))
Utilities to help constructing class interfaces.
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
A category of log message.
Definition: log.h:30
const char * name() const
Retrieve the log category name.
Definition: log.h:34
LogSeverity severity() const
Retrieve the severity of the log category.
Definition: log.h:35
static const LogCategory & defaultCategory()
Retrieve the default log category.
Definition: log.cpp:740
LogCategory(const char *name)
Construct a log category.
Definition: log.cpp:702
void setSeverity(LogSeverity severity)
Set the severity of the log category.
Definition: log.cpp:727
Internal log message representation.
Definition: log.h:57
const LogCategory & category() const
Retrieve the category of the log message.
Definition: log.h:69
LogMessage(const char *fileName, unsigned int line, const LogCategory &category, LogSeverity severity)
Construct a log message for a given category.
Definition: log.cpp:768
const std::string msg() const
Retrieve the message text of the log message.
Definition: log.h:71
const std::string & fileInfo() const
Retrieve the file info of the log message.
Definition: log.h:70
const utils::time_point & timestamp() const
Retrieve the timestamp of the log message.
Definition: log.h:67
std::ostream & stream()
Definition: log.h:65
LogSeverity severity() const
Retrieve the severity of the log message.
Definition: log.h:68
Base class to support log message extensions.
Definition: log.h:86
virtual std::string logPrefix() const =0
Retrieve a string to be prefixed to the log message.
LogMessage _log(const LogCategory *category, LogSeverity severity, const char *fileName=__builtin_FILE(), unsigned int line=__builtin_LINE()) const
Create a temporary LogMessage object to log a message.
Definition: log.cpp:903
Top-level libcamera namespace.
Definition: backtrace.h:17
LogMessage _log(const LogCategory *category, LogSeverity severity, const char *fileName=__builtin_FILE(), unsigned int line=__builtin_LINE())
Create a temporary LogMessage object to log a message.
Definition: log.cpp:926
LogSeverity
Definition: log.h:20
@ LogWarning
Definition: log.h:24
@ LogFatal
Definition: log.h:26
@ LogError
Definition: log.h:25
@ LogDebug
Definition: log.h:22
@ LogInfo
Definition: log.h:23
Miscellaneous utility functions.
std::chrono::steady_clock::time_point time_point
The libcamera time point related to libcamera::utils::clock.
Definition: utils.h:73