コード例 #1
0
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;
      }
   }
}
コード例 #2
0
ファイル: LogService.cpp プロジェクト: aspectron/jsx
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);
}