libcamera: libcamera::LogMessage Class Reference

libcamera v0.3.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
Public Member Functions | List of all members
libcamera::LogMessage Class Reference

Internal log message representation. More...

## Public Member Functions
| LogMessage (const char *fileName, unsigned int line, const LogCategory &category, LogSeverity severity, const std::string &prefix=std::string())
| Construct a log message for a given category.
| LogMessage (LogMessage &&)
| Move-construct a log message.
std::ostream & | stream ()
const utils::time_point & | timestamp () const
| Retrieve the timestamp of the log message.
LogSeverity | severity () const
| Retrieve the severity of the log message.
const LogCategory & | category () const
| Retrieve the category of the log message.
const std::string & | fileInfo () const
| Retrieve the file info of the log message.
const std::string & | prefix () const
| Retrieve the prefix of the log message.
const std::string | msg () const
| Retrieve the message text of the log message.

## Detailed Description

Internal log message representation.

The LogMessage class models a single message in the log. It serves as a helper to provide the std::ostream API for logging, and must never be used directly. Use the LOG() macro instead access the log infrastructure.

## Constructor & Destructor Documentation

## ◆ LogMessage() [1/2]

libcamera::LogMessage::LogMessage | ( | const char * | fileName,
|  | unsigned int | line,
|  | const LogCategory & | category,
|  | LogSeverity | severity,
|  | const std::string & | prefix = std::string() )

Construct a log message for a given category.

Parameters

  [in] | fileName | The file name where the message is logged from
  [in] | line | The line number where the message is logged from
  [in] | category | The log message category, controlling how the message will be displayed
  [in] | severity | The log message severity, controlling how the message will be displayed
  [in] | prefix | The log message prefix

Create a log message pertaining to line line of file fileName. The severity argument sets the message severity to control whether it will be output or dropped. The prefix optionally identifies the object instance logging the message.

## ◆ LogMessage() [2/2]

libcamera::LogMessage::LogMessage | ( | LogMessage && | other | ) |

Move-construct a log message.

Parameters

  [in] | other | The other message

The move constructor is meant to support the _log() functions. Thanks to copy elision it will likely never be called, but C++11 only permits copy elision, it doesn't enforce it unlike C++17. To avoid potential link errors depending on the compiler type and version, and optimization level, the move constructor is defined even if it will likely never be called, and ensures that the destructor of the other message will not output anything to the log by setting the severity to LogInvalid.

## Member Function Documentation

## ◆ category()

const LogCategory & libcamera::LogMessage::category | ( |  | ) | const
| inline

Retrieve the category of the log message.

Returns
  The category of the message

## ◆ fileInfo()

const std::string & libcamera::LogMessage::fileInfo | ( |  | ) | const
| inline

Retrieve the file info of the log message.

Returns
  The file info of the message

## ◆ msg()

const std::string libcamera::LogMessage::msg | ( |  | ) | const
| inline

Retrieve the message text of the log message.

Returns
  The message text of the message, as a string

## ◆ prefix()

const std::string & libcamera::LogMessage::prefix | ( |  | ) | const
| inline

Retrieve the prefix of the log message.

Returns
  The prefix of the message

## ◆ severity()

LogSeverity libcamera::LogMessage::severity | ( |  | ) | const
| inline

Retrieve the severity of the log message.

Returns
  The severity of the message

## ◆ stream()

std::ostream & libcamera::LogMessage::stream | ( |  | ) |
| inline

Data is added to a LogMessage through the stream returned by this function. The stream implements the std::ostream API and can be used for logging as std::cout.

Returns
  A reference to the log message stream

## ◆ timestamp()

const utils::time_point & libcamera::LogMessage::timestamp | ( |  | ) | const
| inline

Retrieve the timestamp of the log message.

Returns
  The timestamp of the message

The documentation for this class was generated from the following files:

- include/libcamera/base/log.h
- src/libcamera/base/log.cpp