forked from community/device-mgt-core
Add custom loggers (#136)
* Fixes https://roadmap.entgra.net/issues/10117 * Added custom logs for below cases: 1. Device connectivity events 2. Policy payload change events 3. Device enrollment history events 4. App install events **1. Device connectivity logs** - logs for newly added operations and calls for pending operations Pattern : {DateTime} {LogLevel} - {ActionTag} {OperationCode} {DeviceId} {DeviceType} {TenantDomain} {TenantId} {UserName} - log_message ``` [2023-06-15 00:12:09,093] INFO - [ADD_OPERATION] [DEVICE_LOCATION] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:12:10,344] INFO - [PENDING_OPERATION] [DEVICE_LOCATION] [675c60a9d31492d6] [android] [carbon.super] [-1234] [admin]- Device Connected [2023-06-15 00:13:49,755] INFO - [ADD_OPERATION] [DEVICE_LOCK] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:13:56,513] INFO - [ADD_OPERATION] [DEVICE_MUTE] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:14:23,839] INFO - [PENDING_OPERATION] [DEVICE_MUTE] [2023-06-15 00:15:12,549] INFO - [ADD_OPERATION] [INSTALL_APPLICATION] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:15:29,703] INFO - [PENDING_OPERATION] [INSTALL_APPLICATION] [675c60a9d31492d6] [android] [carbon.super] [-1234] [admin]- Device Connected ``` **2. Policy payload change events** - logs for creating policy, updating policy, deleting policy, change policy priorities and apply changes to device logs Pattern : {DateTime} {LogLevel} - {ActionTag} {PolicyName} {TenantDomain} {TenantId} {Payload} {UserName} - log_message ``` [2023-06-15 00:15:53,264] INFO - [UPDATE_POLICY] [passcodeios] [carbon.super] [-1234] [{"policyPayloadVersion":"2.0","id":33,"priorityId":1,"profile":{"profileId":33,"profileName":"passcodeios","tenantId":0,"deviceType":"ios","updatedDate":"Jun 15, 2023 12:15:53 AM","profileFeaturesList":[{"id":33,"featureCode":"PASSCODE_POLICY","profileId":0,"deviceType":"ios","content":"{\"forcePIN\":true,\"allowSimple\":true,\"requireAlphanumeric\":true,\"minLength\":7.0,\"minComplexChars\":4.0,\"pinHistory\":\"\"}","correctiveActions":[]}]},"policyName":"passcodeios","generic":false,"roles":["ANY"],"devices":[],"users":[],"active":false,"updated":false,"description":"test","compliance":"enforce","tenantId":-1234,"profileId":33,"policyType":"GENERAL"}] [admin] - Policy updated [2023-06-15 00:34:38,980] INFO - [ADD_POLICY] [application management policy] [carbon.super] [-1234] [{"policyPayloadVersion":"2.0","id":65,"priorityId":0,"profile":{"profileId":65,"profileName":"application management policy","tenantId":0,"deviceType":"windows","createdDate":"Jun 15, 2023 12:34:38 AM","updatedDate":"Jun 15, 2023 12:34:38 AM","profileFeaturesList":[{"id":65,"featureCode":"ALLOW_ALL_TRUSTED_APPS","profileId":0,"deviceType":"windows","content":"{\"enabled\":true}","correctiveActions":[]},{"id":73,"featureCode":"RESTRICT_APP_TO_SYSTEM_VOLUME","profileId":0,"deviceType":"windows","content":"{\"enabled\":false}","correctiveActions":[]}]},"policyName":"application management policy","generic":false,"roles":["ANY"],"devices":[],"users":[],"active":false,"updated":false,"description":"test","compliance":"enforce","tenantId":-1234,"profileId":0,"policyType":"GENERAL"}] [admin] - Policy created [2023-06-15 00:35:05,420] INFO - [DELETE_POLICY] [passcodeios] [carbon.super] [-1234] [{"policyPayloadVersion":"2.0","id":33,"priorityId":1,"profile":{"profileId":33,"profileName":"passcodeios","tenantId":-1234,"deviceType":"ios","createdDate":"Jun 13, 2023 10:24:30 PM","updatedDate":"Jun 15, 2023 12:15:53 AM","profileFeaturesList":[{"id":33,"featureCode":"PASSCODE_POLICY","profileId":33,"deviceType":"ios","content":"{\"forcePIN\":true,\"allowSimple\":true,\"requireAlphanumeric\":true,\"minLength\":7.0,\"minComplexChars\":4.0,\"pinHistory\":\"\"}","correctiveActions":[]}]},"policyName":"passcodeios","generic":false,"roles":["ANY"],"devices":[],"users":[],"active":false,"updated":true,"description":"test","compliance":"enforce","policyCriterias":[],"tenantId":-1234,"profileId":33,"deviceGroups":[],"policyType":"GENERAL"}] [admin] - Policy deleted [2023-06-15 00:35:12,768] INFO - [UPDATE_POLICY_PRIORITIES] [] [carbon.super] [-1234] [[{"id":65,"priorityId":1,"generic":false,"active":false,"updated":false,"tenantId":0,"profileId":0},{"id":34,"priorityId":2,"generic":false,"active":false,"updated":false,"tenantId":0,"profileId":0}]] [admin] - Policy priorities updated [2023-06-15 00:35:25,395] INFO - [PUBLISH_CHANGES] [] [carbon.super] [-1234] [] [admin] - Apply changes to device ``` **3. Device enrollment history events** - logs for device enrollment and dis-enrollment Pattern : {DateTime} {LogLevel} - {DeviceId} {DeviceType} {Owner} {Ownership} {TenantId} {TenantDomain} {UserName} - log_message ``` [2023-06-15 00:12:09,078] INFO - [97] [android] [admin] [BYOD] [-1234] [carbon.super] [admin] - Device enrolled successfully [2023-06-15 00:47:36,278] INFO - [97] [android] [admin] [BYOD] [-1234] [carbon.super] [admin] - Device disenrolled successfully ``` **4. App install events** - logs for app installation and uninstallation Pattern : {DateTime} {LogLevel} - {AppId} {AppName} {AppType} {SubType} {Action} {Device} {TenantId} {TenantDomain} {UserName} - log_message ``` [2023-06-15 00:15:12,550] INFO - [1] [Calculator] [PUBLIC] [DEVICE] [install] [deviceId {id='675c60a9d31492d6', type='android'}] [-1234] [carbon.super] [admin] - App install triggered [2023-06-15 00:46:24,454] INFO - [2] [Sololearn] [ENTERPRISE] [DEVICE] [install] [deviceId {id='675c60a9d31492d6', type='android'}] [-1234] [carbon.super] [admin] - App install triggered [2023-06-15 00:46:40,498] INFO - [3] [Engineering] [WEB_CLIP] [DEVICE] [install] [deviceId {id='675c60a9d31492d6', type='android'}] [-1234] [carbon.super] [admin] - Web app install triggered ``` * proprietary/product-uem#6 Co-authored-by: prathabanKavin <kavinprathaban025@gmail.com> Co-authored-by: Pahansith Gunathilake <pahansith@entgra.io> Reviewed-on: community/device-mgt-core#136 Co-authored-by: Kavin Prathaban <kavin@entgra.io> Co-committed-by: Kavin Prathaban <kavin@entgra.io>remotes/1728937285237262521/tmp_refs/heads/master
parent
74e06047f1
commit
7ad3a0e21b
@ -0,0 +1,181 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.entgra.device.mgt.core.notification.logger;
|
||||||
|
|
||||||
|
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 subType;
|
||||||
|
private final String tenantId;
|
||||||
|
private final String tenantDomain;
|
||||||
|
private final String device;
|
||||||
|
private final String userName;
|
||||||
|
private final String action;
|
||||||
|
|
||||||
|
private AppInstallLogContext(Builder builder) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppId() {
|
||||||
|
return appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
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;
|
||||||
|
|
||||||
|
public Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppId() {
|
||||||
|
return appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setAppId(String appId) {
|
||||||
|
this.appId = appId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppName() {
|
||||||
|
return appName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setAppName(String appName) {
|
||||||
|
this.appName = appName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppType() {
|
||||||
|
return appType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setAppType(String appType) {
|
||||||
|
this.appType = appType;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setTenantId(String tenantId) {
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDevice() {
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setDevice(String device) {
|
||||||
|
this.device = device;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setAction(String action) {
|
||||||
|
this.action = action;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppInstallLogContext build() {
|
||||||
|
return new AppInstallLogContext(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.entgra.device.mgt.core.notification.logger;
|
||||||
|
|
||||||
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||||
|
|
||||||
|
public class DeviceConnectivityLogContext extends LogContext {
|
||||||
|
|
||||||
|
private final String deviceId;
|
||||||
|
private final String deviceType;
|
||||||
|
private final String actionTag;
|
||||||
|
private final String operationCode;
|
||||||
|
private final String tenantId;
|
||||||
|
private final String tenantDomain;
|
||||||
|
private final String userName;
|
||||||
|
|
||||||
|
private DeviceConnectivityLogContext(Builder builder) {
|
||||||
|
this.deviceId = builder.deviceId;
|
||||||
|
this.deviceType = builder.deviceType;
|
||||||
|
this.actionTag = builder.actionTag;
|
||||||
|
this.operationCode = builder.operationCode;
|
||||||
|
this.tenantId = builder.tenantId;
|
||||||
|
this.tenantDomain = builder.tenantDomain;
|
||||||
|
this.userName = builder.userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceType() {
|
||||||
|
return deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActionTag() {
|
||||||
|
return actionTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperationCode() {
|
||||||
|
return operationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantId() {
|
||||||
|
return tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantDomain() {
|
||||||
|
return tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String deviceId;
|
||||||
|
private String deviceType;
|
||||||
|
private String operationCode;
|
||||||
|
private String actionTag;
|
||||||
|
private String tenantId;
|
||||||
|
private String tenantDomain;
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
public Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setDeviceId(String deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceType() {
|
||||||
|
return deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setDeviceType(String deviceType) {
|
||||||
|
this.deviceType = deviceType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperationCode() {
|
||||||
|
return operationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setOperationCode(String operationCode) {
|
||||||
|
this.operationCode = operationCode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantId() {
|
||||||
|
return tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setTenantId(String tenantId) {
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantDomain() {
|
||||||
|
return tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setTenantDomain(String tenantDomain) {
|
||||||
|
this.tenantDomain = tenantDomain;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActionTag() {
|
||||||
|
return actionTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setActionTag(String actionTag) {
|
||||||
|
this.actionTag = actionTag;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceConnectivityLogContext build() {
|
||||||
|
return new DeviceConnectivityLogContext(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.entgra.device.mgt.core.notification.logger;
|
||||||
|
|
||||||
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||||
|
|
||||||
|
public class DeviceEnrolmentLogContext extends LogContext {
|
||||||
|
private final String deviceId;
|
||||||
|
private final String deviceType;
|
||||||
|
private final String owner;
|
||||||
|
private final String ownership;
|
||||||
|
private final String tenantID;
|
||||||
|
private final String tenantDomain;
|
||||||
|
private final String userName;
|
||||||
|
|
||||||
|
private DeviceEnrolmentLogContext(Builder builder) {
|
||||||
|
this.deviceId = builder.deviceId;
|
||||||
|
this.deviceType = builder.deviceType;
|
||||||
|
this.owner = builder.owner;
|
||||||
|
this.ownership = builder.ownership;
|
||||||
|
this.tenantID = builder.tenantID;
|
||||||
|
this.tenantDomain = builder.tenantDomain;
|
||||||
|
this.userName = builder.userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantID() {
|
||||||
|
return tenantID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceType() {
|
||||||
|
return deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwnership() {
|
||||||
|
return ownership;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantDomain() {
|
||||||
|
return tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
public static class Builder {
|
||||||
|
private String deviceId;
|
||||||
|
private String deviceType;
|
||||||
|
private String owner;
|
||||||
|
private String ownership;
|
||||||
|
private String tenantID;
|
||||||
|
private String tenantDomain;
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
public Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceType() {
|
||||||
|
return deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setDeviceType(String deviceType) {
|
||||||
|
this.deviceType = deviceType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantID() {
|
||||||
|
return tenantID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setTenantID(String tenantID) {
|
||||||
|
this.tenantID = tenantID;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantDomain() {
|
||||||
|
return tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setTenantDomain(String tenantDomain) {
|
||||||
|
this.tenantDomain = tenantDomain;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setDeviceId(String deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setOwner(String owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwnership() {
|
||||||
|
return ownership;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setOwnership(String ownership) {
|
||||||
|
this.ownership = ownership;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceEnrolmentLogContext build() {
|
||||||
|
return new DeviceEnrolmentLogContext(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.entgra.device.mgt.core.notification.logger;
|
||||||
|
|
||||||
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||||
|
|
||||||
|
public class PolicyLogContext extends LogContext {
|
||||||
|
private final String policyName;
|
||||||
|
private final String payload;
|
||||||
|
private final String actionTag;
|
||||||
|
private final String userName;
|
||||||
|
private final String tenantID;
|
||||||
|
private final String tenantDomain;
|
||||||
|
|
||||||
|
private PolicyLogContext(Builder builder) {
|
||||||
|
this.policyName = builder.policyName;
|
||||||
|
this.payload = builder.payload;
|
||||||
|
this.actionTag = builder.actionTag;
|
||||||
|
this.userName = builder.userName;
|
||||||
|
this.tenantID = builder.tenantID;
|
||||||
|
this.tenantDomain = builder.tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPolicyName() {
|
||||||
|
return policyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPayload() {
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActionTag() {
|
||||||
|
return actionTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantID() {
|
||||||
|
return tenantID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantDomain() {
|
||||||
|
return tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String policyName;
|
||||||
|
private String payload;
|
||||||
|
private String actionTag;
|
||||||
|
private String userName;
|
||||||
|
private String tenantID;
|
||||||
|
private String tenantDomain;
|
||||||
|
|
||||||
|
public Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPolicyName() {
|
||||||
|
return policyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setPolicyName(String policyName) {
|
||||||
|
this.policyName = policyName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPayload() {
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setPayload(String payload) {
|
||||||
|
this.payload = payload;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActionTag() {
|
||||||
|
return actionTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setActionTag(String actionTag) {
|
||||||
|
this.actionTag = actionTag;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantID() {
|
||||||
|
return tenantID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setTenantID(String tenantID) {
|
||||||
|
this.tenantID = tenantID;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantDomain() {
|
||||||
|
return tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setTenantDomain(String tenantDomain) {
|
||||||
|
this.tenantDomain = tenantDomain;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PolicyLogContext build() {
|
||||||
|
return new PolicyLogContext(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,318 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package io.entgra.device.mgt.core.notification.logger.impl;
|
||||||
|
|
||||||
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||||
|
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.util.MDCContextUtil;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.log4j.MDC;
|
||||||
|
|
||||||
|
public class EntgraAppInstallLoggerImpl implements EntgraLogger {
|
||||||
|
|
||||||
|
private static Log log = null;
|
||||||
|
|
||||||
|
public EntgraAppInstallLoggerImpl(Class<?> clazz) {
|
||||||
|
log = LogFactory.getLog(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String message) {
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String message, Throwable t) {
|
||||||
|
log.info(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object o) {
|
||||||
|
log.info(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object o, Throwable throwable) {
|
||||||
|
log.info(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(String message, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object object, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.info(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object object, Throwable t, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.info(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message) {
|
||||||
|
log.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message, Throwable t) {
|
||||||
|
log.debug(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object o) {
|
||||||
|
log.debug(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object o, Throwable throwable) {
|
||||||
|
log.debug(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(String message, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object object, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.debug(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object object, Throwable t, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.debug(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message) {
|
||||||
|
log.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message, Throwable t) {
|
||||||
|
log.error(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object o) {
|
||||||
|
log.error(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object o, Throwable throwable) {
|
||||||
|
log.error(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, Throwable t, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.error(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object object, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.error(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object object, Throwable t, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.error(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message) {
|
||||||
|
log.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message, Throwable t) {
|
||||||
|
log.warn(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object o) {
|
||||||
|
log.warn(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object o, Throwable throwable) {
|
||||||
|
log.warn(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, Throwable t, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.warn(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object object, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.warn(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object object, Throwable t, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.warn(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(String message) {
|
||||||
|
log.trace(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(String message, Throwable t) {
|
||||||
|
log.trace(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object o) {
|
||||||
|
log.trace(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object o, Throwable throwable) {
|
||||||
|
log.trace(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String message, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.trace(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object object, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.trace(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object object, Throwable t, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.trace(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fatal(String message) {
|
||||||
|
log.fatal(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fatal(String message, Throwable t) {
|
||||||
|
log.fatal(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object o) {
|
||||||
|
log.fatal(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object o, Throwable throwable) {
|
||||||
|
log.fatal(0, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(String message, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.fatal(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object object, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.fatal(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object object, Throwable t, LogContext logContext) {
|
||||||
|
AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext;
|
||||||
|
MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext);
|
||||||
|
log.fatal(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDebugEnabled() {
|
||||||
|
return log.isDebugEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isErrorEnabled() {
|
||||||
|
return log.isErrorEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFatalEnabled() {
|
||||||
|
return log.isFatalEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInfoEnabled() {
|
||||||
|
return log.isInfoEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return log.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWarnEnabled() {
|
||||||
|
return log.isWarnEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearLogContext() {
|
||||||
|
MDC.clear();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,318 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package io.entgra.device.mgt.core.notification.logger.impl;
|
||||||
|
|
||||||
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||||
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
|
||||||
|
import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContext;
|
||||||
|
import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.log4j.MDC;
|
||||||
|
|
||||||
|
public class EntgraDeviceConnectivityLoggerImpl implements EntgraLogger {
|
||||||
|
|
||||||
|
private static Log log = null;
|
||||||
|
|
||||||
|
public EntgraDeviceConnectivityLoggerImpl(Class<?> clazz) {
|
||||||
|
log = LogFactory.getLog(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String message) {
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String message, Throwable t) {
|
||||||
|
log.info(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object o) {
|
||||||
|
log.info(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object o, Throwable throwable) {
|
||||||
|
log.info(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(String message, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object object, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.info(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.info(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message) {
|
||||||
|
log.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message, Throwable t) {
|
||||||
|
log.debug(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object o) {
|
||||||
|
log.debug(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object o, Throwable throwable) {
|
||||||
|
log.debug(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(String message, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object object, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.debug(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.debug(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message) {
|
||||||
|
log.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message, Throwable t) {
|
||||||
|
log.error(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object o) {
|
||||||
|
log.error(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object o, Throwable throwable) {
|
||||||
|
log.error(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, Throwable t, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.error(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object object, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.error(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.error(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message) {
|
||||||
|
log.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message, Throwable t) {
|
||||||
|
log.warn(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object o) {
|
||||||
|
log.warn(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object o, Throwable throwable) {
|
||||||
|
log.warn(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, Throwable t, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.warn(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object object, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.warn(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.warn(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(String message) {
|
||||||
|
log.trace(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(String message, Throwable t) {
|
||||||
|
log.trace(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object o) {
|
||||||
|
log.trace(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object o, Throwable throwable) {
|
||||||
|
log.trace(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String message, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.trace(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object object, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.trace(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.trace(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fatal(String message) {
|
||||||
|
log.fatal(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fatal(String message, Throwable t) {
|
||||||
|
log.fatal(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object o) {
|
||||||
|
log.fatal(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object o, Throwable throwable) {
|
||||||
|
log.fatal(0, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(String message, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.fatal(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object object, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.fatal(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext);
|
||||||
|
log.fatal(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDebugEnabled() {
|
||||||
|
return log.isDebugEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isErrorEnabled() {
|
||||||
|
return log.isErrorEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFatalEnabled() {
|
||||||
|
return log.isFatalEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInfoEnabled() {
|
||||||
|
return log.isInfoEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return log.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWarnEnabled() {
|
||||||
|
return log.isWarnEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearLogContext() {
|
||||||
|
MDC.clear();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,318 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package io.entgra.device.mgt.core.notification.logger.impl;
|
||||||
|
|
||||||
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||||
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
|
||||||
|
import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext;
|
||||||
|
import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.log4j.MDC;
|
||||||
|
|
||||||
|
public class EntgraDeviceEnrolmentLoggerImpl implements EntgraLogger {
|
||||||
|
|
||||||
|
private static Log log = null;
|
||||||
|
|
||||||
|
public EntgraDeviceEnrolmentLoggerImpl(Class<?> clazz) {
|
||||||
|
log = LogFactory.getLog(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String message) {
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String message, Throwable t) {
|
||||||
|
log.info(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object o) {
|
||||||
|
log.info(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object o, Throwable throwable) {
|
||||||
|
log.info(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(String message, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object object, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.info(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.info(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message) {
|
||||||
|
log.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message, Throwable t) {
|
||||||
|
log.debug(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object o) {
|
||||||
|
log.debug(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object o, Throwable throwable) {
|
||||||
|
log.debug(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(String message, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object object, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.debug(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.debug(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message) {
|
||||||
|
log.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message, Throwable t) {
|
||||||
|
log.error(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object o) {
|
||||||
|
log.error(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object o, Throwable throwable) {
|
||||||
|
log.error(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, Throwable t, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.error(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object object, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.error(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.error(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message) {
|
||||||
|
log.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message, Throwable t) {
|
||||||
|
log.warn(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object o) {
|
||||||
|
log.warn(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object o, Throwable throwable) {
|
||||||
|
log.warn(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, Throwable t, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.warn(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object object, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.warn(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.warn(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(String message) {
|
||||||
|
log.trace(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(String message, Throwable t) {
|
||||||
|
log.trace(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object o) {
|
||||||
|
log.trace(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object o, Throwable throwable) {
|
||||||
|
log.trace(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String message, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.trace(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object object, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.trace(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.trace(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fatal(String message) {
|
||||||
|
log.fatal(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fatal(String message, Throwable t) {
|
||||||
|
log.fatal(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object o) {
|
||||||
|
log.fatal(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object o, Throwable throwable) {
|
||||||
|
log.fatal(0, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(String message, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.fatal(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object object, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.fatal(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object object, Throwable t, LogContext logContext) {
|
||||||
|
DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext;
|
||||||
|
MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext);
|
||||||
|
log.fatal(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDebugEnabled() {
|
||||||
|
return log.isDebugEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isErrorEnabled() {
|
||||||
|
return log.isErrorEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFatalEnabled() {
|
||||||
|
return log.isFatalEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInfoEnabled() {
|
||||||
|
return log.isInfoEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return log.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWarnEnabled() {
|
||||||
|
return log.isWarnEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearLogContext() {
|
||||||
|
MDC.clear();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,318 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package io.entgra.device.mgt.core.notification.logger.impl;
|
||||||
|
|
||||||
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||||
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
|
||||||
|
import io.entgra.device.mgt.core.notification.logger.PolicyLogContext;
|
||||||
|
import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.log4j.MDC;
|
||||||
|
|
||||||
|
public class EntgraPolicyLoggerImpl implements EntgraLogger {
|
||||||
|
|
||||||
|
private static Log log = null;
|
||||||
|
|
||||||
|
public EntgraPolicyLoggerImpl(Class<?> clazz) {
|
||||||
|
log = LogFactory.getLog(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String message) {
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String message, Throwable t) {
|
||||||
|
log.info(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object o) {
|
||||||
|
log.info(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object o, Throwable throwable) {
|
||||||
|
log.info(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(String message, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object object, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.info(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(Object object, Throwable t, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.info(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message) {
|
||||||
|
log.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message, Throwable t) {
|
||||||
|
log.debug(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object o) {
|
||||||
|
log.debug(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object o, Throwable throwable) {
|
||||||
|
log.debug(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(String message, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object object, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.debug(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debug(Object object, Throwable t, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.debug(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message) {
|
||||||
|
log.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message, Throwable t) {
|
||||||
|
log.error(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object o) {
|
||||||
|
log.error(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object o, Throwable throwable) {
|
||||||
|
log.error(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, Throwable t, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.error(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object object, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.error(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Object object, Throwable t, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.error(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message) {
|
||||||
|
log.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message, Throwable t) {
|
||||||
|
log.warn(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object o) {
|
||||||
|
log.warn(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object o, Throwable throwable) {
|
||||||
|
log.warn(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, Throwable t, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.warn(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object object, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.warn(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(Object object, Throwable t, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.warn(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(String message) {
|
||||||
|
log.trace(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(String message, Throwable t) {
|
||||||
|
log.trace(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object o) {
|
||||||
|
log.trace(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object o, Throwable throwable) {
|
||||||
|
log.trace(o, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String message, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.trace(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object object, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.trace(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(Object object, Throwable t, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.trace(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fatal(String message) {
|
||||||
|
log.fatal(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fatal(String message, Throwable t) {
|
||||||
|
log.fatal(message, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object o) {
|
||||||
|
log.fatal(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object o, Throwable throwable) {
|
||||||
|
log.fatal(0, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(String message, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.fatal(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object object, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.fatal(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatal(Object object, Throwable t, LogContext logContext) {
|
||||||
|
PolicyLogContext policyLogContext = (PolicyLogContext) logContext;
|
||||||
|
MDCContextUtil.populatePolicyMDCContext(policyLogContext);
|
||||||
|
log.fatal(object, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDebugEnabled() {
|
||||||
|
return log.isDebugEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isErrorEnabled() {
|
||||||
|
return log.isErrorEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFatalEnabled() {
|
||||||
|
return log.isFatalEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInfoEnabled() {
|
||||||
|
return log.isInfoEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return log.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWarnEnabled() {
|
||||||
|
return log.isWarnEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearLogContext() {
|
||||||
|
MDC.clear();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue