Example usage for org.apache.commons.logging Log isInfoEnabled

List of usage examples for org.apache.commons.logging Log isInfoEnabled

Introduction

In this page you can find the example usage for org.apache.commons.logging Log isInfoEnabled.

Prototype

boolean isInfoEnabled();

Source Link

Document

Is info logging currently enabled?

Usage

From source file:org.xflatdb.xflat.db.TableMetadataFactory.java

/**
 * Gets the metadata document for the given table name.
 * @param name The table name for which to get the metadata document.
 * @return A Document representing the metadata associated to the table.
 *//*  ww  w .  j a va  2s .  co  m*/
public Document getMetadataDoc(String name) {
    try {
        return this.wrapper.readFile(name + ".config.xml");
    } catch (IOException | JDOMException ex) {
        Log log = LogFactory.getLog(getClass());
        if (log.isInfoEnabled())
            log.info(String.format("corrupt metadata file: %s.config.xml in directory %s", name,
                    this.wrapper.toString()), ex);

        return null;
    }
}

From source file:org.xflatdb.xflat.db.TableMetadataFactory.java

/**
 * Creates a TableMetadata for the given engine.  This TableMetadata object
 * does not have the ID generator or table config, so it can function only as
 * an EngineProvider.  Do not call {@link TableMetadata#getTable(java.lang.Class) } on the
 * resulting object./*w w w  .  ja  v  a 2 s . c  om*/
 * @param name The name of the table.
 * @param engineFile The file where the engine data should be stored.
 * @return A new TableMetadata object.
 */
public TableMetadata makeTableMetadata(String name, File engineFile) {
    Document doc;

    try {
        doc = this.wrapper.readFile(name + ".config.xml");
    } catch (IOException | JDOMException ex) {
        Log log = LogFactory.getLog(getClass());
        if (log.isInfoEnabled())
            log.info(String.format("corrupt metadata file: %s.config.xml in directory %s", name,
                    this.wrapper.toString()), ex);

        doc = null;
    }

    TableMetadata ret = new TableMetadata(name, db, engineFile);

    if (doc == null) {
        //no need for config or ID generator
        ret.engineMetadata = new Element("engine", XFlatConstants.xFlatNs);
    } else {
        //load engine
        ret.engineMetadata = doc.getRootElement().getChild("engine", XFlatConstants.xFlatNs);
        if (ret.engineMetadata == null) {
            ret.engineMetadata = new Element("engine", XFlatConstants.xFlatNs);
        }
    }

    return ret;
}

From source file:org.xflatdb.xflat.db.TableMetadataFactory.java

/**
 * Creates a TableMetadata for the given table information.
 * @param name The name of the table//from ww  w. j a va  2s. c  o m
 * @param engineFile The file locating the engine.
 * @param config The configuration of the table, null to use {@link TableConfig#DEFAULT}
 * @param idType The type of the ID property for the table.
 * @return A table metadata for the given table.
 */
public TableMetadata makeTableMetadata(String name, File engineFile, TableConfig config, Class<?> idType) {
    Document doc;
    TableMetadata ret;
    try {
        doc = this.wrapper.readFile(name + ".config.xml");
    } catch (IOException | JDOMException ex) {
        Log log = LogFactory.getLog(getClass());
        if (log.isInfoEnabled())
            log.info(String.format("regenerating corrupt metadata file: %s.config.xml in directory %s", name,
                    this.wrapper.toString()), ex);

        doc = null;
    }

    if (doc == null) {
        ret = makeNewTableMetadata(name, engineFile, config, idType);
    } else {
        ret = makeTableMetadataFromDocument(name, engineFile, doc, config, idType);
    }

    return ret;
}

From source file:rocket.logging.server.CommonsLoggingService.java

@Override
protected Logger createLoggerAdapter(final String loggerName) {
    final Log log = LogFactory.getLog(loggerName);
    return new Logger() {
        public void debug(final String message) {
            log.debug(message);/*from   w  w  w  .j  a  v a 2 s  .c o  m*/
        }

        public void debug(final String message, final Throwable throwable) {
            log.debug(message, throwable);
        }

        public void info(final String message) {
            log.info(message);
        }

        public void info(final String message, final Throwable throwable) {
            log.info(message, throwable);
        }

        public void warn(final String message) {
            log.warn(message);
        }

        public void warn(final String message, final Throwable throwable) {
            log.warn(message, throwable);
        }

        public void error(final String message) {
            log.error(message);
        }

        public void error(final String message, final Throwable throwable) {
            log.error(message, throwable);
        }

        public void fatal(final String message) {
            log.fatal(message);
        }

        public void fatal(final String message, final Throwable throwable) {
            log.fatal(message, throwable);
        }

        public boolean isDebugEnabled() {
            return log.isDebugEnabled();
        }

        public boolean isInfoEnabled() {
            return log.isInfoEnabled();
        }

        public boolean isWarnEnabled() {
            return log.isWarnEnabled();
        }

        public boolean isErrorEnabled() {
            return log.isErrorEnabled();
        }

        public boolean isFatalEnabled() {
            return log.isFatalEnabled();
        }
    };
}

From source file:uk.co.modularaudio.service.audioproviderregistry.AudioTestResults.java

public void logResults(final Log log) {
    // Only interested in the hardware underflows / overflows
    final long totalErrors = numHardOverflows + numHardUnderflows;
    float percentageErrors = 0.0f;
    if (numPeriodsRecorded > 0) {
        percentageErrors = (float) totalErrors / (float) numPeriodsRecorded;
    }/*from w  ww . j  a v a  2s .c o  m*/
    if (log.isInfoEnabled()) {
        log.info("Test had " + // NOPMD by dan on 01/02/15 07:07
                numSoftOverflows + " soft overflows and " + numSoftUnderflows + " soft underflows for "
                + numHardOverflows + " hard overflows and " + numHardUnderflows + " hard underflows for "
                + numPeriodsRecorded + " periods recorded");
        log.info("This is " + percentageErrors + " percent hard errors"); // NOPMD by dan on 01/02/15 07:07
    }
}