Класс LogIface

Класс LogIface содержит методы, позволяющие поэтапно получить текст записи журнала из частей, и затем отправить запись в журнал одним вызовом:

Чтобы создать экземпляр класса LogIface, передайте один из перечислителей LogLevel в конструктор класса. Пример использования функций класса LogIface представлен в подразделе "Объединение сообщений" раздела "Дополнительные возможности при отправке сообщений в журнал".

Описание класса LogIface представлено в файле /opt/KasperskyOS-Community-Edition-<version>/sysroot-*-kos/include/component/logrr/cpp/tools.h.

component/logrr/cpp/tools.h (фрагмент)

/**

* @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);

}

}

// ...

};

В начало