diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-04-14 00:26:39 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-04-15 00:04:54 +0300 |
commit | df1d955d24d113771bd8fedc3bde7f230c059fb7 (patch) | |
tree | 5897cf7618d5419d6556829f3069675af7ea90cf /src | |
parent | 93be96431a5cdacfe632c3cfb6763b90649bc590 (diff) |
libcamera: log: Use compiler builtins to retrieve file and line number
Replace the __FILE__ and __LINE__ values passed to the _log() function
with default parameters, taking their values from the __builtin_FILE()
and __builtin_LINE() functions. This moves handling of the file and line
from the preprocessor to the compiler, which is generally preferred as
it increases type safety.
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/log.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp index 9f86e645..94175ab3 100644 --- a/src/libcamera/log.cpp +++ b/src/libcamera/log.cpp @@ -897,19 +897,18 @@ Loggable::~Loggable() /** * \brief Create a temporary LogMessage object to log a message - * \param[in] fileName The file name where the message is logged from - * \param[in] line The line number where the message is logged from * \param[in] category The log message category * \param[in] severity The log message severity + * \param[in] fileName The file name where the message is logged from + * \param[in] line The line number where the message is logged from * * This method is used as a backeng by the LOG() macro to create a log message * for locations inheriting from the Loggable class. * * \return A log message */ -LogMessage Loggable::_log(const char *fileName, unsigned int line, - const LogCategory *category, - LogSeverity severity) const +LogMessage Loggable::_log(const LogCategory *category, LogSeverity severity, + const char *fileName, unsigned int line) const { LogMessage msg(fileName, line, category ? *category : LogCategory::defaultCategory(), @@ -921,18 +920,18 @@ LogMessage Loggable::_log(const char *fileName, unsigned int line, /** * \brief Create a temporary LogMessage object to log a message - * \param[in] fileName The file name where the message is logged from - * \param[in] line The line number where the message is logged from * \param[in] category The log message category * \param[in] severity The log message severity + * \param[in] fileName The file name where the message is logged from + * \param[in] line The line number where the message is logged from * * This function is used as a backeng by the LOG() macro to create a log * message for locations not inheriting from the Loggable class. * * \return A log message */ -LogMessage _log(const char *fileName, unsigned int line, - const LogCategory *category, LogSeverity severity) +LogMessage _log(const LogCategory *category, LogSeverity severity, + const char *fileName, unsigned int line) { return LogMessage(fileName, line, category ? *category : LogCategory::defaultCategory(), |