Skip to content
Snippets Groups Projects
Commit 841d3960 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4485 Fix Alfa-server logging

parent 98c127c9
No related branches found
No related tags found
No related merge requests found
...@@ -132,16 +132,6 @@ ...@@ -132,16 +132,6 @@
<artifactId>mapstruct</artifactId> <artifactId>mapstruct</artifactId>
</dependency> </dependency>
<!-- aspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<!-- Dev --> <!-- Dev -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
......
...@@ -35,6 +35,16 @@ ...@@ -35,6 +35,16 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId> <artifactId>spring-boot-starter</artifactId>
</dependency> </dependency>
<!-- aspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package de.ozgcloud.alfa.logging;
import org.aspectj.lang.annotation.Pointcut;
public class AlfaAspectPointcuts {
@Pointcut("execution(public * *(..))")
void anyPublicMethods() {
// aspect pointcut - no implementation needed
}
@Pointcut("within(de.ozgcloud..*)")
void anythingInOzgCloud() {
// aspect pointcut - no implementation needed
}
@Pointcut("anyPublicMethods() && anythingInOzgCloud()")
void anyPublicMethodInOzgCloud() {
// aspect pointcut - no implementation needed
}
@Pointcut("anyPublicMethodInOzgCloud() && @target(org.springframework.stereotype.Service)")
void anyPublicServiceMethod() {
// aspect pointcut - no implementation needed
}
@Pointcut("anyPublicMethodInOzgCloud() && @target(org.springframework.web.bind.annotation.RestController)")
void anyPublicRestControllerMethod() {
// aspect pointcut - no implementation needed
}
}
package de.ozgcloud.alfa.logging;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
import de.itvsh.kop.common.logging.AspectLoggingUtils;
@Aspect
@Component
public class AlfaLoggingAspect extends AlfaAspectPointcuts {
@Before("anyPublicServiceMethod() || anyPublicRestControllerMethod()")
public void onServiceMethod(JoinPoint joinPoint) {
AspectLoggingUtils.log(joinPoint);
}
@AfterThrowing(pointcut = "anyPublicServiceMethod() || anyPublicRestControllerMethod()", throwing = "ex")
public void afterExceptionInServiceMethod(JoinPoint joinPoint, Exception ex) {
AspectLoggingUtils.logException(joinPoint, ex);
}
@AfterReturning(pointcut = "anyPublicServiceMethod() || anyPublicRestControllerMethod()", returning = "returnValue")
public void afterServiceMethod(JoinPoint joinPoint, Object returnValue) {
AspectLoggingUtils.logReturnValue(joinPoint, returnValue);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment