virtual void append(const log4cxx::spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool) { Info info; info.level_ = event->getLevel(); info.message_ = event->getMessage(); info.logger_name_ = event->getLoggerName(); info_.push_back( info ); }
virtual void append(const log4cxx::spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool) { (void)pool; levels::Level level; if (event->getLevel() == log4cxx::Level::getFatal()) { level = levels::Fatal; } else if (event->getLevel() == log4cxx::Level::getError()) { level = levels::Error; } else if (event->getLevel() == log4cxx::Level::getWarn()) { level = levels::Warn; } else if (event->getLevel() == log4cxx::Level::getInfo()) { level = levels::Info; } else if (event->getLevel() == log4cxx::Level::getDebug()) { level = levels::Debug; } else { return; } #ifdef _MSC_VER LOG4CXX_ENCODE_CHAR(tmpstr, event->getMessage()); // has to handle LogString with wchar types. std::string msg = tmpstr // tmpstr gets instantiated inside the LOG4CXX_ENCODE_CHAR macro #else std::string msg = event->getMessage(); #endif const log4cxx::spi::LocationInfo& info = event->getLocationInformation(); appender_->log(level, msg.c_str(), info.getFileName(), info.getMethodName().c_str(), info.getLineNumber()); }
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); }
Filter::FilterDecision LevelMatchFilter::decide( const log4cxx::spi::LoggingEventPtr& event) const { if(levelToMatch != 0 && levelToMatch->equals(event->getLevel())) { if(acceptOnMatch) { return Filter::ACCEPT; } else { return Filter::DENY; } } else { return Filter::NEUTRAL; } }