Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
prasa7 committed Jun 23, 2023
1 parent 4a49991 commit ea184a6
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@

import org.apache.http.HttpHeaders;
import org.apache.synapse.MessageContext;
import org.apache.synapse.api.ApiUtils;
import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.wso2.carbon.apimgt.gateway.APIMgtGatewayConstants;
import org.wso2.carbon.apimgt.gateway.utils.*;
import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.keymgt.model.entity.*;

import java.util.Map;
import java.util.*;

/**
* Provides util methods for the LogsHandler
Expand Down Expand Up @@ -120,10 +123,16 @@ protected static String getTransportInURL(org.apache.synapse.MessageContext mess
}

protected static String getMatchingLogLevel(MessageContext ctx, Map<String, String> logProperties) {
String apiCtx = LogUtils.getTransportInURL(ctx);

String path = ApiUtils.getFullRequestPath(ctx);
String tenantDomain = GatewayUtils.getTenantDomain();
TreeMap selectedAPIS = Utils.getSelectedAPIList(path, tenantDomain);
String selectedPath = (String) selectedAPIS.firstKey();
API api = (API) selectedAPIS.get(selectedPath);
String apiCtx = api.getContext();
for (Map.Entry<String, String> entry : logProperties.entrySet()) {
String key = entry.getKey().substring(1);
if (apiCtx.startsWith(key + "/") || apiCtx.equals(key)) {
if (apiCtx.startsWith("/" + key) || apiCtx.equals(key)) {
ctx.setProperty(LogsHandler.LOG_LEVEL, entry.getValue());
ctx.setProperty("API_TO", apiCtx);
return entry.getValue();
Expand Down

0 comments on commit ea184a6

Please sign in to comment.