Package org.apache.avalon.framework.logger

Examples of org.apache.avalon.framework.logger.Logger


     * @return true if the file contains the string, false otherwise.
     * @throws IOException
     */
    public static boolean containsPattern(File file, Pattern pattern) throws IOException {
       
        Logger log = new ConsoleLogger();

        FileChannel fc = null;
    // Open the file and then get a channel from the stream
        FileInputStream fis = null;
    boolean result = false;

    try {
      fis = new FileInputStream(file);
      fc = fis.getChannel();

      // Get the file's size and then map it into memory
      int sz = (int)fc.size();
      MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);

      // Decode the file into a char buffer
      CharBuffer cb = decoder.decode(bb);

      // Perform the search
      Matcher pm = pattern.matcher(cb); // Pattern matcher

      result = pm.find();
    } catch (FileNotFoundException e) {
      log.error("File not found: " +e.toString());
    } catch (CharacterCodingException e) {
      log.error("Problem with encoding: " +e.toString());
    } catch (IOException e) {
      log.error("IO Exception: " +e.toString());
    } finally {
          // Close the channel and the stream
          if (fc != null)
              fc.close();
          if (fis != null)
View Full Code Here


     * (i.e. the groupth group of the match)
     * @throws IOException if the file could not be read.
     */
    public static String[] findPattern(File file, Pattern pattern, int group) throws IOException {

        Logger log = new ConsoleLogger();

        ArrayList occurences = new ArrayList();
        FileInputStream fis = null;
        FileChannel fc = null;

        try {
            // Open the file and then get a channel from the stream
            fis = new FileInputStream(file);
            fc = fis.getChannel();

            // Get the file's size and then map it into memory
            int sz = (int)fc.size();
            MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);

            // Decode the file into a char buffer
            CharBuffer cb = decoder.decode(bb);

            // Perform the search
            Matcher pm = pattern.matcher(cb); // Pattern matcher

            while (pm.find()) {
                occurences.add(pm.group(group));
            }
        } catch (FileNotFoundException e) {
            log.error("file not found " +e.toString());
        } catch (CharacterCodingException e) {
            log.error("encoding problem " +e.toString());
        } catch (IOException e) {
            log.error("IO exception" +e.toString());
        } finally {
          // Close the channel and the stream
          if (fc != null)
              fc.close();
          if (fis != null)
View Full Code Here

    /**
     * Dumps an error
     */
    public void dumpError(Exception e) {
        if (_errorDump) {
            Logger log = getLogger();
            if (e instanceof SAXException) {
                log.error("", e);
                if (((SAXException)e).getException() != null) {
                    log.error("", ((SAXException)e).getException());
                }
            } else if (e instanceof FOPException) {
                e.printStackTrace();
                if (((FOPException)e).getException() != null) {
                    log.error("", ((FOPException)e).getException());
                }
            } else {
                log.error("", e);
            }
        }
    }
View Full Code Here

            }

            XMLReader parser = inputHandler.getParser();
            setParserFeatures(parser);

            Logger logger = log.getChildLogger("fop");
            Driver driver = new Driver();
            driver.setLogger(logger);
            if (outputPDF) {
                driver.setRenderer(Driver.RENDER_PDF);
            } else {
View Full Code Here

        Map options = new java.util.HashMap();
        String[] arguments = parseArguments(options, args);

        PFMReader app = new PFMReader();
        Logger log;
        if (options.get("-d") != null) {
            log = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG);
        } else {
            log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
        }
        app.enableLogging(log);
       
        //app.invokedStandalone = true;

        log.info("PFM Reader v1.1");
        log.info("");

        if (options.get("-ef") != null) {
            embFile = (String)options.get("-ef");
        }
View Full Code Here

            case Project.MSG_INFO   : logLevel = ConsoleLogger.LEVEL_INFO; break;
            case Project.MSG_WARN   : logLevel = ConsoleLogger.LEVEL_WARN; break;
            case Project.MSG_ERR    : logLevel = ConsoleLogger.LEVEL_ERROR; break;
            case Project.MSG_VERBOSE: logLevel = ConsoleLogger.LEVEL_DEBUG; break;
        }
        Logger log = new ConsoleLogger(logLevel);
        MessageHandler.setScreenLogger(log);
        try {
            Starter starter = new FOPTaskStarter(this, log, logFiles);
            starter.run();
        } catch (FOPException ex) {
View Full Code Here

            String msg = "Creating the ServiceContainer failed";
            ServiceContainerFactory.logger.error( msg, e );
            throw e;
        }

        Logger serviceContainerLogger = serviceManagerConfig.getLogger();

        serviceContainerLogger.debug(
            "Using the following configuration : "
            + ConfigurationUtil.toString( configuration )
            );

        ContainerUtil.enableLogging( result, serviceManagerConfig.getLogger() );
View Full Code Here

            componentFlavour
            );

        // create the remaining Avalon artifacts for the service component

        Logger serviceComponentLogger = this.getLogger().getChildLogger(
            roleEntry.getLogCategory()
            );

        Configuration serviceComponentConfiguraton = this.getServiceConfiguration().getChild(
            roleEntry.getShorthand()
View Full Code Here

        LoggerManager lm = new Log4JLoggerManager();

        // Setup the RoleManager
        DefaultRoleManager roles = new DefaultRoleManager();

        Logger logger = lm.getLoggerForCategory(AVALON_LOG_CATEGORY);

        roles.enableLogging(logger);
        roles.configure(roleConfig);

        // Setup ECM
View Full Code Here

     * Create the Avalon logger to be passed to YAAFI
     * @return an Avalon Logger
     */
    protected Logger createAvalonLogger()
    {
        Logger result = new CommonsLogger(log, AVALON_LOG_CATEGORY);
        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.logger.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.