Skip to content

Commit

Permalink
Audit logger
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-v committed Dec 4, 2024
1 parent b37b96d commit fca79bf
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions services-api/src/main/java/io/scalecube/services/ServiceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,6 +54,7 @@ static void beforeAll() {
.id("WS")
.gatewayHandler(new GatewaySessionHandlerImpl(AUTH_REGISTRY))
.build())
.defaultLogger("gateway", Level.INFO)
.services(new SecuredServiceImpl(AUTH_REGISTRY)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
10 changes: 10 additions & 0 deletions services/src/main/java/io/scalecube/services/Microservices.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit fca79bf

Please sign in to comment.