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

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

Introduction

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

Prototype

void debug(Object message);

Source Link

Document

Logs a message with debug log level.

Usage

From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java

/**
 * Logs the given message to the log at the debug level. If the log level is not enabled, this method does
 * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
 *
 * @param  log      the log where the messages will go
 * @param  basename the base name of the resource bundle
 * @param  locale   the locale to determine what bundle to use
 * @param  key      the resource bundle key name
 * @param  varargs  arguments to help fill in the resource bundle message
 *
 * @return if the message was logged, a non-<code>null</code> Msg object is returned
 *//*ww  w.j  av a 2s.c  o m*/
public static Msg debug(Log log, BundleBaseName basename, Locale locale, String key, Object... varargs) {
    if (log.isDebugEnabled()) {
        Msg msg = Msg.createMsg(basename, locale, key, varargs);
        log.debug((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg);
        return msg;
    }

    return null;
}

From source file:de.zib.gndms.GORFX.context.service.globus.resource.TaskResource.java

@Override
public void remove() {

    if (taskAction != null) {
        Log log = taskAction.getLog();
        log.debug("Removing task resource: " + getID());
        AbstractTask tsk = taskAction.getModel();
        boolean cleanUp = false;
        if (tsk != null) {
            if (!tsk.isDone()) {
                // task is still running cancel it and cleanup entity manager
                taskAction.setCancelled(true);
                log.debug("cancel task " + tsk.getWid());
                cleanUp = true;//from www.j  av  a2 s .c  o m
                if (future != null) {
                    future.cancel(true);
                    try {
                        // give cancel some time
                        Thread.sleep(2000L);
                    } catch (InterruptedException e) {
                        logger.debug(e);
                    }
                }

                try {
                    EntityManager em = taskAction.getEntityManager();
                    if (em != null && em.isOpen()) {
                        try {
                            EntityTransaction tx = em.getTransaction();
                            if (tx.isActive())
                                tx.rollback();
                        } finally {
                            em.close();
                        }
                    }
                } catch (Exception e) {
                    // don't bother with exceptions
                    log.debug("Exception on task future cancel: " + e.toString(), e);
                }
            }

            EntityManager em = home.getEntityManagerFactory().createEntityManager();
            TxFrame tx = new TxFrame(em);
            // cleanup if necessary
            try {
                try {
                    Task t = em.find(Task.class, tsk.getId());
                    t.setPostMortem(true);
                    tx.commit();

                    if (cleanUp) {
                        log.debug("Triggering task cleanup");
                        try {
                            taskAction.setOwnEntityManager(em);
                            taskAction.cleanUpOnFail(t);
                        } catch (Exception e) {
                            log.debug("Exception on cleanup: " + e.toString());
                        }
                    }

                    // remove task from db
                    log.debug("Removing task: " + t.getId());
                    tx.begin();
                    em.remove(t);
                    tx.commit();
                } finally {
                    tx.finish();
                    if (em.isOpen())
                        em.close();
                }
            } catch (Exception e) {
                log.debug("Exception on task resource removal: " + e.toString());
                e.printStackTrace();
            }
        }
    }
}

From source file:de.iteratec.iteraplan.businesslogic.common.AuditLogger.java

@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
    try {//from  www . ja va2  s.  c om
        StringBuilder builder = new StringBuilder();
        builder.append("User [").append(UserContext.getCurrentUserContext().getLoginName()).append("] doing [")
                .append(appendTypeOfAction(invocation)).append("] with Types|Values (separated by ++++): [")
                .append(appendArgumentTypesAndValues(invocation) + "]");
        logger.debug(builder.toString());
        return invocation.proceed();
    } catch (Throwable ex) { //NOPMD - errors should be caught here as well!
        logger.error("Exception thrown in: " + invocation.getMethod().getName());
        throw ex;
    }
}

From source file:eu.semaine.jms.JMSLogReader.java

@Override
public void onMessage(Message m) {
    try {//  w w  w.  ja  va2 s  .  co m
        if (!(m instanceof TextMessage)) {
            return; // silently ignore
        }
        String dest = m.getJMSDestination().toString();
        // dest is expected to have the form
        // semaine.log.component.log-level
        String[] parts = dest.split("\\.");
        String level = parts[parts.length - 1].toLowerCase();
        String component = parts[parts.length - 2];
        Log log = LogFactory.getLog("semaine.log." + component);
        String text = ((TextMessage) m).getText();
        //text = time.format(new Date(m.getJMSTimestamp())) + " " + text;
        if (level.equals("info"))
            log.info(text);
        else if (level.equals("warn"))
            log.warn(text);
        else if (level.equals("error"))
            log.error(text);
        else if (level.equals("debug"))
            log.debug(text);
        else
            log.info(text);
    } catch (Exception e) {

    }
}

From source file:eu.qualityontime.commons.MethodUtils.java

/**
 * Gets the class for the primitive type corresponding to the primitive
 * wrapper class given. For example, an instance of
 * <code>Boolean.class</code> returns a <code>boolean.class</code>.
 * //from   w  w w  .  ja v  a 2s .c om
 * @param wrapperType
 *            the
 * @return the primitive type class corresponding to the given wrapper
 *         class, null if no match is found
 */
public static Class<?> getPrimitiveType(final Class<?> wrapperType) {
    // does anyone know a better strategy than comparing names?
    if (Boolean.class.equals(wrapperType)) {
        return boolean.class;
    } else if (Float.class.equals(wrapperType)) {
        return float.class;
    } else if (Long.class.equals(wrapperType)) {
        return long.class;
    } else if (Integer.class.equals(wrapperType)) {
        return int.class;
    } else if (Short.class.equals(wrapperType)) {
        return short.class;
    } else if (Byte.class.equals(wrapperType)) {
        return byte.class;
    } else if (Double.class.equals(wrapperType)) {
        return double.class;
    } else if (Character.class.equals(wrapperType)) {
        return char.class;
    } else {
        final Log log = LogFactory.getLog(MethodUtils.class);
        if (log.isDebugEnabled()) {
            log.debug("Not a known primitive wrapper class: " + wrapperType);
        }
        return null;
    }
}

From source file:it.doqui.index.ecmengine.client.backoffice.AbstractEcmEngineBackofficeDelegateImpl.java

protected AbstractEcmEngineBackofficeDelegateImpl(Log inLog) {
    inLog.debug("[" + getClass().getSimpleName() + "::constructor] BEGIN");
    this.log = inLog;
    try {/*from w  ww . ja  v a  2  s  .com*/
        initializeService();
    } catch (Throwable ex) {
        log.error("[" + getClass().getSimpleName() + "::constructor] eccezione", ex);
    } finally {
        log.debug("[" + getClass().getSimpleName() + "::constructor] END");
    }
}

From source file:de.tudarmstadt.ukp.dkpro.core.api.datasets.Dataset.java

default Split getSplit(double aTrainRatio, double aTestRatio) {
    Log LOG = LogFactory.getLog(getClass());

    File[] all = getDataFiles();/*from   w w w . ja v a  2 s. c o m*/
    Arrays.sort(all, (File a, File b) -> {
        return a.getName().compareTo(b.getName());
    });
    LOG.info("Found " + all.length + " files");

    int trainPivot = (int) Math.round(all.length * aTrainRatio);
    int testPivot = (int) Math.round(all.length * aTestRatio) + trainPivot;
    File[] train = (File[]) ArrayUtils.subarray(all, 0, trainPivot);
    File[] test = (File[]) ArrayUtils.subarray(all, trainPivot, testPivot);

    LOG.debug("Assigned " + train.length + " files to training set");
    LOG.debug("Assigned " + test.length + " files to test set");

    if (testPivot != all.length) {
        LOG.info("Files missing from split: [" + (all.length - testPivot) + "]");
    }

    return new SplitImpl(train, test, null);
}

From source file:name.chenyuelin.aopAdvisor.DebugLoggerAdvisor.java

@Override
public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
    if (LOG.isDebugEnabled()) {
        Log log = getLog(target);
        if (log != null && log.isDebugEnabled()) {
            StringBuilder debugMessage = new StringBuilder(50);
            debugMessage.append(method.getName()).append(" end.\nReturns:{");
            if (returnValue == null) {
                debugMessage.append(returnValue).append("}");
            } else {
                debugMessage.append(returnValue.getClass().getSimpleName()).append(":").append(returnValue)
                        .append("}");
            }/*www  . ja  va2s . c  o  m*/

            log.debug(debugMessage);
        }

    }
}

From source file:interactivespaces.activity.component.route.ros.RosMessageRouterActivityComponent.java

/**
 * Handle a new route message.// www  .  j a v a2  s.  co m
 *
 * @param channelName
 *          name of the channel the message came in on
 * @param message
 *          the message that came in
 */
void handleNewMessage(final String channelName, final T message) {
    if (!getComponentContext().canHandlerRun()) {
        return;
    }

    try {
        getComponentContext().enterHandler();

        long start = System.currentTimeMillis();
        String handlerInvocationId = newHandlerInvocationId();
        Log log = getComponentContext().getActivity().getLog();
        if (log.isDebugEnabled()) {
            log.debug(String.format("Entering ROS route message handler invocation %s", handlerInvocationId));
        }

        // Send the message out to the listener.
        messageListener.onNewRoutableInputMessage(channelName, message);

        if (log.isDebugEnabled()) {
            log.debug(String.format("Exiting ROS route message handler invocation %s in %d msecs",
                    handlerInvocationId, System.currentTimeMillis() - start));
        }
    } catch (Throwable e) {
        handleError(String.format("Error after receiving routing message for channel %s", channelName), e);
    } finally {
        getComponentContext().exitHandler();
    }
}

From source file:name.chenyuelin.aopAdvisor.DebugLoggerAdvisor.java

@Override
public void before(Method method, Object[] args, Object target) throws Throwable {
    if (LOG.isDebugEnabled()) {
        Log log = getLog(target);

        if (log != null && log.isDebugEnabled()) {
            StringBuilder debugMessage = new StringBuilder(50);
            debugMessage.append(method.getName()).append(" start.\nParameters:\n");
            for (Object arg : args) {
                Class<?> argClass = arg.getClass();
                debugMessage.append(argClass.getSimpleName()).append(":").append(arg).append("\n");
            }/* w  w  w  .  ja v  a  2  s.  c  o  m*/
            if (debugMessage.length() > 0) {
                debugMessage.deleteCharAt(debugMessage.length() - 1);
            }
            log.debug(debugMessage);
        }

    }
}