Skip to content

Commit

Permalink
Removed slf4j
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-v committed Oct 8, 2024
1 parent f4e4ccf commit 02449c2
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 118 deletions.
20 changes: 6 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-parent</artifactId>
<version>0.2.20</version>
<version>0.3.1</version>
</parent>

<artifactId>scalecube-services-parent</artifactId>
Expand Down Expand Up @@ -59,23 +59,22 @@
</scm>

<properties>
<scalecube-cluster.version>2.6.18.rc1</scalecube-cluster.version>
<scalecube-security.version>1.0.32</scalecube-security.version>
<scalecube-cluster.version>2.6.18.RC10</scalecube-cluster.version>
<scalecube-security.version>1.0.33.RC1</scalecube-security.version>

<reactor.version>2020.0.32</reactor.version>
<jackson.version>2.15.1</jackson.version>
<jackson.version>2.18.0</jackson.version>
<netty.version>4.1.93.Final</netty.version>
<rsocket.version>1.1.4</rsocket.version>
<protostuff.version>1.6.0</protostuff.version>
<slf4j.version>1.7.36</slf4j.version>
<log4j.version>2.17.2</log4j.version>
<disruptor.version>3.4.2</disruptor.version>
<jsr305.version>3.0.2</jsr305.version>
<jctools.version>2.1.2</jctools.version>

<mockito-junit.version>4.6.1</mockito-junit.version>
<junit-jupiter.version>5.8.2</junit-jupiter.version>
<hamcrest.version>1.3</hamcrest.version>
<log4j.version>2.17.2</log4j.version>
<slf4j.version>1.7.36</slf4j.version>

<distributionManagement.url>https://maven.pkg.github.com/scalecube/scalecube-services
</distributionManagement.url>
Expand Down Expand Up @@ -150,13 +149,6 @@
<scope>import</scope>
</dependency>

<!-- Disruptor -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>${disruptor.version}</version>
</dependency>

<!-- RSocket -->
<dependency>
<groupId>io.rsocket</groupId>
Expand Down
3 changes: 0 additions & 3 deletions services-discovery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
<groupId>io.scalecube</groupId>
<artifactId>scalecube-cluster</artifactId>
</dependency>

<dependency>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-services-api</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Tests -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand All @@ -32,7 +30,6 @@
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-codec-jackson</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
import io.scalecube.services.ServiceEndpoint;
import io.scalecube.services.discovery.api.ServiceDiscovery;
import io.scalecube.services.discovery.api.ServiceDiscoveryEvent;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.StringJoiner;
import java.util.function.UnaryOperator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.Exceptions;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Sinks;

public final class ScalecubeServiceDiscovery implements ServiceDiscovery {

private static final Logger LOGGER = LoggerFactory.getLogger(ServiceDiscovery.class);
private static final Logger LOGGER = System.getLogger(ServiceDiscovery.class.getName());

private ClusterConfig clusterConfig;
private Cluster cluster;
Expand Down Expand Up @@ -107,17 +107,18 @@ public void shutdown() {
}

private void onMembershipEvent(MembershipEvent membershipEvent) {
LOGGER.debug("onMembershipEvent: {}", membershipEvent);
LOGGER.log(Level.DEBUG, "onMembershipEvent: {0}", membershipEvent);

ServiceDiscoveryEvent discoveryEvent = toServiceDiscoveryEvent(membershipEvent);
if (discoveryEvent == null) {
LOGGER.warn(
"DiscoveryEvent is null, cannot publish it (corresponding membershipEvent: {})",
LOGGER.log(
Level.WARNING,
"DiscoveryEvent is null, cannot publish it (corresponding membershipEvent: {0})",
membershipEvent);
return;
}

LOGGER.debug("Publish discoveryEvent: {}", discoveryEvent);
LOGGER.log(Level.DEBUG, "Publish discoveryEvent: {0}", discoveryEvent);
sink.emitNext(discoveryEvent, busyLooping(Duration.ofSeconds(3)));
}

Expand All @@ -141,7 +142,7 @@ private ServiceEndpoint toServiceEndpoint(ByteBuffer byteBuffer) {
try {
return (ServiceEndpoint) clusterConfig.metadataCodec().deserialize(byteBuffer.duplicate());
} catch (Exception e) {
LOGGER.error("Failed to read metadata", e);
LOGGER.log(Level.ERROR, "Failed to read metadata", e);
throw Exceptions.propagate(e);
}
}
Expand Down
9 changes: 4 additions & 5 deletions services-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,17 @@
<artifactId>fastutil</artifactId>
<version>8.1.1</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-jpl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
</dependencies>

Expand Down
10 changes: 3 additions & 7 deletions services-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
<groupId>org.jctools</groupId>
<artifactId>jctools-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<!-- Tests -->
<dependency>
Expand Down Expand Up @@ -79,12 +75,12 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<artifactId>log4j-jpl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import io.netty.buffer.ByteBuf;
import io.scalecube.services.api.ServiceMessage;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Mono;
import reactor.util.context.Context;

public interface GatewaySessionHandler {

Logger LOGGER = LoggerFactory.getLogger(GatewaySessionHandler.class);
Logger LOGGER = System.getLogger(GatewaySessionHandler.class.getName());

GatewaySessionHandler DEFAULT_INSTANCE = new GatewaySessionHandler() {};

Expand Down Expand Up @@ -59,8 +59,9 @@ default void onResponse(
* @param context subscriber context
*/
default void onError(GatewaySession session, Throwable throwable, Context context) {
LOGGER.error(
"Exception occurred on session: {}, on context: {}, cause:",
LOGGER.log(
Level.ERROR,
"Exception occurred on session: {0,number,#}, on context: {1}",
session.sessionId(),
context,
throwable);
Expand All @@ -73,7 +74,8 @@ default void onError(GatewaySession session, Throwable throwable, Context contex
* @param throwable an exception that occurred (not null)
*/
default void onSessionError(GatewaySession session, Throwable throwable) {
LOGGER.error("Exception occurred on session: {}, cause:", session.sessionId(), throwable);
LOGGER.log(
Level.ERROR, "Exception occurred on session: {0,number,#}", session.sessionId(), throwable);
}

/**
Expand All @@ -86,8 +88,11 @@ default void onSessionError(GatewaySession session, Throwable throwable) {
default Mono<Void> onConnectionOpen(long sessionId, Map<String, String> headers) {
return Mono.fromRunnable(
() ->
LOGGER.debug(
"Connection opened, sessionId: {}, headers({})", sessionId, headers.size()));
LOGGER.log(
Level.DEBUG,
"Connection opened, sessionId: {0,number,#}, headers({1})",
sessionId,
headers.size()));
}

/**
Expand All @@ -96,7 +101,7 @@ default Mono<Void> onConnectionOpen(long sessionId, Map<String, String> headers)
* @param session websocket session (not null)
*/
default void onSessionOpen(GatewaySession session) {
LOGGER.info("Session opened: {}", session);
LOGGER.log(Level.INFO, "Session opened: {0}", session);
}

/**
Expand All @@ -105,6 +110,6 @@ default void onSessionOpen(GatewaySession session) {
* @param session websocket session (not null)
*/
default void onSessionClose(GatewaySession session) {
LOGGER.info("Session closed: {}", session);
LOGGER.log(Level.INFO, "Session closed: {0}", session);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.scalecube.services.gateway;

import io.netty.util.ReferenceCounted;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;

public final class ReferenceCountUtil {

private static final Logger LOGGER = LoggerFactory.getLogger(ReferenceCountUtil.class);
private static final Logger LOGGER = System.getLogger(ReferenceCountUtil.class.getName());

private ReferenceCountUtil() {
// Do not instantiate
Expand All @@ -24,7 +24,11 @@ public static boolean safestRelease(Object msg) {
&& ((ReferenceCounted) msg).refCnt() > 0
&& ((ReferenceCounted) msg).release();
} catch (Throwable t) {
LOGGER.warn("Failed to release reference counted object: {}, cause: {}", msg, t.toString());
LOGGER.log(
Level.WARNING,
"Failed to release reference counted object: {0}, cause: {1}",
msg,
t.toString());
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
import io.scalecube.services.transport.api.ClientChannel;
import io.scalecube.services.transport.api.ClientTransport;
import io.scalecube.services.transport.api.DataCodec;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.lang.reflect.Type;
import java.time.Duration;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.NettyOutbound;
Expand All @@ -33,7 +33,7 @@

public final class HttpGatewayClientTransport implements ClientChannel, ClientTransport {

private static final Logger LOGGER = LoggerFactory.getLogger(HttpGatewayClientTransport.class);
private static final Logger LOGGER = System.getLogger(HttpGatewayClientTransport.class.getName());

private static final String CONTENT_TYPE = "application/json";
private static final HttpGatewayClientCodec CLIENT_CODEC =
Expand Down Expand Up @@ -93,7 +93,7 @@ public Mono<ServiceMessage> requestResponse(ServiceMessage request, Type respons

private Mono<Void> send(
ServiceMessage request, HttpClientRequest clientRequest, NettyOutbound outbound) {
LOGGER.debug("Sending request: {}", request);
LOGGER.log(Level.DEBUG, "Sending request: {0}", request);
// prepare request headers
request.headers().forEach(clientRequest::header);
// send with publisher (defer buffer cleanup to netty)
Expand Down Expand Up @@ -127,7 +127,7 @@ private static ServiceMessage toMessage(HttpClientResponse httpResponse, ByteBuf
.forEach(entry -> builder.header(entry.getKey(), entry.getValue()));
ServiceMessage message = builder.build();

LOGGER.debug("Received response: {}", message);
LOGGER.log(Level.DEBUG, "Received response: {0}", message);
return message;
}

Expand Down
Loading

0 comments on commit 02449c2

Please sign in to comment.