11package ir .bigz .springbootreal .commons .generallog ;
22
33import com .fasterxml .jackson .databind .ObjectMapper ;
4+ import ir .bigz .springbootreal .commons .util .Utils ;
45import ir .bigz .springbootreal .exception .AppException ;
56import ir .bigz .springbootreal .exception .HttpExceptionModel ;
67import org .aspectj .lang .JoinPoint ;
8+ import org .aspectj .lang .Signature ;
79import org .aspectj .lang .annotation .*;
810import org .slf4j .Logger ;
911import org .slf4j .LoggerFactory ;
12+ import org .springframework .beans .factory .annotation .Autowired ;
1013import org .springframework .http .ResponseEntity ;
1114import org .springframework .stereotype .Component ;
15+ import org .springframework .web .context .request .RequestContextHolder ;
16+ import org .springframework .web .context .request .ServletRequestAttributes ;
1217
18+ import javax .servlet .http .HttpServletRequest ;
1319import java .util .Arrays ;
1420
1521@ Aspect
@@ -18,13 +24,23 @@ public class AppLogAspect {
1824
1925 private final Logger LOG = LoggerFactory .getLogger (AppLogAspect .class );
2026
27+ private final HttpServletRequest request ;
28+
29+ public AppLogAspect (HttpServletRequest request ) {
30+ this .request = request ;
31+ }
32+
2133 @ Before ("ir.bigz.springbootreal.commons.generallog.CommonJoinPoint.controllerExecution()" )
2234 public void beforeCallControllerMethod (JoinPoint joinPoint ){
2335 String methodName = joinPoint .getSignature ().getName ();
2436 Object [] args = joinPoint .getArgs ();
37+ String queryString = "" ;
38+ if (Utils .isNotNull (request .getQueryString ())){
39+ queryString = request .getQueryString ();
40+ }
2541 String reduce = Arrays .stream (args ).reduce ("" , (s , s2 ) -> s + " " + s2 ).toString ();
26- LOG .info ("before method: {} | argument: {}" ,
27- methodName , reduce );
42+ LOG .info ("before method: {} | argument: {} | queryString: {} " ,
43+ methodName , reduce , queryString );
2844 }
2945
3046 @ AfterReturning (value = "ir.bigz.springbootreal.commons.generallog.CommonJoinPoint.controllerExecution()" ,
0 commit comments