本文整理汇总了C++中Appender::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ Appender::getId方法的具体用法?C++ Appender::getId怎么用?C++ Appender::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Appender
的用法示例。
在下文中一共展示了Appender::getId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateAppenderFromConfig
void Log::CreateAppenderFromConfig(std::string const& appenderName)
{
if (appenderName.empty())
return;
// Format=type, level, flags, optional1, optional2
// if type = File. optional1 = file and option2 = mode
// if type = Console. optional1 = Color
std::string options = sConfigMgr->GetStringDefault(appenderName.c_str(), "");
Tokenizer tokens(options, ',');
Tokenizer::const_iterator iter = tokens.begin();
size_t size = tokens.size();
std::string name = appenderName.substr(9);
if (size < 2)
{
fprintf(stderr, "Log::CreateAppenderFromConfig: Wrong configuration for appender %s. Config line: %s\n", name.c_str(), options.c_str());
return;
}
AppenderFlags flags = APPENDER_FLAGS_NONE;
AppenderType type = AppenderType(atoi(*iter++));
LogLevel level = LogLevel(atoi(*iter++));
if (level > LOG_LEVEL_FATAL)
{
fprintf(stderr, "Log::CreateAppenderFromConfig: Wrong Log Level %d for appender %s\n", level, name.c_str());
return;
}
if (size > 2)
flags = AppenderFlags(atoi(*iter++));
auto factoryFunction = appenderFactory.find(type);
if (factoryFunction == appenderFactory.end())
{
fprintf(stderr, "Log::CreateAppenderFromConfig: Unknown type %d for appender %s\n", type, name.c_str());
return;
}
try
{
Appender* appender = factoryFunction->second(NextAppenderId(), name, level, flags, ExtraAppenderArgs(iter, tokens.end()));
appenders[appender->getId()] = appender;
}
catch (InvalidAppenderArgsException const& iaae)
{
fprintf(stderr, "%s", iaae.what());
}
}