Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: v0.0.5 #48

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def jacocoExcludePatterns = [
"**/*Filter*",
"**/*Resolver*",
"**/resources/**",
"**/common/**"
"**/exception/**",
"**/config/**",
"**/aspect/**",
]

def excludedClassFilesForReport(classDirectories, jacocoExcludePatterns) {
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/com/verby/indp/global/aspect/LogAspect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.verby.indp.global.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Order(1)
@Component
public class LogAspect {

@Pointcut("bean(*Service)")
private void allService() {
}

@Pointcut("bean(*Controller)")
private void allRequest() {
}

@AfterThrowing(pointcut = "allService()", throwing = "exception")
private void logException(JoinPoint joinPoint, RuntimeException exception) {
String exName = exception.getClass().getSimpleName();
String exMessage = exception.getMessage();
String methodName = joinPoint.getSignature().toShortString();
Object[] args = joinPoint.getArgs();

log.warn("[Exception] {} exName=[{}] exMessage=[{}] args=[{}]",
methodName, exName, exMessage, args);
}

@Around("allRequest()")
private Object logRequest(ProceedingJoinPoint joinPoint) throws Throwable {
String methodName = joinPoint.getSignature().toShortString();
Object[] args = joinPoint.getArgs();

log.info("[Request] {} params=[{}]]", methodName, args);

return joinPoint.proceed();
}
}
2 changes: 1 addition & 1 deletion src/main/resources/server-secrets
Loading