-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* del: 안쓰는 파일 삭제 * feat: logback 설정 * feat: aop 로깅 구현 * feat: yml 세팅 및 cd 수정
- Loading branch information
Showing
15 changed files
with
401 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,9 +109,9 @@ jobs: | |
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create application.yaml file | ||
- name: Create application-secret.properties file | ||
run: | | ||
echo "${{ secrets.APPLICATION_YAML_API }}" > ./${{ env.MODULE }}/infra/${{ env.DEPLOY_TARGET }}/application.yaml | ||
echo "${{ secrets.APPLICATION_SECRET_PROPERTIES }}" > ./${{ env.MODULE }}/infra/${{ env.DEPLOY_TARGET }}/application-secret.properties | ||
- name: Send Docker Compose | ||
uses: appleboy/[email protected] | ||
|
@@ -132,6 +132,6 @@ jobs: | |
port: 22 | ||
script: | | ||
cd /home/${{ env.MODULE }}/infra/${{ env.DEPLOY_TARGET }} | ||
echo "${{ secrets.APPLICATION_YAML_API }}" > application.yaml | ||
docker compose pull | ||
docker compose up -d | ||
echo "${{ secrets.APPLICATION_SECRET_PROPERTIES }}" > application-secret.properties | ||
docker-compose pull | ||
docker-compose up -d |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
FROM openjdk:17 | ||
|
||
ARG JAR_FILE=./build/libs/*.jar | ||
ARG SPRING_PROFILE | ||
|
||
COPY ${JAR_FILE} layer-server.jar | ||
|
||
ENV SPRING_PROFILE=${SPRING_PROFILE} | ||
|
||
ENTRYPOINT ["java","-Dspring.profiles.active=prod" ,"-jar" ,"layer-server.jar"] | ||
ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul" ,"-jar" ,"layer-server.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
layer-api/src/main/java/org/layer/aop/ExecutionLoggingAop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package org.layer.aop; | ||
|
||
import java.util.Objects; | ||
|
||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.StopWatch; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.context.request.RequestContextHolder; | ||
import org.springframework.web.context.request.ServletRequestAttributes; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Aspect | ||
@Component | ||
@Log4j2 | ||
public class ExecutionLoggingAop { | ||
|
||
// 모든 layer-api 모듈 내의 controller package에 존재하는 클래스 | ||
@Around("execution(* org.layer.domain..controller..*(..))") | ||
public Object logExecutionTrace(ProceedingJoinPoint pjp) throws Throwable { | ||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); | ||
RequestMethod httpMethod = RequestMethod.valueOf(request.getMethod()); | ||
|
||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
Long memberId = null; | ||
if (!authentication.getPrincipal().equals("anonymousUser")) { | ||
memberId = (Long) authentication.getPrincipal(); | ||
} | ||
|
||
String className = pjp.getSignature().getDeclaringType().getSimpleName(); | ||
String methodName = pjp.getSignature().getName(); | ||
String task = className + "." + methodName; | ||
|
||
log.info("[Call Method] " + httpMethod + ": " + task + " | Request userId=" + memberId); | ||
|
||
Object[] paramArgs = pjp.getArgs(); | ||
String loggingMessage = ""; | ||
int cnt = 1; | ||
for (Object object : paramArgs) { | ||
if (Objects.nonNull(object)) { | ||
String paramName = "[param" + cnt +"] " + object.getClass().getSimpleName(); | ||
String paramValue = " [value" + cnt +"] " + object; | ||
loggingMessage += paramName + paramValue + "\n"; | ||
cnt++; | ||
} | ||
} | ||
log.info("{}", loggingMessage); | ||
// 해당 클래스 처리 전의 시간 | ||
StopWatch sw = new StopWatch(); | ||
sw.start(); | ||
|
||
Object result = null; | ||
|
||
// 해당 클래스의 메소드 실행 | ||
try{ | ||
result = pjp.proceed(); | ||
} | ||
catch (Exception e){ | ||
log.warn("[ERROR] " + task + " 메서드 예외 발생 : " + e.getMessage()); | ||
throw e; | ||
} | ||
|
||
// 해당 클래스 처리 후의 시간 | ||
sw.stop(); | ||
long executionTime = sw.getTotalTimeMillis(); | ||
|
||
log.info("[ExecutionTime] " + task + " --> " + executionTime + " (ms)"); | ||
|
||
return result; | ||
} | ||
|
||
} |
65 changes: 0 additions & 65 deletions
65
layer-api/src/main/java/org/layer/filter/LoggerFilter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
spring: | ||
config: | ||
import: application-secret.properties | ||
datasource: | ||
url: ${DEV_DB_URL} | ||
username: ${DEV_DB_NAME} | ||
password: ${DEV_DB_PASSWORD} | ||
driver-class-name: com.mysql.cj.jdbc.Driver | ||
jpa: | ||
hibernate: | ||
ddl-auto: update | ||
properties: | ||
hibernate: | ||
format_sql: true | ||
show_sql: true | ||
open-in-view: false | ||
database: mysql | ||
|
||
data: | ||
redis: | ||
host: ${DEV_REDIS_HOST} | ||
port: ${DEV_REDIS_PORT} | ||
password: ${DEV_REDIS_PASSWORD} | ||
|
||
jwt: | ||
secret: ${DEV_JWT_SECRET} | ||
|
||
kakao: | ||
login: | ||
api_key: ${DEV_KAKAO_API_KEY} | ||
redirect_uri: ${DEV_KAKAO_REDIRECT_URI} | ||
uri: | ||
base: https://kauth.kakao.com | ||
code: /oauth/authorize | ||
token: /oauth/token | ||
api: | ||
uri: | ||
base: https://kapi.kakao.com | ||
user: /v2/user/me | ||
|
||
google: | ||
login: | ||
client_id: ${DEV_GOOGLE_CLIENT_ID} | ||
code_uri: ${DEV_GOOGLE_CODE_URI} | ||
token_uri: ${DEV_GOOGLE_TOKEN_URI} | ||
client_secret: ${DEV_GOOGLE_CLIENT_SECRET} | ||
redirect_uri: ${DEV_GOOGLE_REDIRECT_URI} | ||
code_redirect_uri: http://localhost:8080/api/auth/oauth2/google/code | ||
|
||
|
||
webmvc: | ||
cors: | ||
allowedOrigins: | ||
http://localhost:8080, | ||
https://api.layerapp.io, | ||
https://layerapp.io, | ||
http://localhost:5173 | ||
|
||
ncp: | ||
storage: | ||
region: ${STORAGE_REGION} | ||
bucketName: ${STORAGE_NAME} | ||
endpoint: ${STORAGE_ENDPOINT} | ||
accessKey: ${STORAGE_ACCESS_KEY} | ||
secretKey: ${STORAGE_SECRET_KEY} |
Oops, something went wrong.