Skip to content

Commit

Permalink
Adding logs for easier debugging (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-gopalakrishna authored Aug 15, 2022
1 parent 8b2a459 commit 4672549
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/microsoft/azure/functions/worker/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ public static boolean isTrue(String value) {
}
return false;
}

public static String getJavaVersion() {
return String.join(" - ", System.getProperty("java.home"), System.getProperty("java.version"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public FunctionEnvironmentReloadRequestHandler(JavaFunctionBroker broker) {

@Override
String execute(FunctionEnvironmentReloadRequest request, Builder response) throws Exception {
WorkerLogManager.getSystemLogger().log(Level.INFO, "FunctionEnvironmentReloadRequest received by the Java worker");
EnvironmentVariables = request.getEnvironmentVariablesMap();
if (EnvironmentVariables == null || EnvironmentVariables.isEmpty()) {
return String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.microsoft.azure.functions.worker.handler;

import java.util.*;
import java.util.logging.Level;

import com.microsoft.azure.functions.worker.WorkerLogManager;
import com.microsoft.azure.functions.worker.broker.*;
import com.microsoft.azure.functions.worker.description.*;
import com.microsoft.azure.functions.rpc.messages.*;
Expand All @@ -18,6 +20,7 @@ public FunctionLoadRequestHandler(JavaFunctionBroker broker) {

@Override
String execute(FunctionLoadRequest request, FunctionLoadResponse.Builder response) throws Exception {
WorkerLogManager.getSystemLogger().log(Level.INFO, "FunctionLoadRequest received by the Java worker");
final RpcFunctionMetadata metadata = request.getMetadata();
final FunctionMethodDescriptor descriptor = createFunctionDescriptor(request.getFunctionId(), metadata);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.microsoft.azure.functions.worker.broker.*;
import com.microsoft.azure.functions.rpc.messages.*;

import static com.microsoft.azure.functions.worker.Util.getJavaVersion;

public class InvocationRequestHandler extends MessageHandler<InvocationRequest, InvocationResponse.Builder> {
public InvocationRequestHandler(JavaFunctionBroker broker) {
super(StreamingMessage::getInvocationRequest,
Expand All @@ -23,6 +25,8 @@ public InvocationRequestHandler(JavaFunctionBroker broker) {

@Override
String execute(InvocationRequest request, InvocationResponse.Builder response) throws Exception {
WorkerLogManager.getSystemLogger().log(Level.INFO, "Java version - " + getJavaVersion());
WorkerLogManager.getSystemLogger().log(Level.INFO, "InvocationRequest received by the Java worker");
final String functionId = request.getFunctionId();
final String invocationId = request.getInvocationId();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.microsoft.azure.functions.rpc.messages.*;
import com.microsoft.azure.functions.worker.broker.JavaFunctionBroker;

import java.util.logging.Level;

public class WorkerInitRequestHandler extends MessageHandler<WorkerInitRequest, WorkerInitResponse.Builder> {
public WorkerInitRequestHandler(JavaFunctionBroker broker) {
super(StreamingMessage::getWorkerInitRequest,
Expand All @@ -15,6 +17,7 @@ public WorkerInitRequestHandler(JavaFunctionBroker broker) {

@Override
String execute(WorkerInitRequest request, WorkerInitResponse.Builder response) {
WorkerLogManager.getSystemLogger().log(Level.INFO, "WorkerInitRequest received by the Java worker");
broker.setWorkerDirectory(request.getWorkerDirectory());
response.setWorkerVersion(Application.version());
response.putCapabilities("TypedDataCollection", "TypedDataCollection");
Expand Down

0 comments on commit 4672549

Please sign in to comment.