VLink  2.3.0
A high-performance communication middleware
vlink::LoggerPluginInterface类 参考abstract

Pure-virtual interface that every shared-library logger backend implements. 更多...

#include <logger_plugin_interface.h>

vlink::LoggerPluginInterface 的协作图:

Public 成员函数

virtual bool init (std::string_view app_name) noexcept=0
 Initialises the backend immediately after the plugin instance is constructed. 更多...
 
virtual bool log (int level, std::string_view str) noexcept=0
 Writes a single record to the backend. 更多...
 
virtual void flush () noexcept
 Drains records accepted by log before this call. 更多...
 

Protected 成员函数

 LoggerPluginInterface ()=default
 
virtual ~LoggerPluginInterface ()=default
 

详细描述

Pure-virtual interface that every shared-library logger backend implements.

Concrete subclasses use VLINK_PLUGIN_REGISTER internally to expose their factory and destructor functions to the Plugin loader. Instances are owned by the host application for the duration of the plugin handle. When selected through VLINK_LOG_PLUGIN, init runs after the host Logger is constructed and supports same-thread Logger re-entry, so implementations may create VLink communication nodes there. Other threads can continue logging to the console while initialisation is in progress, but their records are not sent to the plugin.

构造及析构函数说明

◆ LoggerPluginInterface()

vlink::LoggerPluginInterface::LoggerPluginInterface ( )
protecteddefault

◆ ~LoggerPluginInterface()

virtual vlink::LoggerPluginInterface::~LoggerPluginInterface ( )
protectedvirtualdefault

成员函数说明

◆ flush()

virtual void vlink::LoggerPluginInterface::flush ( )
inlinevirtualnoexcept

Drains records accepted by log before this call.

Returns only after plugin-owned asynchronous work for earlier records has completed. A synchronous implementation can use the default no-op.

◆ init()

virtual bool vlink::LoggerPluginInterface::init ( std::string_view  app_name)
pure virtualnoexcept

Initialises the backend immediately after the plugin instance is constructed.

参数
app_nameCalling application name; may inform log labels or file paths.
返回
true on success; false to indicate the plugin must not be used further.

◆ log()

virtual bool vlink::LoggerPluginInterface::log ( int  level,
std::string_view  str 
)
pure virtualnoexcept

Writes a single record to the backend.

Implementations should be non-blocking; str remains valid only for the duration of the call. The host may call this method concurrently. Logs emitted synchronously by this method or its dependencies are not forwarded back into the same plugin.

参数
levelSeverity using vlink::Logger::Level values.
strFully formatted record.
返回
true on success; false to indicate a write error. The global Logger does not retry or redirect a failed plugin write.

该类的文档由以下文件生成: