Skip to content

Commit

Permalink
Issue #4572 - First pass at updating for slf4j-api usage
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <[email protected]>
  • Loading branch information
joakime committed Feb 18, 2020
1 parent 0bc6c83 commit e4a08ec
Show file tree
Hide file tree
Showing 174 changed files with 764 additions and 693 deletions.
10 changes: 10 additions & 0 deletions apache-jsp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
<artifactId>jetty-annotations</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand All @@ -101,6 +105,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
Expand Down
1 change: 1 addition & 0 deletions apache-jsp/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
requires jetty.servlet.api;
requires org.eclipse.jetty.util;
requires org.mortbay.apache.jasper;
requires org.slf4j;

provides Log with JuliLog;
provides ServletContainerInitializer with JettyJasperInitializer;
Expand Down
85 changes: 25 additions & 60 deletions apache-jsp/src/main/java/org/eclipse/jetty/apache/jsp/JuliLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,170 +18,135 @@

package org.eclipse.jetty.apache.jsp;

import java.util.Objects;

import org.slf4j.LoggerFactory;

public class JuliLog implements org.apache.juli.logging.Log
{
public static org.apache.juli.logging.Log getInstance(String name)
{
return new JuliLog(name);
}

private final org.eclipse.jetty.util.log.Logger _logger;
private final org.eclipse.jetty.util.log.StdErrLog _stdErrLog;
private final org.slf4j.Logger logger;

public JuliLog()
{
_logger = org.eclipse.jetty.util.log.Log.getRootLogger();
_stdErrLog = (_logger instanceof org.eclipse.jetty.util.log.StdErrLog) ? (org.eclipse.jetty.util.log.StdErrLog)_logger : null;
this(JuliLog.class.getName());
}

public JuliLog(String name)
{
_logger = org.eclipse.jetty.util.log.Log.getLogger(name);
_stdErrLog = (_logger instanceof org.eclipse.jetty.util.log.StdErrLog) ? (org.eclipse.jetty.util.log.StdErrLog)_logger : null;
logger = LoggerFactory.getLogger(name);
}

@Override
public boolean isDebugEnabled()
{
return _logger.isDebugEnabled();
return logger.isDebugEnabled();
}

@Override
public boolean isErrorEnabled()
{
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN;
return logger.isErrorEnabled();
}

@Override
public boolean isFatalEnabled()
{
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN;
return logger.isErrorEnabled();
}

@Override
public boolean isInfoEnabled()
{
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_INFO;
return logger.isInfoEnabled();
}

@Override
public boolean isTraceEnabled()
{
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_DEBUG;
return logger.isTraceEnabled();
}

@Override
public boolean isWarnEnabled()
{
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN;
return logger.isWarnEnabled();
}

@Override
public void trace(Object message)
{
if (message instanceof String)
_logger.debug((String)message);
else
_logger.debug("{}", message);
logger.trace(Objects.toString(message));
}

@Override
public void trace(Object message, Throwable t)
{
if (message instanceof String)
_logger.debug((String)message, t);
else
_logger.debug("{}", message, t);
logger.trace(Objects.toString(message), t);
}

@Override
public void debug(Object message)
{
if (message instanceof String)
_logger.debug((String)message);
else
_logger.debug("{}", message);
logger.debug(Objects.toString(message));
}

@Override
public void debug(Object message, Throwable t)
{
if (message instanceof String)
_logger.debug((String)message, t);
else
_logger.debug("{}", message, t);
logger.debug(Objects.toString(message), t);
}

@Override
public void info(Object message)
{
if (message instanceof String)
_logger.info((String)message);
else
_logger.info("{}", message);
logger.info(Objects.toString(message));
}

@Override
public void info(Object message, Throwable t)
{
if (message instanceof String)
_logger.info((String)message, t);
else
_logger.info("{}", message, t);
logger.info(Objects.toString(message), t);
}

@Override
public void warn(Object message)
{
if (message instanceof String)
_logger.warn((String)message);
else
_logger.warn("{}", message);
logger.warn(Objects.toString(message));
}

@Override
public void warn(Object message, Throwable t)
{
if (message instanceof String)
_logger.warn((String)message, t);
else
_logger.warn("{}", message, t);
logger.warn(Objects.toString(message), t);
}

@Override
public void error(Object message)
{
if (message instanceof String)
_logger.warn((String)message);
else
_logger.warn("{}", message);
logger.error(Objects.toString(message));
}

@Override
public void error(Object message, Throwable t)
{
if (message instanceof String)
_logger.warn((String)message, t);
else
_logger.warn("{}", message, t);
logger.error(Objects.toString(message), t);
}

@Override
public void fatal(Object message)
{
if (message instanceof String)
_logger.warn((String)message);
else
_logger.warn("{}", message);
logger.error(Objects.toString(message));
}

@Override
public void fatal(Object message, Throwable t)
{
if (message instanceof String)
_logger.warn((String)message, t);
else
_logger.warn("{}", message, t);
logger.error(Objects.toString(message), t);
}
}

Expand Down
21 changes: 10 additions & 11 deletions jetty-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
@{argLine} ${jetty.surefire.argLine}
--add-modules java.security.jgss
--add-modules org.eclipse.jetty.jmx
--add-modules org.slf4j
</argLine>
</configuration>
</plugin>
Expand Down Expand Up @@ -117,13 +116,23 @@
<artifactId>jetty-alpn-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-servlet-api</artifactId>
Expand Down Expand Up @@ -154,16 +163,6 @@
<version>2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
Expand Down
1 change: 1 addition & 0 deletions jetty-client/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

requires org.eclipse.jetty.alpn.client;
requires transitive org.eclipse.jetty.http;
requires org.slf4j;

// Only required if using SPNEGO.
requires static java.security.jgss;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.toolchain.test.Net;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
Expand All @@ -92,7 +93,6 @@
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.SocketAddressResolver;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import org.eclipse.jetty.client.util.ByteBufferContentProvider;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.client.util.ByteBufferContentProvider;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource;

Expand Down
10 changes: 10 additions & 0 deletions jetty-deploy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,23 @@
<artifactId>jetty-xml</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
Expand Down
1 change: 1 addition & 0 deletions jetty-deploy/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
requires java.xml;
requires transitive org.eclipse.jetty.webapp;
requires org.eclipse.jetty.xml;
requires org.slf4j;

// Only required if using JMX.
requires static org.eclipse.jetty.jmx;
Expand Down
Loading

0 comments on commit e4a08ec

Please sign in to comment.