Search in sources :

Example 31 with Log

use of org.apache.commons.logging.Log in project ant by apache.

the class CommonsLoggingListener method getLog.

private Log getLog(String cat, String suffix) {
    if (suffix != null) {
        suffix = suffix.replace('.', '-');
        suffix = suffix.replace(' ', '-');
        cat = cat + "." + suffix;
    }
    final PrintStream tmpOut = System.out;
    final PrintStream tmpErr = System.err;
    System.setOut(out);
    System.setErr(err);
    if (!initialized) {
        try {
            logFactory = LogFactory.getFactory();
        } catch (final LogConfigurationException e) {
            e.printStackTrace(System.err);
            return null;
        }
    }
    initialized = true;
    final Log log = logFactory.getInstance(cat);
    System.setOut(tmpOut);
    System.setErr(tmpErr);
    return log;
}
Also used : PrintStream(java.io.PrintStream) Log(org.apache.commons.logging.Log) LogConfigurationException(org.apache.commons.logging.LogConfigurationException)

Example 32 with Log

use of org.apache.commons.logging.Log in project ant by apache.

the class CommonsLoggingListener method targetFinished.

/**
 * @see BuildListener#targetFinished
 * {@inheritDoc}.
 */
@Override
public void targetFinished(final BuildEvent event) {
    if (initialized) {
        final String targetName = event.getTarget().getName();
        final Log log = getLog(TARGET_LOG, event.getTarget().getName());
        if (event.getException() == null) {
            realLog(log, "Target end: " + targetName, Project.MSG_DEBUG, null);
        } else {
            realLog(log, "Target \"" + targetName + "\" finished with error.", Project.MSG_ERR, event.getException());
        }
    }
}
Also used : Log(org.apache.commons.logging.Log)

Example 33 with Log

use of org.apache.commons.logging.Log in project ant by apache.

the class CommonsLoggingListener method taskStarted.

/**
 * @see BuildListener#taskStarted
 * {@inheritDoc}.
 */
@Override
public void taskStarted(final BuildEvent event) {
    if (initialized) {
        final Task task = event.getTask();
        Object real = task;
        if (task instanceof UnknownElement) {
            final Object realObj = ((UnknownElement) task).getTask();
            if (realObj != null) {
                real = realObj;
            }
        }
        final Log log = getLog(real.getClass().getName(), null);
        if (log.isTraceEnabled()) {
            realLog(log, "Task \"" + task.getTaskName() + "\" started ", Project.MSG_VERBOSE, null);
        }
    }
}
Also used : Task(org.apache.tools.ant.Task) Log(org.apache.commons.logging.Log) UnknownElement(org.apache.tools.ant.UnknownElement)

Example 34 with Log

use of org.apache.commons.logging.Log in project ant by apache.

the class CommonsLoggingListener method targetStarted.

/**
 * @see BuildListener#targetStarted
 * {@inheritDoc}.
 */
@Override
public void targetStarted(final BuildEvent event) {
    if (initialized) {
        final Log log = getLog(TARGET_LOG, event.getTarget().getName());
        // Since task log category includes target, we don't really
        // need this message
        realLog(log, "Start: " + event.getTarget().getName(), Project.MSG_VERBOSE, null);
    }
}
Also used : Log(org.apache.commons.logging.Log)

Example 35 with Log

use of org.apache.commons.logging.Log in project ant by apache.

the class CommonsLoggingListener method messageLogged.

/**
 * @see BuildListener#messageLogged
 * {@inheritDoc}.
 */
@Override
public void messageLogged(final BuildEvent event) {
    if (initialized) {
        Object categoryObject = event.getTask();
        String categoryString;
        String categoryDetail = null;
        if (categoryObject == null) {
            categoryObject = event.getTarget();
            if (categoryObject == null) {
                categoryString = PROJECT_LOG;
                categoryDetail = event.getProject().getName();
            } else {
                categoryString = TARGET_LOG;
                categoryDetail = event.getTarget().getName();
            }
        } else {
            // It's a task - append the target
            if (event.getTarget() != null) {
                categoryString = categoryObject.getClass().getName();
                categoryDetail = event.getTarget().getName();
            } else {
                categoryString = categoryObject.getClass().getName();
            }
        }
        final Log log = getLog(categoryString, categoryDetail);
        final int priority = event.getPriority();
        final String message = event.getMessage();
        realLog(log, message, priority, null);
    }
}
Also used : Log(org.apache.commons.logging.Log)

Aggregations

Log (org.apache.commons.logging.Log)188 Test (org.junit.Test)51 Test (org.junit.jupiter.api.Test)40 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)35 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)19 BeanFactory (org.springframework.beans.factory.BeanFactory)17 CountDownLatch (java.util.concurrent.CountDownLatch)15 LogConfigurationException (org.apache.commons.logging.LogConfigurationException)15 ArrayList (java.util.ArrayList)12 File (java.io.File)11 QueueChannel (org.springframework.integration.channel.QueueChannel)11 MethodInvocation (org.aopalliance.intercept.MethodInvocation)10 IOException (java.io.IOException)9 AtomicReference (java.util.concurrent.atomic.AtomicReference)9 Log4JLogger (org.apache.commons.logging.impl.Log4JLogger)9 Message (org.springframework.messaging.Message)8 List (java.util.List)7 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)7 InputStream (java.io.InputStream)6 LogFactory (org.apache.commons.logging.LogFactory)6