Beispiel #1
0
static void test_logger() {
	ELoggerManager::init("log4e.properties");

	try {

		logger->info("xxxxxxxxxxxxxx");
		logger->warn_("xxxxxxxxxxxxxx%s", "z");

		throw EException(__FILE__, __LINE__, "exception:");
	} catch (EException& e) {
//		ELOG_E(logger, "xxxxxxxxxxxxxx[%s]", e.getMessage());
//		ELOG__E(logger, "xxxxxxxxxxxxxx", e);
		ELOG__E(logger, "message", e);
		logger->error(e);
		logger->error("message", e);
	}

	ELOG_E(logger, "format s=%d", 9999);

	ELOG_E(rootLogger, "root log s=%d", 9999);

	for (int i=0; i<5; i++) {
		ENDC::push(new EString(i));

		sp<ELogger> logger2 = ELoggerManager::getLogger("XXX");
		ELOG_E(logger2, "!@#$%%^&*(&^%@#%%&*\" i s=%d", i);
		logger2->close();

		delete ENDC::pop();
	}
	ENDC::clear();

	ELOG_E(logger, "ndc xxx");
}
Beispiel #2
0
//------------------------------------------------------------------------------
/// \brief Parses the string that was passed in
//------------------------------------------------------------------------------
void ArrayReaderParser::ParseString ()
{
  CStr msg("Incorrectly formated string in U2DREL");
  CToken t1(m_str, "\"");;
  CStr   str;

  try 
  {
    m_valid = true;
    str = t1.GetNextToken();
    {
      CToken token(str, " ");
      str = token.GetNextToken();
      if (str.CompareNoCase("HDF5") != 0)
        throw EException(msg);

      str = token.GetNextToken();
      // see if the string is "CONSTANT"
      if (str.CompareNoCase("constant") == 0)
      {
        m_const = true;
        str = token.GetNextToken();
      }

      // read the multiplier
      if(sscanf(str.c_str(), "%lf", &m_mult) != 1)
        throw EException(msg);

      str = token.GetNextToken(); // read the IPRN flag
      if (sscanf(str.c_str(), "%d", &m_IPRN) != 1)
        throw EException(msg);
    }
    if (m_const)
      return;

    m_file = t1.GetNextToken(); // read the filename
    if (m_file.IsEmpty())
      throw EException(msg);

    t1.GetNextToken();
    m_path = t1.GetNextToken(); // read the path
    if (m_path.IsEmpty())
      throw EException(msg);

    str = t1.GetNextToken();
    {
      CToken token(str, " ");
      str = token.GetNextToken(); // read the number of dimensions
      if ("1" != str && "2" != str && "3" != str)
        throw EException(msg);
      unsigned int nDim(0);
      if (sscanf(str.c_str(), "%d", &nDim) != 1)
        throw EException(msg);

      // read the indices so we know how to read the array
      std::pair<int, int> myPair;
      for (unsigned int i=0; i<nDim; i++)
      {
        myPair.first = myPair.second = 0;
        str = token.GetNextToken();
        if (sscanf(str.c_str(), "%d", &myPair.first) != 1)
          throw EException(msg);
        str = token.GetNextToken();
        if (sscanf(str.c_str(), "%d", &myPair.second) != 1)
          throw EException(msg);
        m_indices.push_back(myPair);
      }

      if (nDim != m_indices.size())
        throw EException(msg);
    }
  }
  catch (EException &e)
  {
    CStr out(e.what());
    if (!out.IsEmpty())
    {
      ErrorStack::Get().PutError(out);
    }
    m_valid = false;
  }
} // ArrayReaderParser::ParseString