반응형
android.util에 속한 Log클래스다.
public final class Log {
public static final int ASSERT = 7;
public static final int DEBUG = 3;
public static final int ERROR = 6;
public static final int INFO = 4;
public static final int VERBOSE = 2;
public static final int WARN = 5;
}
멤버를 보면 로그의 종류를 알 수 있다.
Log.d("태그이름", "로그메시지");
Log.i("태그이름", "로그메시지");
위와 같이 사용하는데 print문으로 할 수 있는 걸 이름을 붙여서 사용한다고 생각하면 되겠다.
d의경우 debug모드에서 볼 수 있고 i의 경우 info에서 볼 수 있다.
Logcat에서 모드를 지정해 로그를 따로 따로 볼 수 있다.
Log.i: Use this to post useful information to the log. For example: that you have successfully connected to a server. Basically use it to report successes.
Log.d: Use this for debugging purposes. If you want to print out a bunch of messages so you can log the exact flow of your program, use this. If you want to keep a log of variable values, use this.
엄청나게 용도의 차이가 난다기 보다는 로그창에서 나타나는 색깔이 다르다보니 배포할 앱을 만들때는 구분해서 사용하는 게 좋을 것 같다.
추가로 Log.wtf()이라는 로그도 있다. What the Fxxk의 그거 맞다.
일어나서는 안되는 일이 일어날 때 이 로그를 찍는다. 절대 일어나면 안되는 최악의 경우로 지정해두고 wtf 모드로 검색해서 사용한다.
나는 Log.d()가 손에 익어서 혼자 개발할 때는 이것만 사용할 것 같다.
"댓글, 공감 버튼 한 번씩 누르고 가주시면 큰 힘이 됩니다"
반응형