本文整理汇总了C++中Appender::layout方法的典型用法代码示例。如果您正苦于以下问题:C++ Appender::layout方法的具体用法?C++ Appender::layout怎么用?C++ Appender::layout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Appender
的用法示例。
在下文中一共展示了Appender::layout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initLog4Qt
void initLog4Qt(Level level) {
Log4Qt::Layout* layout;
Appender* appender = LogManager::rootLogger()->appender("A1");
if (appender) {
logger()->debug("initLogQt: using existing appender A1");
if (level != Level::INFO_INT) {
LogManager::rootLogger()->setLevel(level);
}
layout = appender->layout();
} else {
LogManager::rootLogger()->setLevel(level);
// Create console layout
TTCCLayout* tccLayout = new TTCCLayout();
tccLayout->setName("Layout");
tccLayout->setDateFormat(TTCCLayout::ABSOLUTEDATE);
tccLayout->setThreadPrinting(false);
tccLayout->activateOptions();
// Create appender A1 for console if level set through cmd line option
if (level != Level::INFO_INT) {
ConsoleAppender* a = new ConsoleAppender(tccLayout,
ConsoleAppender::STDERR_TARGET);
a->setName("A1");
a->activateOptions();
// Set appender on root logger
LogManager::rootLogger()->addAppender(a);
}
layout = tccLayout;
}
// Let Log4Qt handle qDebug(), qWarning(), qCritical() and qFatal()
LogManager::setHandleQtMessages(true);
LogManager::qtLogger()->setLevel(Logger::rootLogger()->level());
// Create appender A2 for log window
Gui::TLogWindow::appender = new Gui::TLogWindowAppender(layout);
Gui::TLogWindow::appender->setName("A2");
Gui::TLogWindow::appender->activateOptions();
// Set log window appender on root logger
LogManager::rootLogger()->addAppender(Gui::TLogWindow::appender);
logger()->info("initLog4Qt: root logger initialized on level %1",
LogManager::rootLogger()->level().toString());
}