Filter::FilterDecision LocationInfoFilter::decide()

in src/main/cpp/locationinfofilter.cpp [80:112]


Filter::FilterDecision LocationInfoFilter::decide(
	const log4cxx::spi::LoggingEventPtr& event) const
{
	if (priv->lineNumber == -1 &&
			priv->methodName.empty())
	{
		return Filter::NEUTRAL;
	}

	if (event->getLocationInformation().getLineNumber() == -1 ||
			event->getLocationInformation().getMethodName().compare(LocationInfo::NA_METHOD) == 0){
		return Filter::NEUTRAL;
	}

	bool matched = false;
	bool matchLineNumber = priv->lineNumber == event->getLocationInformation().getLineNumber();
	bool matchMethodName = priv->methodName.compare(event->getLocationInformation().getMethodName()) == 0;

	if(priv->mustMatchAll){
		matched = matchLineNumber && matchMethodName;
	}else{
		matched = matchLineNumber || matchMethodName;
	}

	if (priv->acceptOnMatch)
	{
		return matched ? Filter::ACCEPT : Filter::NEUTRAL;
	}
	else
	{
		return matched ? Filter::DENY : Filter::NEUTRAL;
	}
}