Package org.apache.uima.util

Examples of org.apache.uima.util.Logger


     * (non-Javadoc)
     *
     * @see org.apache.uima.jcas.jcasgen_gen.IError#newError(int, java.lang.String)
     */
    public void newError(int severity, String message, Exception ex) {
      Logger log = UIMAFramework.getLogger();
      log.log(logLevels[severity], "JCasGen: " + message); //$NON-NLS-1$
      System.out.println(Messages.getString("MultiPageEditor.JCasGenErr") //$NON-NLS-1$
              + message);
      if (null != ex)
        ex.printStackTrace();
      if (IError.WARN < severity) {
View Full Code Here


   * (non-Javadoc)
   *
   * @see org.apache.uima.jcas.jcasgen_gen.IError#newError(int, java.lang.String)
   */
  public void newError(int severity, String message, Exception exception) {
    Logger log = UIMAFramework.getLogger();
    log.log(logLevels[severity], "JCasGen: " + message, exception);
    if (IError.WARN < severity)
      throw new ErrorExit();
  }
View Full Code Here

  }

  public void testDefaultLoggerCreation() throws Exception {
    try {
      // get default logger
      Logger logger = UIMAFramework.getLogger();
      Assert.assertNotNull(logger);

      // create another logger
      Logger logger1 = UIMAFramework.getLogger();

      // both loggers must reference the same instance
      Assert.assertEquals(logger, logger1);

      // test base logging functions
View Full Code Here

  }

  public void testClassLoggerCreation() throws Exception {
    try {
      // get class logger
      Logger logger = UIMAFramework.getLogger(this.getClass());
      Assert.assertNotNull(logger);

      // create another class logger
      Logger logger1 = UIMAFramework.getLogger(this.getClass());

      // create default logger
      Logger defaultLogger = UIMAFramework.getLogger();

      // both loggers must reference the same instance
      Assert.assertEquals(logger, logger1);

      // should not be the same
View Full Code Here

  }

  public void testSetLevel() throws Exception {
    try {
      // get class logger
      Logger logger = UIMAFramework.getLogger(this.getClass());
      Logger uimaLogger = UIMAFramework.getLogger(); // should affect everything in
      // org.apache.uima.*

      // set level to WARNING
      uimaLogger.setLevel(Level.WARNING);
      Assert.assertTrue(uimaLogger.isLoggable(Level.WARNING));
      Assert.assertTrue(uimaLogger.isLoggable(Level.SEVERE));
      Assert.assertFalse(uimaLogger.isLoggable(Level.INFO));
      Assert.assertTrue(logger.isLoggable(Level.WARNING));
      Assert.assertTrue(logger.isLoggable(Level.SEVERE));
      Assert.assertFalse(logger.isLoggable(Level.INFO));

      // set level to FINE
      uimaLogger.setLevel(Level.FINE);
      Assert.assertTrue(uimaLogger.isLoggable(Level.WARNING));
      Assert.assertTrue(uimaLogger.isLoggable(Level.SEVERE));
      Assert.assertTrue(uimaLogger.isLoggable(Level.INFO));
      Assert.assertFalse(uimaLogger.isLoggable(Level.FINER));
      Assert.assertFalse(uimaLogger.isLoggable(Level.ALL));
      Assert.assertTrue(logger.isLoggable(Level.WARNING));
      Assert.assertTrue(logger.isLoggable(Level.SEVERE));
      Assert.assertTrue(logger.isLoggable(Level.INFO));
      Assert.assertFalse(logger.isLoggable(Level.FINER));
      Assert.assertFalse(logger.isLoggable(Level.ALL));
View Full Code Here

      // no log level was specified, use default log level settings "INFO" that is also
      // used by the Java logging framework.
      defaultLogLevel = Level.INFO;
    }
    // turn of logging for the performance test
    Logger logger = UIMAFramework.getLogger();
    logger.setLevel(Level.OFF);

    //create timer
    Timer globalTimer = new Timer();
    Timer initTimer = new Timer();
    Timer warmupTimer = new Timer();
    Timer ioTimer = new Timer();
    Timer processResetTimer = new Timer();
    Timer cleanupTimer = new Timer();
    Timer documentPreparationTimer = new Timer();
   
    //start timer for global time
    globalTimer.start();

    // init analysis engine
    try {

      // start initialization timer  
      initTimer.start();
     
      // set datapath
      ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
      if (dataPath != null) {
        resMgr.setDataPath(dataPath);
      }

      AnalysisEngine ae = null;
      CAS cas = null;
      // get resource specifier from XML file
      XMLInputSource in = new XMLInputSource(taeDescFilePath);
      ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);

      // create analysis engine with resource manager
      ae = UIMAFramework.produceAnalysisEngine(specifier, resMgr, null);
      // check ae
      Assert.assertNotNull(ae);

      // create new cas
      cas = ae.newCAS();
      // check cas
      Assert.assertNotNull(cas);

      // access cas type system
      cas.getTypeSystem().getFeatureByFullName(CAS.FEATURE_FULL_NAME_LANGUAGE);

      // stop initalization timer
      initTimer.stop();
      result.setInitTime(initTimer.getTimeSpan());

      if (doWarmup) {
        // start warmup timer    
        warmupTimer.start();

        // process dummy document
        cas.setDocumentLanguage("en");
        cas.setDocumentText("This is a test sentence.");
        ae.process(cas);
        cas.reset();

        // stop warmup timer
        warmupTimer.stop();
        result.setWarmupTime(warmupTimer.getTimeSpan());
      }

      // start io timer
      ioTimer.start();

      // read all files in the test file directory
      File[] inputFiles = testFileDir.listFiles(new FileFileFilter());
      // create string array for the file content and language
      String[] fileTexts = new String[inputFiles.length];
      String[] languages = new String[inputFiles.length];
      int numChars = 0;
      long fileSize = 0;
      // iterate of all input files and extract content and language
      for (int i = 0; i < inputFiles.length; i++) {
        // get file language
        languages[i] = inputFiles[i].getName().substring(0, 2);
        // get file content
        fileTexts[i] = FileUtils.file2String(inputFiles[i], "UTF-8");
        fileSize += inputFiles[i].length();
        // count characters
        numChars += fileTexts[i].length();
      }

      // stop io timer
      ioTimer.stop();

      // save results
      result.setNumberOfFiles(inputFiles.length);
      result.setNumberOfCharacters(numChars);
      result.setTotalFileSize(fileSize);
      result.setIoTime(ioTimer.getTimeSpan());

      // start real processing
      int numAnnot = 0;

      // check repeat single mode setting
      // repeatSingle=true: iterates of all files and repeat each file "numsToRun" times
      // repeatSingle=false: iterates of all files and repeat the collection "numsToRun" times
      if (repeatSingle) {
        // iterate over all text files (over the cached content)
        for (int i = 0; i < fileTexts.length; i++) {
          // file repeat mode
          // iterate over the current document "numsToRun" times
          for (int j = 0; j < numsToRun; j++) {
            documentPreparationTimer.start();
            // set cas data
            cas.setDocumentLanguage(languages[i]);
            cas.setDocumentText(fileTexts[i]);
            documentPreparationTimer.stop();
            processResetTimer.start();
            ae.process(cas);
            processResetTimer.stop();
            documentPreparationTimer.start();
            numAnnot += cas.getAnnotationIndex().size();
            cas.reset();
            documentPreparationTimer.stop();
          }
        }
      }
      // use collection repeat mode
      else {
        // process the file collection "numsToRun" times
        for (int j = 0; j < numsToRun; j++) {
          // iterate over all text files (over the cached content)
          for (int i = 0; i < fileTexts.length; i++) {
            documentPreparationTimer.start();
            // set cas data
            cas.setDocumentLanguage(languages[i]);
            cas.setDocumentText(fileTexts[i]);
            documentPreparationTimer.stop();
            processResetTimer.start();
            ae.process(cas);
            processResetTimer.stop();
            documentPreparationTimer.start();
            numAnnot += cas.getAnnotationIndex().size();
            cas.reset();
            documentPreparationTimer.stop();
          }
        }
      }

      // cleanup ae and stop global timer
      cleanupTimer.start();
      ae.destroy();
      ae = null;
      cleanupTimer.stop();
      globalTimer.stop();

      // save results
      result.setNumberOfCreatedAnnotations(numAnnot);
      result.setOverallTime(globalTimer.getTimeSpan());
      result.setProcessingTime(processResetTimer.getTimeSpan());
      result.setCleanupTime(cleanupTimer.getTimeSpan());
      result.setDocumentPreparationTime(documentPreparationTimer.getTimeSpan());

      // turn on logging as it was before
      logger.setLevel(defaultLogLevel);

      // return result object
      return result;

    } catch (Exception e) { // Bail out.
View Full Code Here

        resMgr = UIMAFramework.newDefaultResourceManager();
      }

      // get a Logger for this class and set its ResourceManager so that
      // UIMA extension ClassLoader is used to locate message digests.
      Logger logger = UIMAFramework.getLogger(this.getClass());
      logger.setResourceManager(resMgr);

      // create and initialize UIMAContext
      mUimaContextAdmin = UIMAFramework.newUimaContext(logger, resMgr, UIMAFramework
              .newConfigurationManager());

    } else {
      // configure logger of the UIMA context so that class-specific logging
      // levels and UIMA extension classLoader will work
      // get a Logger for this class and set its ResourceManager so that
      // UIMA extension ClassLoader is used to locate message digests.
      Logger logger = UIMAFramework.getLogger(this.getClass());
      logger.setResourceManager(mUimaContextAdmin.getResourceManager());
      mUimaContextAdmin.setLogger(logger);
    }

    // if this is a local resource (instantaited from a ResourceCreationSpecifier),
    // initialize the ResourceManager and UIMA Context.
View Full Code Here

      // declares any input or output sofas in its capabilities)
      mSofaAware = getProcessingResourceMetaData().isSofaAware();
     
      // Set Logger, to enable component-specific logging configuration
      UimaContextAdmin uimaContext = getUimaContextAdmin();
      Logger logger = UIMAFramework.getLogger(mFlowController.getClass());
      logger.setResourceManager(this.getResourceManager());
      uimaContext.setLogger(logger);     
     
      // initialize FlowController
      mFlowController.initialize(getFlowControllerContext());
View Full Code Here

                  annotatorClassName, mDescription.getSourceUrlString() }, e);
    }

    // Set Logger, to enable annotator-specific logging
    UimaContextAdmin uimaContext = getUimaContextAdmin();
    Logger logger = UIMAFramework.getLogger(annotatorClass);
    logger.setResourceManager(this.getResourceManager());
    uimaContext.setLogger(logger);

    // initialize AnalysisComponent
    try {
      mAnalysisComponent.initialize(getUimaContext());
View Full Code Here

  }

  @Deprecated
  public void log(String aMessage) {
    if (context != null) {
      Logger logger = context.getLogger();
      if (logger != null) {
        logger.log(aMessage);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.util.Logger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.