Untitled
unknown
java
a year ago
1.7 kB
5
Indexable
package com.cais.ufg.aspect;
import com.cais.ufg.tracing.UfgRequestContext;
import com.cais.ufg.tracing.UfgRequestTraceService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Aspect
@Component
@Slf4j
public class UfgRequestLoggingAspect {
@Autowired
private UfgRequestTraceService traceService;
@Pointcut("@annotation(com.cais.ufg.aspect.LogUfgRequest)")
public void logUfgRequestPointcut() {
}
@AfterReturning(value = "logUfgRequestPointcut()", returning = "response")
public void logUfgRequest(Object response) {
try {
// Retrieve all necessary data for UfgRequestContext creation
UfgRequestContext context = new UfgRequestContext(
"endpointUrl", // Replace with actual data
"objectId",
"organizationCauseSign",
"caseSignType",
"purpose",
"externalLogsCorrelationId",
"businessUserId",
"tokenIssuer",
"tokenSecurityContextUsername",
"requestBody",
"responseBody",
new String[]{"header1", "header2"}, // Replace as needed
"traceId",
"callerAddress"
);
// Log the UfgRequestContext
traceService.log(context);
} catch (Exception e) {
log.error("Failed to log UfgRequestContext", e);
}
}
}Editor is loading...
Leave a Comment