|
|
@@ -58,11 +58,19 @@ public class SqlOperationAspect extends AbstractLoggingAspect {
|
|
|
final long start = System.currentTimeMillis();
|
|
|
long executionTime;
|
|
|
Object result;
|
|
|
+
|
|
|
+ if (!Objects.equals(param, "") && paramValue == null) {
|
|
|
+ paramValue = param;
|
|
|
+ }
|
|
|
+ if (!Objects.equals(param2, "") && paramValue2 == null) {
|
|
|
+ paramValue2 = param2;
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
result = joinPoint.proceed(); // SQL 실행
|
|
|
} catch (Exception e) {
|
|
|
executionTime = System.currentTimeMillis() - start;
|
|
|
- log.error("({}) {}: Exception: {}", type, LogUtils.elapsedLog(tableName, executionTime), e.getMessage());
|
|
|
+ exceptionLog(type, tableName, executionTime, e.getMessage(), paramValue, paramValue2);
|
|
|
if (signature.getReturnType().equals(int.class)) {
|
|
|
return -1; // int 반환 타입 예외 발생 시 -1 반환
|
|
|
}
|
|
|
@@ -82,10 +90,6 @@ public class SqlOperationAspect extends AbstractLoggingAspect {
|
|
|
count = list.size(); // List 의 크기 계산
|
|
|
}
|
|
|
|
|
|
- if (!Objects.equals(param, "") && paramValue == null) {
|
|
|
- paramValue = param;
|
|
|
- }
|
|
|
-
|
|
|
if (isLogging) {
|
|
|
String info;
|
|
|
if (Objects.requireNonNull(sqlOperation.type()) == SqlOperation.SqlType.TRUNCATE) {
|
|
|
@@ -98,6 +102,21 @@ public class SqlOperationAspect extends AbstractLoggingAspect {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private void exceptionLog(String type, String tableName, long executionTime, String errMessage, String paramValue, String paramValue2) {
|
|
|
+ String info = LogUtils.elapsedLog(tableName, executionTime);
|
|
|
+ if (paramValue != null) {
|
|
|
+ if (paramValue2 != null) {
|
|
|
+ log.error("({}) {}: {}, {}, Exception: {}", type, info, paramValue, paramValue2, errMessage);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ log.error("({}) {}: {}, Exception: {}", type, info, paramValue, errMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ log.error("({}) {}: Exception: {}", type, info, errMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void logging(String type, String info, String paramValue, String paramValue2) {
|
|
|
if (paramValue != null) {
|
|
|
if (paramValue2 != null) {
|
|
|
@@ -108,7 +127,12 @@ public class SqlOperationAspect extends AbstractLoggingAspect {
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- log.info("({}) {}", type, info);
|
|
|
+ if (paramValue2 != null) {
|
|
|
+ log.info("({}) {}: {}", type, info, paramValue2);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ log.info("({}) {}", type, info);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|