Skip to content

Commit

Permalink
Remove the start and stop logs of the listener
Browse files Browse the repository at this point in the history
Support it only in the debug mode.
  • Loading branch information
BuddhiWathsala committed Nov 16, 2021
1 parent 08e234e commit 34c0b4c
Showing 1 changed file with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.PrintStream;

import static io.ballerina.stdlib.grpc.GrpcConstants.HTTPS_ENDPOINT_STARTED;
import static io.ballerina.stdlib.grpc.GrpcConstants.HTTPS_ENDPOINT_STOPPED;
import static io.ballerina.stdlib.grpc.GrpcConstants.HTTP_ENDPOINT_STARTED;
import static io.ballerina.stdlib.grpc.GrpcConstants.HTTP_ENDPOINT_STOPPED;

/**
* Server Connector Port Binding Listener.
Expand All @@ -34,29 +34,24 @@
public class ServerConnectorPortBindingListener implements PortBindingEventListener {

private static final Logger log = LoggerFactory.getLogger(ServerConnectorPortBindingListener.class);
private static final PrintStream console;

public void onOpen(String serverConnectorId, boolean isHttps) {
if (isHttps) {
console.println(HTTPS_ENDPOINT_STARTED + serverConnectorId);
} else {
console.println(GrpcConstants.HTTP_ENDPOINT_STARTED + serverConnectorId);

if (log.isDebugEnabled()) {
String message = isHttps ? HTTPS_ENDPOINT_STARTED : HTTP_ENDPOINT_STARTED;
log.debug(message + serverConnectorId);
}
}

public void onClose(String serverConnectorId, boolean isHttps) {
if (isHttps) {
console.println(HTTPS_ENDPOINT_STOPPED + serverConnectorId);
} else {
console.println(GrpcConstants.HTTP_ENDPOINT_STOPPED + serverConnectorId);

if (log.isDebugEnabled()) {
String message = isHttps ? HTTPS_ENDPOINT_STOPPED : HTTP_ENDPOINT_STOPPED;
log.debug(message + serverConnectorId);
}
}

public void onError(Throwable throwable) {
log.error("Error in http endpoint", throwable);
}

static {
console = System.out;
}
}

0 comments on commit 34c0b4c

Please sign in to comment.