12 #include <libcamera/base/private.h> 33 const std::string &
name()
const {
return name_; }
42 const std::string name_;
46 #define LOG_DECLARE_CATEGORY(name) \ 47 extern const LogCategory &_LOG_CATEGORY(name)(); 49 #define LOG_DEFINE_CATEGORY(name) \ 50 LOG_DECLARE_CATEGORY(name) \ 51 const LogCategory &_LOG_CATEGORY(name)() \ 54 static LogCategory *category = LogCategory::create(#name); \ 61 LogMessage(
const char *fileName,
unsigned int line,
63 const std::string &prefix = std::string());
68 std::ostream &
stream() {
return msgStream_; }
73 const std::string &
fileInfo()
const {
return fileInfo_; }
74 const std::string &
prefix()
const {
return prefix_; }
75 const std::string
msg()
const {
return msgStream_.str(); }
80 void init(
const char *fileName,
unsigned int line);
82 std::ostringstream msgStream_;
86 std::string fileInfo_;
96 virtual std::string logPrefix()
const = 0;
99 const char *fileName = __builtin_FILE(),
100 unsigned int line = __builtin_LINE())
const;
104 const char *fileName = __builtin_FILE(),
105 unsigned int line = __builtin_LINE());
108 #define _LOG_CATEGORY(name) logCategory##name 110 #define _LOG1(severity) \ 111 _log(nullptr, Log##severity).stream() 112 #define _LOG2(category, severity) \ 113 _log(&_LOG_CATEGORY(category)(), Log##severity).stream() 119 #define _LOG_MACRO(_1, _2, NAME, ...) NAME 120 #define LOG(...) _LOG_MACRO(__VA_ARGS__, _LOG2, _LOG1)(__VA_ARGS__) 122 #define LOG(category, severity) 126 #define ASSERT(condition) static_cast<void>(({ \ 128 LOG(Fatal) << "assertion \"" #condition "\" failed in " \ 129 << __func__ << "()"; \ 132 #define ASSERT(condition) static_cast<void>(false && (condition)) const std::string & prefix() const
Retrieve the prefix of the log message.
Definition: log.h:74
Utilities to help constructing class interfaces.
const std::string & name() const
Retrieve the log category name.
Definition: log.h:33
Base class to support log message extensions.
Definition: log.h:90
LogSeverity
Definition: log.h:19
Top-level libcamera namespace.
Definition: backtrace.h:17
Internal log message representation.
Definition: log.h:58
std::chrono::steady_clock::time_point time_point
The libcamera time point related to libcamera::utils::clock.
Definition: utils.h:73
Miscellaneous utility functions.
static LogCategory * create(const char *name)
Create a new LogCategory or return an existing one.
Definition: log.cpp:790
LogSeverity severity() const
Retrieve the severity of the log category.
Definition: log.h:34
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:1037
LogSeverity severity() const
Retrieve the severity of the log message.
Definition: log.h:71
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
const std::string & fileInfo() const
Retrieve the file info of the log message.
Definition: log.h:73
const LogCategory & category() const
Retrieve the category of the log message.
Definition: log.h:72
const std::string msg() const
Retrieve the message text of the log message.
Definition: log.h:75
static const LogCategory & defaultCategory()
Retrieve the default log category.
Definition: log.cpp:845
A category of log message.
Definition: log.h:28
const utils::time_point & timestamp() const
Retrieve the timestamp of the log message.
Definition: log.h:70
std::ostream & stream()
Definition: log.h:68
void setSeverity(LogSeverity severity)
Set the severity of the log category.
Definition: log.cpp:832