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

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

Introduction

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

Prototype

void info(Object message, Throwable t);

Source Link

Document

Logs an error with info log level.

Usage

From source file:org.acmsl.queryj.tools.handlers.AbstractQueryJCommandHandler.java

/**
 * Retrieves the database product version.
 * @param metadata the database metadata.
 * @return such information, or null if the vendor complains.
 *///from w w  w.j a v a2  s . c  o  m
@Nullable
protected String retrieveDatabaseProductVersion(@NotNull final DatabaseMetaData metadata) {
    @Nullable
    String result = null;

    try {
        result = metadata.getDatabaseProductVersion();
    } catch (@NotNull final Throwable throwable) {
        @Nullable
        final Log t_Log = UniqueLogFactory.getLog(AbstractQueryJCommandHandler.class);

        if (t_Log != null) {
            t_Log.info("Database vendor complained when queried about " + "its version via "
                    + "java.sql.DatabaseMetaData.getDatabaseProductVersion()", throwable);
        }
    }

    return result;
}

From source file:org.acmsl.queryj.tools.handlers.JdbcConnectionClosingHandler.java

/**
 * Waits until all generation threads have finish.
 * @param tasks the tasks.//  w  w  w .j a  v a 2 s  . c o m
 * @param log the {@link Log} instance.
 */
protected void waitUntilGenerationThreadsFinish(
        @NotNull final List<Future<? extends QueryJTemplate<QueryJTemplateContext>>> tasks,
        @Nullable final Log log) {
    for (@Nullable
    final Future<? extends QueryJTemplate<QueryJTemplateContext>> t_Task : tasks) {
        if (t_Task != null) {
            while (!t_Task.isDone()) {
                try {
                    if (log != null) {
                        log.debug("Waiting for " + t_Task.get().getTemplateContext().getTemplateName()
                                + " to finish");
                    }
                } catch (@NotNull final InterruptedException interrupted) {
                    log.info(INTERRUPTED_WHILE_WAITING_FOR_THE_THREADS_TO_FINISH, interrupted);
                } catch (@NotNull final ExecutionException interrupted) {
                    log.info(interrupted.getMessage());

                    Throwable cause = interrupted.getCause();

                    while (cause != null) {
                        log.error(cause.getMessage(), cause);
                        cause = cause.getCause();
                    }
                }

                synchronized (LOCK) {
                    try {
                        LOCK.wait(1000);
                    } catch (@NotNull final InterruptedException interrupted) {
                        if (log != null) {
                            log.info(INTERRUPTED_WHILE_WAITING_FOR_THE_THREADS_TO_FINISH, interrupted);
                        }
                    }
                }
            }
        }
    }
}

From source file:org.alfresco.extension.bulkimport.util.LogUtils.java

public final static void info(final Log log, final String message, final Throwable cause) {
    log.info(PREFIX + message, cause);
}

From source file:org.alfresco.extension.bulkimport.util.LogUtils.java

public final static void info(final Log log, final Throwable cause) {
    log.info(RAW_EXCEPTION, cause);
}

From source file:org.amplafi.flow.impl.FlowStateLoggerImpl.java

public void info(Log logger, Object message, Throwable throwable) {
    if (logger == null) {
        logger = getLog();//from ww  w  .java  2s.c o m
    }
    StringBuilder stringBuilder = getFlowStatesString(message);
    logger.info(stringBuilder, throwable);
}

From source file:org.apache.hadoop.hdfs.TestDFSClientFailover.java

/**
 * Spy on the Java DNS infrastructure.//w w  w .j ava  2 s . com
 * This likely only works on Sun-derived JDKs, but uses JUnit's
 * Assume functionality so that any tests using it are skipped on
 * incompatible JDKs.
 */
private NameService spyOnNameService() {
    try {
        Field f = InetAddress.class.getDeclaredField("nameServices");
        f.setAccessible(true);
        Assume.assumeNotNull(f);
        @SuppressWarnings("unchecked")
        List<NameService> nsList = (List<NameService>) f.get(null);

        NameService ns = nsList.get(0);
        Log log = LogFactory.getLog("NameServiceSpy");

        ns = Mockito.mock(NameService.class, new GenericTestUtils.DelegateAnswer(log, ns));
        nsList.set(0, ns);
        return ns;
    } catch (Throwable t) {
        LOG.info("Unable to spy on DNS. Skipping test.", t);
        // In case the JDK we're testing on doesn't work like Sun's, just
        // skip the test.
        Assume.assumeNoException(t);
        throw new RuntimeException(t);
    }
}

From source file:org.displaytag.exception.BaseNestableJspTagException.java

/**
 * Instantiate a new BaseNestableJspTagException.
 * @param source Class where the exception is generated
 * @param message message//from   ww w  . j a v a  2 s. c o m
 * @param cause previous Exception
 */
public BaseNestableJspTagException(Class source, String message, Throwable cause) {
    super(message);
    this.sourceClass = source;
    this.nestedException = cause;

    // log exception
    Log log = LogFactory.getLog(source);

    // choose appropriate logging method
    if (getSeverity() == SeverityEnum.DEBUG) {
        log.debug(toString(), cause);
    } else if (getSeverity() == SeverityEnum.INFO) {
        log.info(toString(), cause);
    } else if (getSeverity() == SeverityEnum.WARN) {
        log.warn(toString(), cause);
    } else {
        // error - default
        log.error(toString(), cause);
    }

}

From source file:org.displaytag.exception.BaseNestableRuntimeException.java

/**
 * Instantiate a new BaseNestableRuntimeException.
 * @param source Class where the exception is generated
 * @param message message//  w  w w .j  a  v a  2 s .  c  om
 * @param cause previous Exception
 */
public BaseNestableRuntimeException(Class source, String message, Throwable cause) {
    super(message);
    this.sourceClass = source;
    this.nestedException = cause;

    // log exception
    Log log = LogFactory.getLog(source);

    // choose appropriate logging method
    if (getSeverity() == SeverityEnum.DEBUG) {
        log.debug(toString(), cause);
    } else if (getSeverity() == SeverityEnum.INFO) {
        log.info(toString(), cause);
    } else if (getSeverity() == SeverityEnum.WARN) {
        log.warn(toString(), cause);
    } else {
        // error - default
        log.error(toString(), cause);
    }

}

From source file:org.easyrec.utils.spring.log.LoggerUtils.java

/**
 * Writes the given 'message' to the Log 'logger' with level 'logLevel'.
 *
 * @param logger   the Log to which the message is written
 * @param logLevel the level to which the message is written
 * @param message  the message to be written
 * @param ta       a Throwable passed on to the Log
 *//*from w ww . j a  v  a  2 s.co  m*/
public static void log(Log logger, String logLevel, String message, Throwable ta) {
    if (logLevel.equalsIgnoreCase("info")) {
        if (logger.isInfoEnabled()) {
            logger.info(message, ta);
        }
    } else if (logLevel.equalsIgnoreCase("debug")) {
        if (logger.isDebugEnabled()) {
            logger.debug(message, ta);
        }
    } else if (logLevel.equalsIgnoreCase("error")) {
        if (logger.isErrorEnabled()) {
            logger.error(message, ta);
        }
    } else if (logLevel.equalsIgnoreCase("trace")) {
        if (logger.isTraceEnabled()) {
            logger.trace(message, ta);
        }
    } else if (logLevel.equalsIgnoreCase("warn")) {
        if (logger.isWarnEnabled()) {
            logger.warn(message, ta);
        }
    } else if (logLevel.equalsIgnoreCase("fatal")) {
        if (logger.isFatalEnabled()) {
            logger.fatal(message, ta);
        }
    } else {
        logger.error("Passed unknown log level " + logLevel + " to Aspect - logging to error instead!");
        logger.error(message, ta);
    }
}

From source file:org.jboss.netty.logging.CommonsLoggerTest.java

@Test
public void testInfoWithException() {
    org.apache.commons.logging.Log mock = createStrictMock(org.apache.commons.logging.Log.class);

    mock.info("a", e);
    replay(mock);/*from  w w w.jav  a2 s . com*/

    InternalLogger logger = new CommonsLogger(mock, "foo");
    logger.info("a", e);
    verify(mock);
}