728x90
PrettyFormatStrategy : λμνλ thread, callstack, messageκ° μμκ² λμ¬ μ μλ€.
1) app gradle.build
dependencies {
implementation 'com.orhanobut:logger:2.2.0'
2) importλ Ctrl + Space ν΄μ μ‘μ μ€λ λλ€.
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import com.orhanobut.logger.PrettyFormatStrategy;
3) MainActivity > super.onCreate()
// Logger Stack Trace Count.
PrettyFormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder().methodCount(5).build();
// Remove Log Message When Release.
Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy){
@Override
public boolean isLoggable(int priority, @Nullable String tag) {
//return BuildConfig.DEBUG;
return true;
}
});
Logger.t("tag").d("onCreate"); // νκ·Έ, λλ²κΉ
ν λ΄μ©
Logger.d("onCreate"); // λλ²κΉ
ν λ΄μ©
4) MainActivicy > onDestroy()
Logger.clearLogAdapters();
5) λ‘κ·Έλ₯Ό μ°μ ν¨μ μ
Logger.d(“μ°κ³ μΆμ λ‘κ·Έ λ΄μ©”);
κ²°κ³Ό λ‘κ·Έ ) LogCat μ μλμ κ°μ΄ κΉλνκ² μ°νλ€.
ν μ€νΈν μ 체 μ½λ)
package com.devshin93.myapplication;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import com.orhanobut.logger.PrettyFormatStrategy;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Logger Stack Trace Count.
PrettyFormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder().methodCount(5).build();
// Remove Log Message When Release.
Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy){
@Override
public boolean isLoggable(int priority, @Nullable String tag) {
//return BuildConfig.DEBUG;
return true;
}
});
Logger.t("Tag").d("λ΄μ©");
Logger.d("onCreate");
prettyTestFunc(); // ν
μ€νΈ ν¨μ νΈμΆ
}
@Override
protected void onDestroy() {
Logger.clearLogAdapters(); // λ‘κ·Έ λ΄μ©μ μ§μ΄λ€
super.onDestroy();
}
/**
* prettyFormatStrategy ν
μ€νΈ ν¨μ
*/
public void prettyTestFunc() {
Logger.d("prettyTestFunc!!");
}
}
'π κ°λ° > μλλ‘μ΄λ' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[μλλ‘μ΄λ] net::ERR_CACHE_MISS (0) | 2021.05.02 |
---|---|
[μλλ‘μ΄λ] μΉλ·° λλ²κΉ μ½κ² νλ λ°©λ² - Chrome inspect μ¬μ©λ² (2) (0) | 2021.05.02 |
[μλλ‘μ΄λ] SDK, JDK, NDK (0) | 2021.04.15 |
[μλλ‘μ΄λ] Switch λ²νΌ μ¬μ©λ² (0) | 2021.03.22 |
[μλλ‘μ΄λ - μλ¬] Installation did not succeed.The application could not be installed (0) | 2021.03.22 |
λκΈ