Exemple #1
0
int handleConfigurationError(LoggerPtr logger, const char *progname) {
  try {
    throw;
  } catch (const MemkeysConfigurationError &er) {
    logger->fatal(CONTEXT,
                  "Error configuring %s: %s", PACKAGE_NAME, er.what());
    cout << Cli::help(progname);
    return EXIT_FAILURE;
  } catch (const MemkeysException &ex) {
    logger->fatal(CONTEXT, "Error setting up application: %s", ex.what());
    return EXIT_FAILURE;
  } catch (...) {
    logger->fatal("Unexpected failure");
    throw;
  }
}
Exemple #2
0
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;
}
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 #4
0
void CLog4CXX::Fatal(const char *loginfo)
{
    m_logger->fatal(loginfo);
}