当前位置: 首页>>代码示例>>C++>>正文


C++ LogSink::Refresh方法代码示例

本文整理汇总了C++中LogSink::Refresh方法的典型用法代码示例。如果您正苦于以下问题:C++ LogSink::Refresh方法的具体用法?C++ LogSink::Refresh怎么用?C++ LogSink::Refresh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogSink的用法示例。


在下文中一共展示了LogSink::Refresh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Refresh

VOID ServLog::Refresh()
{
	LOG_SINK_TYPE OldActiveLogSinks = 0;
	LOG_SINK_TYPE NewActiveLogSinks = Config::GetActiveLogSinks();
	ULONG         Index;
	ServLog       *Inst = ServLog::GetInstance();

	//
	// Save off the original active log sinks
	//
	OldActiveLogSinks = Inst->ActiveSinkTypes;

	//
	// Walk each individual type, checking to see whether or not it's been
	// enabled.
	//
	for (Index = 0;
	     Index < (sizeof(LogSinkTypes) / sizeof(LOG_SINK_TYPE));
	     Index++)
	{
		// 
		// If this log sink type is enabled and was not previously enabled, we
		// instantiate it and add it to the list of active sinks.
		//
		if ((NewActiveLogSinks & LogSinkTypes[Index]) &&
		    (!(OldActiveLogSinks & LogSinkTypes[Index])))
		{
			LogSink *Sink = LogSink::create(
					LogSinkTypes[Index]);

			Log(LOG_SEV_INFO, TEXT("Enabling log sink type %lu."),
					LogSinkTypes[Index]);

			//
			// Add it to the list.
			//
			if (Sink)
				Inst->SinkList.push_back(
						Sink);
		}
		//
		// Otherwise, if the original log sink had this sink type enabled, we may
		// either need to remove it from the list of active sinks (if it's no
		// longer in the new set), or we may need to refresh its settings.
		//
		else if (OldActiveLogSinks & LogSinkTypes[Index])
		{
			std::list<LogSink *>::iterator It;

			for (It = Inst->SinkList.begin();
			     It != Inst->SinkList.end();
			     It++)
			{
				//
				// Did we find the type we're looking for?  If not, continue.
				//
				if ((*It)->GetType() != LogSinkTypes[Index])
					continue;

				LogSink *Sink = (*It);

				//
				// If this log sink type is no longer in the active set, then we
				// must remove it from the list of active log sinks.
				//
				if (!(NewActiveLogSinks & LogSinkTypes[Index]))
				{
					Inst->SinkList.erase(It);

					Log(LOG_SEV_INFO, TEXT("Disabling log sink type %lu."),
							LogSinkTypes[Index]);

					LogSink::destroy(
							Sink);

					break;
				}
				//
				// Otherwise, if it's been enabled and is still enabled, refresh it to
				// make sure everything is still good to go.
				//
				else
				{
					Log(LOG_SEV_INFO, TEXT("Refreshing log sink type %lu."),
							LogSinkTypes[Index]);

					Sink->Refresh();
				}
			}
		}
	}

	//
	// Update the active log sinks bitvector.
	//
	Inst->ActiveSinkTypes = NewActiveLogSinks;
}
开发者ID:340211173,项目名称:hf-2011,代码行数:97,代码来源:ServLog.cpp


注:本文中的LogSink::Refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。