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

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

Introduction

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

Prototype

void error(Object message, Throwable t);

Source Link

Document

Logs an error with error log level.

Usage

From source file:fr.gouv.vitam.utils.logging.CommonsLoggerTest.java

@Test
public void testErrorWithException() {
    final Log mock = createStrictMock(Log.class);

    mock.error("a", e);
    replay(mock);/*from w w w .  j a  v a2  s.co m*/

    final VitamLogger logger = new CommonsLogger(mock, "foo");
    logger.error("a", e);
    verify(mock);
}

From source file:interactivespaces.service.control.opensoundcontrol.internal.OpenSoundControlMethodCollection.java

/**
 * Handle a message./*from   ww  w.j  a v  a 2 s . c om*/
 *
 * @param message
 *          the message to handle
 * @param log
 *          a logger to use
 */
public void handleMessage(M message, Log log) {
    for (OpenSoundControlMethod<M> method : methods) {
        try {
            method.invoke(message);
        } catch (Throwable e) {
            log.error("An Open Sound Control method has failed", e);
        }
    }
}

From source file:com.microsoft.tfs.client.common.framework.command.TeamExplorerLogCommandFinishedCallback.java

@Override
public void onCommandFinished(final ICommand command, IStatus status) {
    /*//from  w  w  w .  ja v a2  s.co m
     * Team Explorer ("private") logging. Map IStatus severity to commons
     * logging severity iff the severity is greater than the configured
     * tfsLogMinimumSeverity.
     */
    if (status.getSeverity() >= minimumSeverity) {
        /*
         * UncaughtCommandExceptionStatus is a TeamExplorerStatus, which
         * does a silly trick: it makes the exception it was given
         * accessible only through a non-standard method. This helps when
         * displaying the status to the user in a dialog, but prevents the
         * platform logger from logging stack traces, so fix it up here.
         *
         * The right long term fix is to ditch TeamExplorerStatus entirely.
         */
        if (status instanceof TeamExplorerStatus) {
            status = ((TeamExplorerStatus) status).toNormalStatus();
        }

        /*
         * Don't have a static Log for this class, because then the errors
         * show up as coming from this class, which is not correct. Instead,
         * get the logger for the class the errors originated from. Note
         * that this is not a particularly expensive operation - it looks up
         * the classname in a hashmap. This should be more than suitable for
         * a command finished error handler.
         */
        final Log log = LogFactory.getLog(CommandHelpers.unwrapCommand(command).getClass());

        if (status.getSeverity() == IStatus.ERROR && log.isErrorEnabled()) {
            log.error(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException());
        } else if (status.getSeverity() == IStatus.WARNING && log.isWarnEnabled()) {
            log.error(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException());
        } else if (status.getSeverity() == IStatus.INFO && log.isInfoEnabled()) {
            log.info(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException());
        } else if (status.getSeverity() == IStatus.CANCEL && log.isInfoEnabled()) {
            log.info(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException());
        } else if (status.getSeverity() != IStatus.OK && log.isDebugEnabled()) {
            log.debug(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException());
        } else if (log.isTraceEnabled()) {
            log.trace(CommandFinishedCallbackHelpers.getMessageForStatus(status), status.getException());
        }
    }
}

From source file:net.sf.nmedit.jtheme.image.SVGImageResource.java

private void readData() {
    InputStream source = null;//from   w  w  w  . j  a  v a 2s.c om
    try {
        byte[] tmp = new byte[1024];

        source = new BufferedInputStream(createInputStream());
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        int size;
        while ((size = source.read(tmp)) != -1) {
            buffer.write(tmp, 0, size);
        }
        svgData = new String(buffer.toByteArray());
    } catch (IOException e) {
        Log log = LogFactory.getLog(getClass());
        if (log.isErrorEnabled())
            log.error(getClass().getName() + ".readData() failed", e);
    } finally {
        try {
            if (source != null)
                source.close();
        } catch (IOException e) {
            // ignore
        }
    }
}

From source file:interactivespaces.service.comm.serial.xbee.internal.SimpleResponseXBeeFrameHandler.java

/**
 * Signal an RX response./*from   w w  w.  j  a  v a 2s. c o  m*/
 *
 * @param endpoint
 *          the endpoint that received the response
 * @param response
 *          the response
 * @param listeners
 *          the listeners
 * @param log
 *          logger for errors
 */
private void signalRxResponse(XBeeCommunicationEndpoint endpoint, RxResponseXBeeFrame response,
        List<XBeeResponseListener> listeners, Log log) {
    for (XBeeResponseListener listener : listeners) {
        try {
            listener.onRxXBeeResponse(endpoint, response);
        } catch (Exception e) {
            log.error("Error during call to listener for XBee RX response", e);
        }
    }
}

From source file:net.sourceforge.eclipsetrader.core.internal.LogListener.java

public void logging(IStatus status, String plugin) {
    Log log = LogFactory.getLog(plugin);
    switch (status.getSeverity()) {
    case IStatus.INFO:
        log.info(status.getMessage(), status.getException());
        break;/*from   ww  w  .j ava 2 s. c  o m*/
    case IStatus.WARNING:
        log.warn(status.getMessage(), status.getException());
        break;
    case IStatus.ERROR:
        log.error(status.getMessage(), status.getException());
        break;
    default:
        log.debug(status.getMessage(), status.getException());
        break;
    }
}

From source file:com.amazon.carbonado.spi.AbstractRepository.java

void error(String message, Throwable e) {
    Log log = getLog();
    if (log != null) {
        log.error(message, e);
    }
}

From source file:interactivespaces.service.comm.serial.xbee.internal.SimpleResponseXBeeFrameHandler.java

/**
 * Signal an AT local response.//from  w  ww.j a  va2  s.co  m
 *
 * @param endpoint
 *          the endpoint that received the response
 * @param response
 *          the response
 * @param listeners
 *          the listeners
 * @param log
 *          logger for errors
 */
private void signalAtLocalResponse(XBeeCommunicationEndpoint endpoint, AtLocalResponseXBeeFrame response,
        List<XBeeResponseListener> listeners, Log log) {
    for (XBeeResponseListener listener : listeners) {
        try {
            listener.onAtLocalXBeeResponse(endpoint, response);
        } catch (Exception e) {
            log.error("Error during call to listener for XBee AT Remote reponse", e);
        }
    }
}

From source file:interactivespaces.service.comm.serial.xbee.internal.SimpleResponseXBeeFrameHandler.java

/**
 * Signal an AT remote response./*from  ww  w  .  ja v  a  2  s.co m*/
 *
 * @param endpoint
 *          the endpoint that received the response
 * @param response
 *          the response
 * @param listeners
 *          the listeners
 * @param log
 *          logger for errors
 */
private void signalAtRemoteResponse(XBeeCommunicationEndpoint endpoint, AtRemoteResponseXBeeFrame response,
        List<XBeeResponseListener> listeners, Log log) {
    for (XBeeResponseListener listener : listeners) {
        try {
            listener.onAtRemoteXBeeResponse(endpoint, response);
        } catch (Exception e) {
            log.error("Error during call to listener for XBee AT Remote reponse", e);
        }
    }
}

From source file:interactivespaces.service.comm.serial.xbee.internal.SimpleResponseXBeeFrameHandler.java

/**
 * Signal a TX status.// ww  w  . ja v  a  2  s  .c  om
 *
 * @param endpoint
 *          the endpoint that received the response
 * @param response
 *          the response
 * @param listeners
 *          the listeners
 * @param log
 *          logger for errors
 */
private void signalTxStatus(XBeeCommunicationEndpoint endpoint, TxStatusXBeeFrame response,
        List<XBeeResponseListener> listeners, Log log) {
    for (XBeeResponseListener listener : listeners) {
        try {
            listener.onTxStatusXBeeResponse(endpoint, response);
        } catch (Exception e) {
            log.error("Error during call to listener for XBee TX response", e);
        }
    }
}