LogIface class

The LogIface class contains methods that let you incrementally build the text of a log entry from parts and then send the entry to the log with one call:

To create a LogIface class instance, pass one of the LogLevel enumerators to the class constructor. An example of using functions of the LogIface class is provided in the "Merging messages" subsection under Advanced capabilities when sending messages to a log.

A description of the LogIface class is provided in the file /opt/KasperskyOS-Community-Edition-<version>/sysroot-*-kos/include/component/logrr/cpp/tools.h.

component/logrr/cpp/tools.h (fragment)

/**

* @brief C++ provider interface for logrr for simple printing and queuing logs

* */

class LogIface

{

// ...

public:

LogIface(logrr::LogLevel level, sl::source_location loc = sl::source_location::current()) : m_level(level), m_defaultSourceLocation(loc)

{}

void SetLogLevel(logrr::LogLevel new_level)

{

m_level = new_level;

}

/**

* @brief Append new format with args to current message template

* */

template <typename... Args>

void Push(std::string_view frmt, Args&&... args)

{

AppendFormat(m_message, frmt, std::forward<Args>(args)...);

}

/**

* @brief Log instantly through separate Log command

* */

template <typename... Args>

void Log(FormatWithLocation frmt, Args&&... args)

{

Flush_(frmt.loc, frmt.frmt, std::forward<Args>(args)...);

}

/**

* @brief Flush current message, built with Push, to Log

* */

void Flush(const sl::source_location& loc = sl::source_location::current())

{

Flush_(loc, m_message);

m_message.clear();

}

~LogIface()

{

if (!m_message.empty())

{

Flush_(m_defaultSourceLocation, m_message);

}

}

// ...

};

Page top