diff --git a/services-api/src/main/java/io/scalecube/services/ServiceInfo.java b/services-api/src/main/java/io/scalecube/services/ServiceInfo.java index 8edfe49aa..1dba4108b 100644 --- a/services-api/src/main/java/io/scalecube/services/ServiceInfo.java +++ b/services-api/src/main/java/io/scalecube/services/ServiceInfo.java @@ -153,6 +153,16 @@ public Builder logger(String name, Level level) { return this; } + /** + * Setter for {@code logger}. Overrides default {@code Microservices.logger}. + * + * @param name logger name (optional) + * @return this buidler + */ + public Builder logger(String name) { + return logger(name, Level.DEBUG); + } + /** * Setter for {@code dataDecoder}. Overrides default {@code Microservices.dataDecoder}. * diff --git a/services-gateway/src/test/java/io/scalecube/services/gateway/http/HttpGatewayTest.java b/services-gateway/src/test/java/io/scalecube/services/gateway/http/HttpGatewayTest.java index c4d8b0730..855547f68 100644 --- a/services-gateway/src/test/java/io/scalecube/services/gateway/http/HttpGatewayTest.java +++ b/services-gateway/src/test/java/io/scalecube/services/gateway/http/HttpGatewayTest.java @@ -25,6 +25,7 @@ import io.scalecube.services.gateway.client.http.HttpGatewayClientTransport; import io.scalecube.services.transport.rsocket.RSocketServiceTransport; import io.scalecube.transport.netty.websocket.WebsocketTransportFactory; +import java.lang.System.Logger.Level; import java.time.Duration; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; @@ -75,6 +76,7 @@ static void beforeAll() { .membership( opts -> opts.seedMembers(gateway.discoveryAddress().toString()))) .transport(RSocketServiceTransport::new) + .defaultLogger("microservices", Level.INFO) .services(new GreetingServiceImpl()) .services( ServiceInfo.fromServiceInstance(new ErrorServiceImpl()) diff --git a/services-gateway/src/test/java/io/scalecube/services/gateway/http/HttpLocalGatewayTest.java b/services-gateway/src/test/java/io/scalecube/services/gateway/http/HttpLocalGatewayTest.java index 146445853..7b0871642 100644 --- a/services-gateway/src/test/java/io/scalecube/services/gateway/http/HttpLocalGatewayTest.java +++ b/services-gateway/src/test/java/io/scalecube/services/gateway/http/HttpLocalGatewayTest.java @@ -22,6 +22,7 @@ import io.scalecube.services.gateway.SomeException; import io.scalecube.services.gateway.client.StaticAddressRouter; import io.scalecube.services.gateway.client.http.HttpGatewayClientTransport; +import java.lang.System.Logger.Level; import java.time.Duration; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; @@ -49,6 +50,7 @@ static void beforeAll() { Microservices.start( new Context() .gateway(() -> new HttpGateway.Builder().id("HTTP").build()) + .defaultLogger("gateway", Level.INFO) .services(new GreetingServiceImpl()) .services( ServiceInfo.fromServiceInstance(new ErrorServiceImpl()) diff --git a/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayAuthTest.java b/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayAuthTest.java index ca6dbc487..0734d43f3 100644 --- a/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayAuthTest.java +++ b/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayAuthTest.java @@ -17,6 +17,7 @@ import io.scalecube.services.gateway.SecuredServiceImpl; import io.scalecube.services.gateway.client.StaticAddressRouter; import io.scalecube.services.gateway.client.websocket.WebsocketGatewayClientTransport; +import java.lang.System.Logger.Level; import java.time.Duration; import java.util.Collections; import java.util.HashSet; @@ -53,6 +54,7 @@ static void beforeAll() { .id("WS") .gatewayHandler(new GatewaySessionHandlerImpl(AUTH_REGISTRY)) .build()) + .defaultLogger("gateway", Level.INFO) .services(new SecuredServiceImpl(AUTH_REGISTRY))); } diff --git a/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayTest.java b/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayTest.java index c1d094de8..ea990fc9c 100644 --- a/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayTest.java +++ b/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayTest.java @@ -25,6 +25,7 @@ import io.scalecube.services.gateway.client.websocket.WebsocketGatewayClientTransport; import io.scalecube.services.transport.rsocket.RSocketServiceTransport; import io.scalecube.transport.netty.websocket.WebsocketTransportFactory; +import java.lang.System.Logger.Level; import java.time.Duration; import java.util.List; import java.util.stream.Collectors; @@ -78,6 +79,7 @@ static void beforeAll() { .membership( opts -> opts.seedMembers(gateway.discoveryAddress().toString()))) .transport(RSocketServiceTransport::new) + .defaultLogger("microservices", Level.INFO) .services(new GreetingServiceImpl()) .services( ServiceInfo.fromServiceInstance(new ErrorServiceImpl()) diff --git a/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketLocalGatewayTest.java b/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketLocalGatewayTest.java index 9139da008..44e60d807 100644 --- a/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketLocalGatewayTest.java +++ b/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketLocalGatewayTest.java @@ -22,6 +22,7 @@ import io.scalecube.services.gateway.SomeException; import io.scalecube.services.gateway.client.StaticAddressRouter; import io.scalecube.services.gateway.client.websocket.WebsocketGatewayClientTransport; +import java.lang.System.Logger.Level; import java.time.Duration; import java.util.List; import java.util.stream.Collectors; @@ -57,6 +58,7 @@ static void beforeAll() { .serviceCall(call -> call.errorMapper(ERROR_MAPPER)) .errorMapper(ERROR_MAPPER) .build()) + .defaultLogger("gateway", Level.INFO) .services(new GreetingServiceImpl()) .services( ServiceInfo.fromServiceInstance(new ErrorServiceImpl()) diff --git a/services/src/main/java/io/scalecube/services/Microservices.java b/services/src/main/java/io/scalecube/services/Microservices.java index 8459b1538..e024764d1 100644 --- a/services/src/main/java/io/scalecube/services/Microservices.java +++ b/services/src/main/java/io/scalecube/services/Microservices.java @@ -712,6 +712,16 @@ public Context defaultLogger(String name, Level level) { return this; } + /** + * Setter for default {@code logger}. By default, default {@code logger} is null. + * + * @param name logger name (optional) + * @return this builder with applied parameter + */ + public Context defaultLogger(String name) { + return defaultLogger(name, Level.DEBUG); + } + /** * Adds {@link Scheduler} supplier to the list of scheduler suppliers. *