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.FileUtils.java

public static void gzip(File input, File outFile) {
    Log log = LogFactory.getLog(FileUtils.class);
    InputStream inStream = null;//from   w  ww. j a va 2 s  .c o m
    OutputStream outStream = null;
    GZIPOutputStream gzip = null;
    try {
        long inFileLengthKB = input.length() / 1024L;

        // Open the out file
        if (outFile == null) {
            outFile = new File(input.getParentFile(), input.getName() + ".gz");
        }
        inStream = new FileInputStream(input);
        outStream = new FileOutputStream(outFile, true);
        gzip = new GZIPOutputStream(outStream);

        // Iterate through in buffers and write out to the gzipped output stream
        byte buffer[] = new byte[102400]; // 100k buffer
        int read = 0;
        long readSoFar = 0;
        while ((read = inStream.read(buffer)) != -1) {
            readSoFar += read;
            gzip.write(buffer, 0, read);
            log.debug("Gzipped " + (readSoFar / 1024L) + "KB / " + inFileLengthKB + "KB of logfile "
                    + input.getName());
        }

        // Close the streams
        inStream.close();
        inStream = null;
        gzip.close();
        gzip = null;
        outStream.close();
        outStream = null;

        // Delete the old file
        input.delete();
        log.debug("Gzip of logfile " + input.getName() + " complete");
    } catch (IOException err) {
        // Delete the gzip file
        log.error("Error during gzip of logfile " + input, err);
    } finally {
        if (inStream != null) {
            try {
                inStream.close();
            } catch (IOException err2) {
            }
        }
        if (gzip != null) {
            try {
                gzip.close();
            } catch (IOException err2) {
            }
        }
        if (outStream != null) {
            try {
                outStream.close();
            } catch (IOException err2) {
            }
        }
    }
}

From source file:edu.vt.middleware.crypt.CryptProvider.java

/**
 * <p>This finds a <code>Signature</code> using the known providers and the
 * supplied parameters.</p>/*  w w  w.  ja v a2  s.  c  o m*/
 *
 * @param  digestAlgorithm  <code>String</code> name
 * @param  algorithm  <code>String</code> name
 * @param  padding  <code>String</code> name
 *
 * @return  <code>Signature</code>
 *
 * @throws  CryptException  if the algorithm is not available from any
 * provider or if the provider is not available in the environment
 */
public static Signature getSignature(final String digestAlgorithm, final String algorithm, final String padding)
        throws CryptException {
    final Log logger = LogFactory.getLog(CryptProvider.class);
    Signature sig = null;
    String transformation = null;
    if (digestAlgorithm != null && padding != null) {
        transformation = digestAlgorithm + "/" + algorithm + "/" + padding;
    } else if (digestAlgorithm != null) {
        transformation = digestAlgorithm + "/" + algorithm;
    } else {
        transformation = algorithm;
    }
    for (int i = 0; i < providers.length; i++) {
        try {
            sig = Signature.getInstance(transformation, providers[i]);
        } catch (NoSuchAlgorithmException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find algorithm " + algorithm + " in " + providers[i]);
            }
        } catch (NoSuchProviderException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find provider " + providers[i]);
            }
        } finally {
            if (sig != null) {
                break;
            }
        }
    }
    if (sig == null) {
        try {
            sig = Signature.getInstance(transformation);
        } catch (NoSuchAlgorithmException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find algorithm " + algorithm);
            }
            throw new CryptException(e.getMessage());
        }
    }
    return sig;
}

From source file:com.linkedin.cubert.functions.builtin.Match.java

private RegexImpl compile(String pattern) {
    RegexImpl impl = null;/*  ww w.  j ava2  s  . co  m*/
    int regexMethod = determineBestRegexMethod(pattern);
    switch (regexMethod) {
    case 0:
        impl = new CompiledRegex(Pattern.compile(pattern));
        break;
    case 1:
        try {
            impl = new CompiledAutomaton(pattern);
        } catch (IllegalArgumentException e) {
            Log log = LogFactory.getLog(getClass());
            log.debug("Got an IllegalArgumentException for Pattern: " + pattern);
            log.debug(e.getMessage());
            log.debug("Switching to java.util.regex");
            impl = new CompiledRegex(Pattern.compile(pattern));
        }
        break;
    default:
        break;
    }
    return impl;
}

From source file:cl.borrego.foundation.util.Message.java

protected void dumpFormattedMessage(Log log, LevelEnum level, String key, Object... arguments) {
    switch (level) {
    case INFO://w w  w  .  j  a v a2s . c  om
        log.info(getFormattedMessage(key, arguments));
        break;
    case DEBUG:
        log.debug(getFormattedMessage(key, arguments));
        break;
    default:
    }
}

From source file:com.telefonica.euro_iaas.paasmanager.rest.aspects.TraceInterceptor.java

protected void writeToLog(Log logger, String message, Throwable ex) {
    if (ex != null) {
        logger.error(ex);//w  ww  .j av a 2  s . c  o m
    } else if (message.contains("ENTER")) {
        logger.info(message);
    } else if (message.contains("EXIT")) {
        logger.debug(message);
    }
}

From source file:com.legstar.c2ws.servlet.C2wsProxy.java

/**
 * Produce a dump-like report of a data buffer content.
 * @param requestID a correlation id/*ww  w .  j  a  v  a2 s.  c o m*/
 * @param data the raw data to trace
 * @param log where to log
 */
public static void traceData(final String requestID, final byte[] data, final Log log) {

    StringBuilder dumpLine = new StringBuilder(); // 128
    String dumpChar; //[5];
    StringBuilder dumpString = new StringBuilder(); //[17];

    for (int i = 0; i < data.length && i < MAX_TRACES_BYTES; i++) {
        /* print every 16 byte on a different line */
        dumpChar = String.format("%02X ", data[i] & 0xff);
        dumpLine.append(dumpChar);
        if (Character.isValidCodePoint(data[i])) {
            dumpChar = String.format("%c", data[i]);
        } else {
            dumpChar = "?";
        }
        if (dumpChar.length() > 0) {
            dumpString.append(dumpChar);
        } else {
            dumpString.append(" ");
        }
        if (i % 16 == 15 || i == data.length - 1) {
            while (i % 16 < 15) {
                dumpLine.append("   ");
                i++;
            }
            dumpLine.append(" -- ");
            dumpLine.append(dumpString);
            log.debug(dumpLine);
            dumpString = new StringBuilder();
            dumpLine = new StringBuilder();
        }
    }

    if (data.length > MAX_TRACES_BYTES) {
        dumpLine.append(String.format("...data was truncated at %d bytes", MAX_TRACES_BYTES));
        log.debug(dumpLine);
    }
}

From source file:com.telefonica.euro_iaas.sdc.puppetwrapper.aspects.TraceInterceptor.java

/**
 * Write the message or the exception into the log system.
 * @param logger//from  w w w  .j av a  2 s .  c om
 * @param message
 * @param ex
 */
protected void writeToLog(Log logger, String message, Throwable ex) {
    if (ex != null) {
        logger.error(ex);
    } else if (message.contains("ENTER")) {
        logger.info(message);
    } else if (message.contains("EXIT")) {
        logger.debug(message);
    }
}

From source file:com.microsoft.tfs.client.common.ui.framework.console.ConsoleStream.java

private void printConsoleMessage(final String message, final boolean newline) {
    final Log log = console.getLog();

    if (log.isDebugEnabled()) {
        final String messageFormat = "[{0}]: {1}"; //$NON-NLS-1$
        final String text = MessageFormat.format(messageFormat, id, message);
        log.debug(text);
    }/*from   w  ww . j ava2  s.  c o  m*/

    if (!console.isEnabled()) {
        return;
    }

    console.throwIfDisposed();

    /*
     * println() and print() can be called from any thread
     */

    if (newline) {
        stream.println(message);
    } else {
        stream.print(message);
    }
}

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

/**
 * Uses the standard LogFactory to retrieve a Log instance.
 *///from w  w  w  . j a  v  a2 s .  co  m
public void testLogWithInlineLogger() {
    // this is typically wasteful ... instead use a static Log instance
    org.apache.commons.logging.Log inlineLog = LogFactory.getLog(this.getClass().getName() + "_inline");

    int sum = sum(3, 5);
    assertEquals(8, sum);

    inlineLog.debug("The sum of 3 + 5 = " + sum);
}

From source file:com.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java

/** {@inheritDoc} **/
public Object invoking(final PicoContainer container, final ComponentAdapter<?> componentAdapter,
        final Member member, final Object instance, final Object... args) {
    Log log = getLog(member);
    if (log.isDebugEnabled()) {
        log.debug(ComponentMonitorHelper.format(ComponentMonitorHelper.INVOKING, memberToString(member),
                instance));//  www .j a  v a  2  s.  co  m
    }
    return delegate.invoking(container, componentAdapter, member, instance, args);
}