Closed whchoi83 closed 7 years ago
찾아보니... 한가지 방식으로 통일하는 것이 항상 좋은 것은 아니네요. (참고 : http://stackoverflow.com/questions/6504407/is-there-a-need-to-do-a-iflog-isdebugenabled-check)
performance 와 관련있는 주제인데, 단순히 static string log 를 찍을 경우는 위의 방식이 좋고,
debug()
의 parameter 로 string concatenation 등을 넘겨야 하는 경우는 아래의 방식이 좋다고 합니다.
debug()
내부를 보면 진입하자마자 if(getlogger().isDebugEnabled)
를 수행합니다. 이걸 굳이 debug() 호출 전에 명시적으로 해 주는 이유는, getLogger().debug(string1 + string2 + string3)
과 같이 static string 이 아니라 변수를 넘겨 로그를 찍는 경우 string concatenation 연산이 애초에 일어나지 않도록 방지하기 위한 것입니다.
@aiceru java client 는 대부분 static string log 로 찍는 형태가 아닌 것으로 알고 있습니다. 하나로 합쳐야 된다고 하는 부분은 대부분의 경우 두 번째 형태로 되어있지만 (아마도 실수 인것으로 보이는) 첫 번째 형태인 코드들이 간혹 있습니다.
예를 들면 Operation implemetation 코드들 중 handline 을 보면 첫 번째와 두 번째 코드가 아래와 같이 혼용되어 있습니다. 이런 코드들은 말씀하신 것 처럼 두 번째 형태로 바꿀 필요가 있어서 본 이슈를 생성했습니다.
BTreeFindPositionOperationImple.java
@Override
public void handleLine(String line) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Got line %s", line);
}
BTreeGetBulkOperationImple.java
public void handleLine(String line) {
getLogger().debug("Got line %s", line);
그렇군요. ㅎㅎ 단순히 한가지 방식으로 통일한다는 뜻으로 오해했습니다 😞 위와 같은 부분을 가능한 전부 찾아내어 한번에 수정이 가능할까요? 아니면 발견되는 대로 수정해 나가는 방식으로 가야 할까요?
getLogger().debug 로 전체 검색을 해보면 대부분은 두 번째 형태로 코드 처리가 되어있습니다. 말씀 드린 몇 곳의 코드만 if 문 처리가 되어있지 않은 형태이고요. 그 부분만 찾아서 해결하면 괜찮을 것 같습니다.
현재 확인한 것으로는 static string 으로 log 를 출력하는 곳은 Flush Operation 뿐인 것 같습니다.
결론은 가능할 것 같습니다. 😅
본 이슈는 naver arcus-java-client debug log 출력 방식 일치 로 이동하고 close 합니다.
java client 전체적으로 debug log 를 출력할 때 아래와 같이 두 가지 방식을 혼용하고 있다. 한 가지 방식으로 통일한다.