Filter::FilterDecision StringMatchFilter::decide(
   const log4cxx::spi::LoggingEventPtr& event) const
{
   const LogString& msg = event->getRenderedMessage();

   if(msg.empty() || stringToMatch.empty())
   {
      return Filter::NEUTRAL;
   }


   if( msg.find(stringToMatch) == LogString::npos )
   {
      return Filter::NEUTRAL;
   }
   else
   { // we've got a match
      if(acceptOnMatch)
      {
         return Filter::ACCEPT;
      }
      else
      {
         return Filter::DENY;
      }
   }
}
Esempio n. 2
0
void LogServiceAppender::append(const log4cxx::spi::LoggingEventPtr& event)
{
    // custom layouts is not supported for log4cxx library
    std::string formatted_string(boost::lexical_cast<std::string>(event->getTimeStamp()));
    formatted_string += ' ';
    formatted_string += event->getLevel()->toString();
    formatted_string += ' ';
    formatted_string += event->getLoggerName();
    formatted_string += " - ";
    formatted_string += event->getRenderedMessage();
    formatted_string += '\n';
    addLogString(formatted_string);
}