// this test checks whether it is possible to write to a closed AsyncAppender
        void closeTest() 
        {
                LoggerPtr root = Logger::getRootLogger();
                LayoutPtr layout = new SimpleLayout();
                VectorAppenderPtr vectorAppender = new VectorAppender();
                AsyncAppenderPtr asyncAppender = new AsyncAppender();
                asyncAppender->setName(LOG4CXX_STR("async-CloseTest"));
                asyncAppender->addAppender(vectorAppender);
                root->addAppender(asyncAppender);

                root->debug(LOG4CXX_TEST_STR("m1"));
                asyncAppender->close();
                root->debug(LOG4CXX_TEST_STR("m2"));

                const std::vector<spi::LoggingEventPtr>& v = vectorAppender->getVector();
                LOGUNIT_ASSERT_EQUAL((size_t) 1, v.size());
        }
Exemple #2
0
// Used for initializing app main()
Memkeys * Memkeys::getInstance(int argc, char ** argv)
{
  Config * cfg = Config::getInstance();
  LoggerPtr mainLogger = Logger::getLogger("main");
  try {
    Cli::parse(argc, argv, cfg);
  } catch (const exception &ex) {
    throw MemkeysConfigurationError(ex.what());
  }
  mainLogger->setLevel(Level::INFO);
  mainLogger->info(CONTEXT,
                   "Starting application %s. PID %d", argv[0], getpid());
  Logger::getRootLogger()->setLevel(cfg->verbosity());
  mainLogger->debug("Configuration\n" + cfg->toString());
  return Memkeys::getInstance(cfg);
}
Exemple #3
0
		virtual void log(const std::string& file, int line, LogLevel level, const std::string& msg) {
			LocationInfo loc(file.c_str(), "", line);
			switch(level) {
				case INFO :
					m_logger->info(msg,loc);
					break;
				case DEBUG :
					m_logger->debug(msg,loc);
					break;
				case WARN :
					m_logger->warn(msg,loc);
					break;
				case ERROR :
					m_logger->error(msg,loc);
					break;
			}
		}
        // this test checks whether appenders embedded within an AsyncAppender are also
        // closed
        void test3()
        {
                size_t LEN = 200;
                LoggerPtr root = Logger::getRootLogger();
                VectorAppenderPtr vectorAppender = new VectorAppender();
                AsyncAppenderPtr asyncAppender = new AsyncAppender();
                asyncAppender->setName(LOG4CXX_STR("async-test3"));
                asyncAppender->addAppender(vectorAppender);
                root->addAppender(asyncAppender);

                for (size_t i = 0; i < LEN; i++) {
                        LOG4CXX_DEBUG(root, "message" << i);
                }

                asyncAppender->close();
                root->debug(LOG4CXX_TEST_STR("m2"));

                const std::vector<spi::LoggingEventPtr>& v = vectorAppender->getVector();
                LOGUNIT_ASSERT_EQUAL(LEN, v.size());
                LOGUNIT_ASSERT_EQUAL(true, vectorAppender->isClosed());
        }
PANTHEIOS_CALL(int) pantheios_be_logEntry(
  void*       /* feToken */
, void*       /* beToken */
, int         severity
, char const* entry
, size_t      cchEntry
)
{
  using namespace log4cxx;
  using namespace log4cxx::helpers;

  severity &= 0x07;

  LoggerPtr rootLogger = Logger::getRootLogger();

  switch(severity)
  {
    case  PANTHEIOS_SEV_EMERGENCY:
    case  PANTHEIOS_SEV_ALERT:
      rootLogger->fatal(entry);
      break;
    case  PANTHEIOS_SEV_CRITICAL:
    case  PANTHEIOS_SEV_ERROR:
      rootLogger->error(entry);
      break;
    case  PANTHEIOS_SEV_WARNING:
      rootLogger->warn(entry);
      break;
    case  PANTHEIOS_SEV_NOTICE:
    case  PANTHEIOS_SEV_INFORMATIONAL:
      rootLogger->info(entry);
      break;
    case  PANTHEIOS_SEV_DEBUG:
      rootLogger->debug(entry);
      break;
  }

  return cchEntry;
}
Exemple #6
0
void CLog4CXX::Debug(const char *loginfo)
{
    m_logger->debug(loginfo);
}