Add apptype to app install log

pull/136/head
prathabanKavin 1 year ago
parent 472d000c9e
commit 663dcd7ee7

@ -22,9 +22,7 @@ import com.google.gson.Gson;
import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException;
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext;
import io.entgra.device.mgt.core.notification.logger.PolicyLogContext;
import io.entgra.device.mgt.core.notification.logger.impl.EntgraAppInstallLoggerImpl;
import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethodBase;
@ -701,14 +699,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
entry.getKey(), action, properties);
activityList.add(activity);
for (DeviceIdentifier identifier : deviceIdentifiers) {
log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setTenantId(tenantId).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build());
log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setTenantId(tenantId).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build());
}
}
} else {
Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action, properties);
activityList.add(activity);
for (DeviceIdentifier identifier : deviceIdentifiers) {
log.info(String.format("App %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setTenantId(tenantId).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build());
log.info(String.format("App %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setTenantId(tenantId).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build());
}
}

@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
public class AppInstallLogContext extends LogContext {
private final String appId;
private final String appName;
private final String appType;
private final String tenantId;
private final String device;
private final String userName;
@ -31,6 +32,7 @@ public class AppInstallLogContext extends LogContext {
private AppInstallLogContext(Builder builder) {
this.appId = builder.appId;
this.appName = builder.appName;
this.appType = builder.appType;
this.tenantId = builder.tenantId;
this.device = builder.device;
this.userName = builder.userName;
@ -44,6 +46,9 @@ public class AppInstallLogContext extends LogContext {
public String getAppName() {
return appName;
}
public String getAppType() {
return appType;
}
public String getTenantId() {
return tenantId;
@ -64,6 +69,7 @@ public class AppInstallLogContext extends LogContext {
public static class Builder {
private String appId;
private String appName;
private String appType;
private String tenantId;
private String device;
private String userName;
@ -99,6 +105,15 @@ public class AppInstallLogContext extends LogContext {
return this;
}
public String getAppType() {
return appType;
}
public Builder setAppType(String appType) {
this.appType = appType;
return this;
}
public String getTenantId() {
return tenantId;
}

@ -84,6 +84,9 @@ public final class MDCContextUtil {
if (mdcContext.getAppName() != null) {
MDC.put("AppName", mdcContext.getAppName());
}
if (mdcContext.getAppType() != null) {
MDC.put("AppType", mdcContext.getAppType());
}
if (mdcContext.getDevice() != null) {
MDC.put("Device", mdcContext.getDevice());
}

Loading…
Cancel
Save