[slf4j-dev] svn commit: r1021 - in slf4j/trunk/jul-to-slf4j: ...

Christian Stein sormuras at gmx.net
Wed May 28 23:41:24 CEST 2008


Hi Ceki, Hi SLF4J-dev-list,

glad to see, that this tiny piece of code made it into the SLF4J trunk. :)

One issue: see the line marked with XXX below, there I failed to pass the
thrown object to the publisher warn method.

Cheers,
Christian

ceki at slf4j.org schrieb:
> Author: ceki
> Date: Wed May 28 22:28:14 2008
> New Revision: 1021
> 
> Added:
>    slf4j/trunk/jul-to-slf4j/   (props changed)
>    slf4j/trunk/jul-to-slf4j/src/
>    slf4j/trunk/jul-to-slf4j/src/main/
>    slf4j/trunk/jul-to-slf4j/src/main/java/
>    slf4j/trunk/jul-to-slf4j/src/main/java/org/
>    slf4j/trunk/jul-to-slf4j/src/main/java/org/slf4j/
>    slf4j/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/
>    slf4j/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java
>    slf4j/trunk/jul-to-slf4j/src/test/
>    slf4j/trunk/jul-to-slf4j/src/test/java/
>    slf4j/trunk/jul-to-slf4j/src/test/java/org/
>    slf4j/trunk/jul-to-slf4j/src/test/java/org/slf4j/
>    slf4j/trunk/jul-to-slf4j/src/test/java/org/slf4j/bridge/
> 
> Log:
> - started work on jul-to-slf4j bridge as requested in bug 38
> 
> Added: slf4j/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java
> ==============================================================================
> --- (empty file)
> +++ slf4j/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java	Wed May 28 22:28:14 2008
> @@ -0,0 +1,221 @@
> +package org.slf4j.bridge;
> +
> +import java.util.logging.ErrorManager;
> +import java.util.logging.Handler;
> +import java.util.logging.Level;
> +import java.util.logging.LogManager;
> +import java.util.logging.LogRecord;
> +
> +import org.slf4j.Logger;
> +import org.slf4j.LoggerFactory;
> +
> +/**
> + * JUL bridge/router for SLF4J.
> + * 
> + * @author Christian Stein
> + * @since 1.5.1
> + */
> +public class SLF4JBridgeHandler extends Handler {

[...]

> +    if (message == null) {
> +      return;
> +    }
> +    /*
> +     * TRACE
> +     */
> +    if (record.getLevel().intValue() <= Level.FINEST.intValue()) {
> +      publisher.trace(message, thrown);
> +      return;
> +    }
> +    /*
> +     * DEBUG
> +     */
> +    if (record.getLevel() == Level.FINER) {
> +      publisher.debug(message, thrown);
> +      return;
> +    }
> +    if (record.getLevel() == Level.FINE) {
> +      publisher.debug(message, thrown);
> +      return;
> +    }
> +    /*
> +     * INFO
> +     */
> +    if (record.getLevel() == Level.CONFIG) {
> +      publisher.info(message, thrown);
> +      return;
> +    }
> +    if (record.getLevel() == Level.INFO) {
> +      publisher.info(message, thrown);
> +      return;
> +    }
> +    /*
> +     * WARN
> +     */
> +    if (record.getLevel() == Level.WARNING) {

XXX

 > +      publisher.warn(message);

XXX

should read

+      publisher.warn(message, thrown);

> +      return;
> +    }
> +    /*
> +     * ERROR
> +     */
> +    if (record.getLevel().intValue() >= Level.SEVERE.intValue()) {
> +      publisher.error(message, thrown);
> +      return;
> +    }
> +    /*
> +     * Still here? Fallback and out.
> +     */
> +    publishFallback(record, publisher);
> +  }
> +
> [...]



More information about the slf4j-dev mailing list