一、功能描述
Layout 在Logcpp中實現日誌輸出格式的控制,組件接口如下所示
/**
* Extend this abstract class to create your own log layout format.
控制日誌的輸出格式
**/
class LOG4CPP_EXPORT Layout
{
public:
/**
* Destructor for Layout.
**/
virtual ~Layout() { };
/**
* Formats the LoggingEvent data to a string that appenders can log.
* Implement this method to create your own layout format.
* @param event The LoggingEvent.
* @returns an appendable string.
**/
virtual std::string format(const LoggingEvent& event) = 0;
};
二、組價類圖如下圖所示,4種實現類完成了format 接口的具體實現
其中PatternLayout 中實現了多種定義好的輸出格式