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

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

Introduction

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

Prototype

void trace(Object message);

Source Link

Document

Logs a message with trace log level.

Usage

From source file:com.joliciel.talismane.utils.DaoUtils.java

public static void LogParameters(Map<String, Object> paramMap, Log log) {
    if (log.isTraceEnabled()) {
        for (Object obj : paramMap.entrySet()) {
            @SuppressWarnings("rawtypes")
            Entry entry = (Entry) obj;//w  w w  .  j  a va2s  .  co  m
            log.trace(
                    entry.getKey() + ": " + (entry.getValue() == null ? "null" : entry.getValue().toString()));
        }
    }
}

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);
    } else if (level == LogLevel.DEBUG) {
        log.debug(msg);//from  w ww .j ava  2s  .  c  o  m
    } 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.liangc.hq.base.utils.MonitorUtils.java

/**
 * Sometimes, it's useful to just get a dump of all of the metrics 
 * returned by the backend./*from  w w  w.ja v  a  2 s.  c o m*/
 * 
 * @param log
 * @param metrics a Map keyed on the category (String), values are 
 * List's of MetricDisplaySummary beans
 */
public static void traceMetricDisplaySummaryMap(Log logger, Map metrics) {
    logger.trace("Dumping metric map (from " + MonitorUtils.class.getName() + "):");
    for (Iterator categoryIter = metrics.keySet().iterator(); categoryIter.hasNext();) {
        String categoryName = (String) categoryIter.next();
        logger.trace("Category: " + categoryName);
        int i = 0;
        Collection metricList = (Collection) metrics.get(categoryName);
        for (Iterator iter = metricList.iterator(); iter.hasNext();) {
            MetricDisplaySummary summaryBean = (MetricDisplaySummary) iter.next();
            ++i;
            logger.trace("\t " + i + ": " + summaryBean);
        }
    }
}

From source file:com.liangc.hq.base.utils.MonitorUtils.java

public static void traceResourceTypeDisplaySummaryList(Log logger, List healths) {
    logger.trace("Dumping list of ResourceTypeDisplaySummary's (from " + MonitorUtils.class.getName() + "):");
    if (healths == null) {
        logger.trace("'healths' list was null!");
        return;/*w w  w. j ava2 s . co m*/
    }
    if (healths.size() < 1) {
        logger.trace("'healths' list was empty!");
        return;
    }
    int i = 0;
    for (Iterator iter = healths.iterator(); iter.hasNext();) {
        ResourceTypeDisplaySummary summaryBean = (ResourceTypeDisplaySummary) iter.next();
        ++i;
        logger.trace("\t" + i + ":" + summaryBean);
    }
}

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

private static byte[] serializeToByteArray(Packet packet, PacketSequenceNumberGenerator sequenceNumberGenerator,
        Log logger) throws IOException {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    outputStream.write(STX);/*  ww  w .j  a  v  a 2 s .co  m*/
    AsciiUtils.writeIntAsAsciiBytes(packet.getOperationCode(), outputStream, 2);
    outputStream.write(COLON);
    Integer sequenceNumber = packet.getSequenceNumber();
    if (sequenceNumber == null) {
        if (logger.isTraceEnabled()) {
            logger.trace("No sequence number in packet, generating one...");
        }
        if (sequenceNumberGenerator != null) {
            sequenceNumber = sequenceNumberGenerator.nextSequence();
            if (logger.isTraceEnabled()) {
                logger.trace("Generated " + sequenceNumber + " as sequence number");
            }
        } else {
            String message = "No sequence number generator. "
                    + "Please see PacketSerializer#setSequenceNumberGenerator("
                    + "PacketSequenceNumberGenerator)";
            logger.error(message);
            throw new IOException(message);
        }
    }
    AsciiUtils.writeIntAsAsciiBytes(sequenceNumber, outputStream, 3);
    outputStream.write(TAB);
    for (Parameter parameter : packet.getParameters()) {
        AsciiUtils.writeIntAsAsciiBytes(parameter.getNumber(), outputStream, 3);
        outputStream.write(COLON);
        AsciiUtils.writeStringAsAsciiBytes(parameter.getValue(), outputStream);
        outputStream.write(TAB);
    }
    return outputStream.toByteArray();
}

From source file:dk.statsbiblioteket.util.Logs.java

/**
 * Log the message and the elements to the log at the specified level.
 * Elements are converted to Strings and appended to the message. Arrays,
 * Lists and similar in the elements are expanded to a certain degree of
 * detail./* w w w  .  j a v  a 2  s .com*/
 *
 * Sample input/output:
 * <code>log(myLog, Level.TRACE, false, "Started test", null,
 * 5, new String[]{"flim", "flam"});</code>
 * expands to
 * <code>log.trace("Started test (5, (flim, flam))");</code>
 *
 * @param log      the log to log to.
 * @param level    the level to log to (e.g. TRACE, DEBUG, INFO...).
 * @param verbose  if true, the elements are expanded more than for false.
 * @param error    the cause of this logging. If null, no cause is logged.
 * @param message  the message for the log.
 * @param elements the elements to log.
 */
public static void log(Log log, Level level, String message, Throwable error, boolean verbose,
        Object... elements) {
    int maxLength = verbose ? VERBOSE_MAXLENGTH : DEFAULT_MAXLENGTH;
    int maxDepth = verbose ? VERBOSE_MAXDEPTH : DEFAULT_MAXDEPTH;
    String expanded = message;
    if (elements != null && elements.length > 0) {
        expanded += expand(elements, maxLength, maxDepth);
    }
    switch (level) {
    case TRACE:
        if (!log.isTraceEnabled()) {
            return;
        }
        if (error == null) {
            log.trace(expanded);
        } else {
            log.trace(expanded, error);
        }
        break;
    case DEBUG:
        if (!log.isDebugEnabled()) {
            return;
        }
        if (error == null) {
            log.debug(expanded);
        } else {
            log.debug(expanded, error);
        }
        break;
    case INFO:
        if (!log.isInfoEnabled()) {
            return;
        }
        if (error == null) {
            log.info(expanded);
        } else {
            log.info(expanded, error);
        }
        break;
    case WARN:
        if (!log.isWarnEnabled()) {
            return;
        }
        if (error == null) {
            log.warn(expanded);
        } else {
            log.warn(expanded, error);
        }
        break;
    case ERROR:
        if (!log.isErrorEnabled()) {
            return;
        }
        if (error == null) {
            log.error(expanded);
        } else {
            log.error(expanded, error);
        }
        break;
    case FATAL:
        if (!log.isFatalEnabled()) {
            return;
        }
        if (error == null) {
            log.fatal(expanded);
        } else {
            log.fatal(expanded, error);
        }
        break;
    default:
        throw new IllegalArgumentException("The level '" + level + "' is unknown");
    }
}

From source file:com.lolay.citygrid.ads.tracking.TrackingIntegration.java

public void testImpression() throws Exception {
    Log log = testImpressionLog;

    log.trace("ENTER");

    TrackingClient client = new ClientFactory(baseUrl).getTracking();
    TrackingInvoker invoker = TrackingInvoker.builder().listingId(1).referenceId(1).impressionId("1")
            .actionTarget(TrackingActionTarget.LISTING_PROFILE).mobileType("junit")
            .muid("1234567890abcdef1234567890abcdef12345678").ua("Integratin/1.0").publisher("4214549098")
            .placement("junit").build();

    try {/*from   w w  w  . j a v  a2s  .  co m*/
        long start = System.currentTimeMillis();
        invoker.impression(client);
        long end = System.currentTimeMillis();
        log.trace(String.format("Impression tracking took %s ms", end - start));
    } catch (InvokerException e) {
        log.error(e.getErrorCodes(), e);
        fail();
    }
}

From source file:com.lolay.citygrid.content.places.detail.DetailIntegration.java

public void testDetail() throws Exception {
    Log log = testDetailLog;
    log.trace("ENTER");

    DetailClient client = new ClientFactory(baseUrl).getDetail();
    DetailInvoker invoker = DetailInvoker.builder().listingId(10100230).clientIp("127.0.0.1").publisher("test")
            .placement("search_page").build();

    DetailResults results = null;//from   w ww.j  a va  2 s .co m
    try {
        long start = System.currentTimeMillis();
        results = invoker.profile(client);
        long end = System.currentTimeMillis();
        log.trace(String.format("Get detail took %s ms", end - start));
    } catch (InvokerException e) {
        log.error(e.getErrorCodes(), e);
        fail();
    }
    assertNotNull(results);
    DetailLocation location = results.getLocation();
    assertNotNull(location);
    DetailAddress address = location.getAddress();
    assertNotNull(address);
    assertNotNull(address.getPostalCode());
    // TODO add validation
}

From source file:com.runwaysdk.business.generation.EclipseCompiler.java

/**
 * Calls the ECJ and wraps any errors in a {@link CompilerException}
 * /*from   w  w w . j a va2s .  c o m*/
 * @param args Arguments for the compiler
 * @throws CompilerException if compilation fails
 */
private void callECJ(String args[]) {
    Log log = LogFactory.getLog(COMPILER_LOG);
    log.trace(Arrays.deepToString(args));

    StringWriter output = new StringWriter();
    StringWriter errors = new StringWriter();
    Main compiler = new Main(new PrintWriter(output), new PrintWriter(errors), false);

    compiler.compile(args);

    String message = errors.toString();

    if (message.length() > 0) {
        String error = "Errors found during compilation:\n" + message;
        throw new CompilerException(error, message);
    }
}

From source file:com.lolay.placefinder.PlaceFinderIntegration.java

public void testWhere() throws Exception {
    final Log log = testWhereLog;
    log.trace("enter");

    PlaceFinderClient client = new PlaceFinderFactory(baseUrl).getPlaceFinder();

    PlaceFinderInvoker invoker = PlaceFinderInvoker.builder().appId(appId).count(1)
            .location("484 Los Angeles Ave., Moorpark, CA").flag("C").build();
    PlaceFinderResultSet response = null;
    try {//from  www  . ja v a2 s.  c o  m
        long start = System.currentTimeMillis();
        response = invoker.location(client);
        long end = System.currentTimeMillis();
        log.trace(String.format("Query took %s ms", end - start));
    } catch (Exception e) {
        log.error(e);
        fail();
    }

    assertNotNull(response);
    assertEquals((Integer) 0, response.getError());

    PlaceFinderResult result = response.getResult();
    assertNotNull(result);
    assertNotNull(result.getLatitude());
    assertNotNull(result.getLongitude());
    assertTrue(result.getLatitude() > 0);
    assertTrue(result.getLongitude() < 0);
}