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:arena.utils.URLUtils.java

public static String addParamToURL(String baseURL, String paramName, String paramValue, String encoding,
        boolean replace) {
    StringBuffer out = new StringBuffer();
    Log log = LogFactory.getLog(URLUtils.class);

    String useEncoding = ((encoding == null) ? "ISO-8859-1" : encoding);

    if ((paramName != null) && (paramValue != null)) {
        log.debug("URL encoding param: " + paramName + "=" + paramValue + " (ignored if null)");

        String encodedParamName = encodeURLToken(paramName, useEncoding);
        String encodedParamValue = encodeURLToken(paramValue, useEncoding);

        out.append(encodedParamName).append("=").append(encodedParamValue).append("&");

        // Remove if replacing
        int paramExistsLoc = baseURL.indexOf(encodedParamName + "=");

        if (replace && (paramExistsLoc != -1)) {
            log.debug(//www .  j ava 2  s .  com
                    "Replacing parameter: " + paramName + " in URL: " + baseURL + " with value " + paramValue);
            int prevAmpersandPos = baseURL.substring(0, paramExistsLoc).lastIndexOf("&");
            int nextAmpersandPos = baseURL.indexOf("&", paramExistsLoc);

            if (nextAmpersandPos != -1) {
                baseURL = baseURL.substring(0, paramExistsLoc) + baseURL.substring(nextAmpersandPos + 1);
            } else {
                baseURL = baseURL.substring(0, (prevAmpersandPos == -1) ? paramExistsLoc : prevAmpersandPos);
            }
        }
    }

    if (out.length() == 0) {
        return baseURL;
    } else if (baseURL.endsWith("?")) {
        return baseURL + out.substring(0, out.length() - 1);
    } else if (baseURL.indexOf("?") == -1) {
        return baseURL + "?" + out.substring(0, out.length() - 1);
    } else {
        return baseURL + "&" + out.substring(0, out.length() - 1);
    }
}

From source file:es.tunelator.log.Logger.java

/**
 * @param source/* w  w w . ja va2 s . c  om*/
 * @param e
 */
public static void logDebug(Class source, Throwable e) {
    Log log = LogFactory.getLog(es.tunelator.AppParameters.LOG_DEBUG);
    //        Log log = LogFactory.getLog(source);
    log.debug(e);
}

From source file:es.tunelator.log.Logger.java

/**
 * @param source//from  w w w .ja  va  2 s  . c o m
 * @param msg
 */
public static void logDebug(Class source, String msg) {
    Log log = LogFactory.getLog(es.tunelator.AppParameters.LOG_DEBUG);
    //        Log log = LogFactory.getLog(source);
    log.debug(msg);
}

From source file:it.doqui.index.ecmengine.client.engine.EcmEngineDelegateFactory.java

/**
 * Metodo factory che crea una nuova istanza del client delegate.
 * /*from   ww w . j a  v  a 2s  .c  o  m*/
 * <p>La factory cerca di istanziare la classe di implementazione
 * specificata dall'utente nel file di propriet&agrave;
 * {@code ecmengine-engine-delegate.properties}. Se tale operazione fallisce
 * la factory cerca di istanziare la classe di default definita
 * in {@link it.doqui.index.ecmengine.client.engine.util.EcmEngineDelegateConstants#ECMENGINE_DELEGATE_CLASS_NAME_DEFAULT}.
 * </p>
 * 
 * @return Una nuova istanza del client delegate.
 * 
 * @throws EcmEngineDelegateInstantiationException Se si verifica un
 * errore nell'istanziazione del client delegate.
 */
public static EcmEngineDelegate getEcmEngineDelegate() throws EcmEngineDelegateInstantiationException {
    final ResourceBundle resources = ResourceBundle.getBundle(ECMENGINE_PROPERTIES_FILE);
    final String caller = resources.getString(ECMENGINE_DELEGATE_CALLER);
    final Log logger = LogFactory.getLog(caller + ECMENGINE_DELEGATE_LOG_CATEGORY);
    final String implClass = resources.getString(ECMENGINE_DELEGATE_CLASS);

    EcmEngineDelegate ecmEngineDelegateImpl = null;
    logger.debug("[EcmEngineDelegateFactory::getEcmEngineDelegate] BEGIN");

    logger.debug("[EcmEngineDelegateFactory::getEcmEngineDelegate] " + "Classe delegate: " + implClass);
    try {
        ecmEngineDelegateImpl = getClassInstance(implClass, logger);
    } catch (EcmEngineDelegateInstantiationException e) {
        logger.warn("[EcmEngineDelegateFactory::getEcmEngineDelegate] " + "Impossibile caricare la classe \""
                + implClass + "\": " + e.getMessage());

        logger.debug("[EcmEngineDelegateFactory::getEcmEngineDelegate] " + "Classe delegate di default: "
                + ECMENGINE_DELEGATE_CLASS_NAME_DEFAULT);
        try {
            ecmEngineDelegateImpl = getClassInstance(ECMENGINE_DELEGATE_CLASS_NAME_DEFAULT, logger);
        } catch (EcmEngineDelegateInstantiationException ex) {
            logger.error("[EcmEngineDelegateFactory::getEcmEngineDelegate] "
                    + "Impossibile caricare la classe di default \"" + ECMENGINE_DELEGATE_CLASS_NAME_DEFAULT
                    + "\": " + ex.getMessage());

            throw ex; // Rilancia l'eccezione al chiamante
        }

    } finally {
        logger.debug("[EcmEngineDelegateFactory::getEcmEngineDelegate] END");
    }

    return ecmEngineDelegateImpl;
}

From source file:com.runwaysdk.logging.RunwayLogUtil.java

public static void logToLevel(Log log, LogLevel level, String msg) {
    if (level == LogLevel.TRACE) {
        log.trace(msg);//w  ww  .j ava2 s  .  co m
    } else if (level == LogLevel.DEBUG) {
        log.debug(msg);
    } else if (level == LogLevel.INFO) {
        log.info(msg);
    } else if (level == LogLevel.WARN) {
        log.warn(msg);
    } else if (level == LogLevel.ERROR) {
        log.error(msg);
    } else if (level == LogLevel.FATAL) {
        log.fatal(msg);
    } else {
        log.fatal(
                "RunwayLogUtil.logToLevel was called, but an invalid level was specified. Here is the message we were passed: '"
                        + msg + "'");
    }
}

From source file:com.netspective.sparx.report.tabular.HtmlTabularReportDataSourceScrollStatesManager.java

public static void closeAllScrollStates(Log log) {
    for (Iterator i = allScrollStateManagers.iterator(); i.hasNext();) {
        HtmlTabularReportDataSourceScrollStatesManager states = (HtmlTabularReportDataSourceScrollStatesManager) i
                .next();//from  w w  w.j ava  2 s.c  om
        int count = states.closeAll();
        log.debug("Closed " + count + " scroll states from " + states);
    }
}

From source file:com.googlecode.jcimd.PacketSerializer.java

private static void doSerializePacket(Packet packet, PacketSequenceNumberGenerator sequenceNumberGenerator,
        boolean useChecksum, Log logger, OutputStream outputStream) throws IOException {
    if (logger.isDebugEnabled()) {
        logger.debug("Sending " + packet);
    }//from   w w w.j  a  v a2s . c om
    byte[] bytes = serializeToByteArray(packet, sequenceNumberGenerator, logger);
    outputStream.write(bytes);
    if (useChecksum) {
        int checkSum = calculateCheckSum(bytes);
        AsciiUtils.writeIntAsHexAsciiBytes(checkSum, outputStream, 2);
    }
    outputStream.write(ETX);
}

From source file:com.jeeframework.util.validate.GenericTypeValidator.java

/**
 *  <p>//from  w  ww .  ja v  a  2s .co  m
 *
 *  Checks if the field is a valid date. The <code>Locale</code> is used
 *  with <code>java.text.DateFormat</code>. The setLenient method is set to
 *  <code>false</code> for all.</p>
 *
 *@param  value   The value validation is being performed on.
 *@param  locale  The Locale to use to parse the date (system default if
 *      null)
 *@return the converted Date value.
 */
public static Date formatDate(String value, Locale locale) {
    Date date = null;

    if (value == null) {
        return null;
    }

    try {
        DateFormat formatter = null;
        if (locale != null) {
            formatter = DateFormat.getDateInstance(DateFormat.SHORT, locale);
        } else {
            formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
        }

        formatter.setLenient(false);

        date = formatter.parse(value);
    } catch (ParseException e) {
        // Bad date so return null
        Log log = LogFactory.getLog(GenericTypeValidator.class);
        if (log.isDebugEnabled()) {
            log.debug("Date parse failed value=[" + value + "], " + "locale=[" + locale + "] " + e);
        }
    }

    return date;
}

From source file:com.jeeframework.util.validate.GenericTypeValidator.java

/**
 *  <p>/*from  w  w  w  .  j  av  a 2  s.  c o m*/
 *  Checks if the field is a valid date. The pattern is used with <code>java.text.SimpleDateFormat</code>
 *  . If strict is true, then the length will be checked so '2/12/1999' will
 *  not pass validation with the format 'MM/dd/yyyy' because the month isn't
 *  two digits. The setLenient method is set to <code>false</code> for all.
 *  </p>
 *
 *@param  value        The value validation is being performed on.
 *@param  datePattern  The pattern passed to <code>SimpleDateFormat</code>.
 *@param  strict       Whether or not to have an exact match of the
 *      datePattern.
 *@return the converted Date value.
 */
public static Date formatDate(String value, String datePattern, boolean strict) {
    Date date = null;

    if (value == null || datePattern == null || datePattern.length() == 0) {
        return null;
    }

    try {
        SimpleDateFormat formatter = new SimpleDateFormat(datePattern);
        formatter.setLenient(false);

        date = formatter.parse(value);

        if (strict) {
            if (datePattern.length() != value.length()) {
                date = null;
            }
        }
    } catch (ParseException e) {
        // Bad date so return null
        Log log = LogFactory.getLog(GenericTypeValidator.class);
        if (log.isDebugEnabled()) {
            log.debug("Date parse failed value=[" + value + "], " + "pattern=[" + datePattern + "], "
                    + "strict=[" + strict + "] " + e);
        }
    }

    return date;
}

From source file:de.itsvs.cwtrpc.core.CwtRpcUtils.java

public static void preloadContextClasses(ServletContext servletContext) throws ApplicationContextException {
    final Log log = LogFactory.getLog(CwtRpcUtils.class);
    final String preloadedClasses;

    preloadedClasses = servletContext.getInitParameter(PRELOADED_CLASSES_INIT_PARAM_NAME);
    if (preloadedClasses != null) {
        final String[] classNames = preloadedClasses.split("\\s");

        for (String className : classNames) {
            if (className.length() > 0) {
                if (log.isDebugEnabled()) {
                    log.debug("Preloading class: " + className);
                }/*w w  w .  ja  va  2 s .  c  o m*/
                try {
                    CwtRpcUtils.class.getClassLoader().loadClass(className);
                } catch (ClassNotFoundException e) {
                    throw new ApplicationContextException("Could not load class '" + className + "'", e);
                }
            }
        }
    }
}