Add subscription type to app install logs

pull/136/head
prathabanKavin 2 years ago
parent afd1204a22
commit 681bcd6c5a

@ -649,6 +649,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
throws ApplicationManagementException {
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
//Get app subscribing info of each device
SubscribingDeviceIdHolder subscribingDeviceIdHolder = getSubscribingDeviceIdHolder(devices,
applicationDTO.getApplicationReleaseDTOs().get(0).getId());
@ -699,14 +700,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()).setAppType(applicationDTO.getType()).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()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).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()).setAppType(applicationDTO.getType()).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()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build());
}
}

@ -24,7 +24,9 @@ public class AppInstallLogContext extends LogContext {
private final String appId;
private final String appName;
private final String appType;
private final String subType;
private final String tenantId;
private final String tenantDomain;
private final String device;
private final String userName;
private final String action;
@ -33,7 +35,9 @@ public class AppInstallLogContext extends LogContext {
this.appId = builder.appId;
this.appName = builder.appName;
this.appType = builder.appType;
this.subType = builder.subType;
this.tenantId = builder.tenantId;
this.tenantDomain = builder.tenantDomain;
this.device = builder.device;
this.userName = builder.userName;
this.action = builder.action;
@ -46,14 +50,23 @@ public class AppInstallLogContext extends LogContext {
public String getAppName() {
return appName;
}
public String getAppType() {
return appType;
}
public String getSubType() {
return subType;
}
public String getTenantId() {
return tenantId;
}
public String getTenantDomain() {
return tenantDomain;
}
public String getDevice() {
return device;
}
@ -70,7 +83,9 @@ public class AppInstallLogContext extends LogContext {
private String appId;
private String appName;
private String appType;
private String subType;
private String tenantId;
private String tenantDomain;
private String device;
private String userName;
private String action;
@ -114,6 +129,24 @@ public class AppInstallLogContext extends LogContext {
return this;
}
public String getSubType() {
return subType;
}
public Builder setSubType(String subType) {
this.subType = subType;
return this;
}
public String getTenantDomain() {
return tenantDomain;
}
public Builder setTenantDomain(String tenantDomain) {
this.tenantDomain = tenantDomain;
return this;
}
public String getTenantId() {
return tenantId;
}

@ -93,9 +93,15 @@ public final class MDCContextUtil {
if (mdcContext.getAppType() != null) {
MDC.put("AppType", mdcContext.getAppType());
}
if (mdcContext.getSubType() != null) {
MDC.put("SubType", mdcContext.getSubType());
}
if (mdcContext.getDevice() != null) {
MDC.put("Device", mdcContext.getDevice());
}
if (mdcContext.getTenantDomain() != null) {
MDC.put("TenantDomain", mdcContext.getTenantDomain());
}
if (mdcContext.getTenantId() != null) {
MDC.put("TenantId", mdcContext.getTenantId());
}

Loading…
Cancel
Save