Add User log context to get eval user logs

pull/97/head
Pramila Niroshan 2 years ago
parent f597caaec8
commit 7e18ca5d3e

@ -22,11 +22,12 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import io.entgra.device.mgt.extensions.logger.spi.EntgraLogger;
import io.entgra.notification.logger.UserLogContext;
import io.entgra.notification.logger.impl.EntgraUserLoggerImpl;
import io.entgra.ui.request.interceptor.beans.AuthData;
import io.entgra.ui.request.interceptor.util.HandlerConstants;
import io.entgra.ui.request.interceptor.util.HandlerUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpPost;
@ -48,7 +49,8 @@ import java.util.Base64;
@MultipartConfig
@WebServlet("/user")
public class UserHandler extends HttpServlet {
private static final Log log = LogFactory.getLog(UserHandler.class);
private static final EntgraLogger log = new EntgraUserLoggerImpl(UserHandler.class);
UserLogContext.Builder userLogContextBuilder = new UserLogContext.Builder();
private static final long serialVersionUID = 9050048549140517002L;
@Override
@ -118,6 +120,7 @@ public class UserHandler extends HttpServlet {
proxyResponse.setData(
jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", ""));
HandlerUtil.handleSuccess(resp, proxyResponse);
log.info("Eval customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build());
}
} catch (IOException e) {
log.error("Error occurred while sending the response into the socket. ", e);

Loading…
Cancel
Save