libcamera: log: De-duplicate _log() functions and LogMessage constructor
The _log() functions, as well as the LogMessage constructor, exist in two versions, one that takes a log category, and one that doesn't. The latter uses the default log category. This can be simplified by passing a LogCategory pointer to _log(), which can then be null for the default category, and moving the retrieval of the default log category from the LogMessage constructor to the _log() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Sebastian Fricke <sebastian.fricke@posteo.net> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
@@ -55,8 +55,6 @@ const LogCategory &_LOG_CATEGORY(name)() \
|
||||
class LogMessage
|
||||
{
|
||||
public:
|
||||
LogMessage(const char *fileName, unsigned int line,
|
||||
LogSeverity severity);
|
||||
LogMessage(const char *fileName, unsigned int line,
|
||||
const LogCategory &category, LogSeverity severity);
|
||||
|
||||
@@ -92,23 +90,20 @@ protected:
|
||||
virtual std::string logPrefix() const = 0;
|
||||
|
||||
LogMessage _log(const char *file, unsigned int line,
|
||||
LogSeverity severity) const;
|
||||
LogMessage _log(const char *file, unsigned int line,
|
||||
const LogCategory &category,
|
||||
const LogCategory *category,
|
||||
LogSeverity severity) const;
|
||||
};
|
||||
|
||||
LogMessage _log(const char *file, unsigned int line, LogSeverity severity);
|
||||
LogMessage _log(const char *file, unsigned int line,
|
||||
const LogCategory &category, LogSeverity severity);
|
||||
const LogCategory *category, LogSeverity severity);
|
||||
|
||||
#ifndef __DOXYGEN__
|
||||
#define _LOG_CATEGORY(name) logCategory##name
|
||||
|
||||
#define _LOG1(severity) \
|
||||
_log(__FILE__, __LINE__, Log##severity).stream()
|
||||
_log(__FILE__, __LINE__, nullptr, Log##severity).stream()
|
||||
#define _LOG2(category, severity) \
|
||||
_log(__FILE__, __LINE__, _LOG_CATEGORY(category)(), Log##severity).stream()
|
||||
_log(__FILE__, __LINE__, &_LOG_CATEGORY(category)(), Log##severity).stream()
|
||||
|
||||
/*
|
||||
* Expand the LOG() macro to _LOG1() or _LOG2() based on the number of
|
||||
|
||||
Reference in New Issue
Block a user