예제 #1
0
파일: main.cpp 프로젝트: Amakata/wajima
double DelayedLoop(LoggerPtr logger, const String& msg)
{

    int64_t before = System::currentTimeMillis();
    int j = 0;
    for(int i = 0; i < runLength; i++)
	{
		logger->info(msg);
		if(j++ == burstLen)
		{
			j = 0;
			try
			{
				Thread::sleep(delay);
			}
			catch(Exception&)
			{
			}
		}
		
    }
    double actualTime = ((System::currentTimeMillis()-before)*1000.0/runLength);
    tcout << "actual time: " << actualTime << std::endl;
    return (actualTime - delay*DELAY_MULT);
}
예제 #2
0
파일: main.cpp 프로젝트: allenlz/memkeys
int main(int argc, char ** argv) {
  LoggerPtr logger = Logger::getLogger("main");
  Memkeys * app = NULL;
  int rc = EXIT_SUCCESS;

  logger->setLevel(Level::INFO);

  // configure and initialize the app
  try {
    app = Memkeys::getInstance(argc, argv);
  } catch(...) {
    return handleConfigurationError(logger, argv[0]);
  }

  // run the app
  try {
    app->run();
  } catch (const exception &ex) {
    logger->fatal(CONTEXT, "Error running application: %s", ex.what());
    rc = EXIT_FAILURE;
  }
  logger->info(CONTEXT, "Shutting down");

  // handle cleanup
  delete logger;
  delete app;
  delete Config::getInstance();
  delete Logger::getRootLogger();
  return rc;
}
예제 #3
0
파일: main.cpp 프로젝트: Amakata/wajima
double NoDelayLoop(LoggerPtr logger, const String& msg)
{
	int64_t before = System::currentTimeMillis();
    for(int i = 0; i < runLength; i++)
	{
		logger->info(msg, __FILE__, __LINE__);
    }
	int64_t after = System::currentTimeMillis();
	return ((after - before)*1000.0)/runLength;
}
예제 #4
0
파일: memkeys.cpp 프로젝트: allenlz/memkeys
// 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);
}
예제 #5
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;
			}
		}
예제 #6
0
파일: memkeys.cpp 프로젝트: allenlz/memkeys
// Signal handler for handling shutdowns
static void signal_cb(int signum)
{
  if (instance == NULL || instance->isShutdown()) {
    return;
  }
  LoggerPtr logger = Logger::getLogger("capture-engine");
  // alarm means timeout has expired
  if (signum == SIGALRM) {
    logger->warning(CONTEXT, "Alarm expired, forcing shutdown");
    instance->forceShutdown();
  } else if (instance->isRunning()) {
    logger->info(CONTEXT, "Shutting down due to signal");
    instance->tryShutdown();
    // if we haven't shut down in 2 seconds, alarm and force it
    signal(SIGALRM, signal_cb);
    alarm(2);
  } else {
    logger->warning(CONTEXT, "Ignoring signal, already shutting down: %s",
                    instance->getStateName().c_str());
  }
}
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;
}
예제 #8
0
void CLog4CXX::Info(const char *loginfo)
{
    m_logger->info(loginfo);
}