나의 플랫폼/안드로이드
[Android] Android volley master library log disable
GsBOB
2016. 4. 14. 18:30
Android Volley Master Library 사용시, 안정적이고 참 좋은 라이브러리다!!
git : https://github.com/mcxiaoke/android-volley
하지만 웹서비스에 보내는 request 정보가 그대로 로그로 찍히게 되어,
서비스시 아주 큰 보안 이슈가 됩니다.
이래서, Log를 Disable 시키는 방법을 열심히 구글링 했지만
딸랑...
VolleyLog.DEBUG = false;
위와 같이 해도.. 로그는 계속 찍히고 이를 어찌할지 고민하다가 결국!!
라이브러리 소스를 직접 받아 수정하도록 하였습니다.
## 수정 방법
1. VolleyLog 클래스 변경
DEBUG flag 변수를 false로 할당
public static boolean DEBUG = false;
안전을 위해 setTag 함수에도 false 할당
public static void setTag(String tag) {
d("Changing log tag to %s", tag);
TAG = tag;
// Reinitialize the DEBUG "constant"
DEBUG = false;
}
2. BasicNetwork 클래스 변경
DEBUG || -> DEBUG && 로 변경
private void logSlowRequests(long requestLifetime, Request<?> request,
byte[] responseContents, StatusLine statusLine) {
if (DEBUG && requestLifetime > SLOW_REQUEST_THRESHOLD_MS) {
VolleyLog.d("HTTP response for request=<%s> [lifetime=%d], [size=%s], " +
"[rc=%d], [retryCount=%s]", request, requestLifetime,
responseContents != null ? responseContents.length : "null",
statusLine.getStatusCode(), request.getRetryPolicy().getCurrentRetryCount());
}
참고 : https://github.com/mcxiaoke/android-volley/issues/121
참고하세요.