Java Code Examples for com.orhanobut.logger.Logger#addLogAdapter()

The following examples show how to use com.orhanobut.logger.Logger#addLogAdapter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppLogger.java    From v9porn with MIT License 6 votes vote down vote up
public static void initLogger() {
    FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder()
            // (Optional) Whether to show thread info or not. Default true
            .showThreadInfo(false)
            // (Optional) How many method line to show. Default 2
            .methodCount(0)
            // (Optional) Hides internal method calls up to offset. Default 5
            .methodOffset(5)
            // .logStrategy(customLog) // (Optional) Changes the log strategy to print out. Default LogCat
            // .tag("My custom tag")   // (Optional) Global tag for every log. Default PRETTY_LOGGER
            .build();

    Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy) {
        @Override
        public boolean isLoggable(int priority, String tag) {
            return BuildConfig.DEBUG;
        }
    });
}
 
Example 2
Source File: AppLogger.java    From v9porn with MIT License 6 votes vote down vote up
public static void initLogger() {
    FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder()
            // (Optional) Whether to show thread info or not. Default true
            .showThreadInfo(false)
            // (Optional) How many method line to show. Default 2
            .methodCount(0)
            // (Optional) Hides internal method calls up to offset. Default 5
            .methodOffset(5)
            // .logStrategy(customLog) // (Optional) Changes the log strategy to print out. Default LogCat
            // .tag("My custom tag")   // (Optional) Global tag for every log. Default PRETTY_LOGGER
            .build();

    Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy) {
        @Override
        public boolean isLoggable(int priority, String tag) {
            return BuildConfig.DEBUG;
        }
    });
}
 
Example 3
Source File: App.java    From V2EX with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    app = this;
    mSecretConfig = new SecretImpl();
    mSecretConfig.init(this);

    Config.init(this);
    setTheme(getResources().getIdentifier(Config.getConfig(ConfigRefEnum.CONFIG_THEME),
            "style", getPackageName()));
    Logger.addLogAdapter(new AndroidLogAdapter());
    RetrofitManager.init(this);
    Utils.init(this);

    registerActivityLifecycleCallbacks(this);
    setFontScaleAndUiScale();
}
 
Example 4
Source File: MyApplication.java    From Mobike with Apache License 2.0 6 votes vote down vote up
private void initMyApplication() {
    //tencent bugly
    CrashReport.initCrashReport(getApplicationContext(), "e1a62089c6", false);
    //Fresco
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
            .build();
    Fresco.initialize(this, config);
    //baidu map sdk
    SDKInitializer.initialize(this);
    //Bmob
    Bmob.initialize(this, "b0cb494256d9b86fc931ca930a055b75");
    //Logger
    Logger.addLogAdapter(new AndroidLogAdapter(){
        @Override
        public boolean isLoggable(int priority, String tag) {
            return true;// TODO: 2017/6/5
        }
    });
    //locail use data
    initUser();
}
 
Example 5
Source File: MyApplication.java    From Mp3Cutter with GNU General Public License v3.0 6 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        instances = this;
        mAppComponent = DaggerAppComponent
                .builder()
                .appModule(new AppModule(this))
                .build();
        initDatabase();
//        CoverLoader.getInstance().init(instances);
        //logger
        if(LogUtils.isApkDebugable(this)) {
            Logger.addLogAdapter(new AndroidLogAdapter());
        }
        //umeng analytics
        MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);
        SkinCompatManager.withoutActivity(this)                         // 基础控件换肤初始化
                .addInflater(new SkinMaterialViewInflater())            // material design 控件换肤初始化[可选]
                .setSkinStatusBarColorEnable(false)                     // 关闭状态栏换肤,默认打开[可选]
                .setSkinWindowBackgroundEnable(false)                   // 关闭windowBackground换肤,默认打开[可选]
                .loadSkin();
    }
 
Example 6
Source File: EaserApplication.java    From Easer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    Logger.addLogAdapter(new AndroidLogAdapter());

    if (SettingsUtils.logging(this)) {
        if (ContextCompat.checkSelfPermission(getApplicationContext(),
                Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
            Logger.addLogAdapter(new DiskLogAdapter());
        } else {
            PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit()
                    .putBoolean(getString(R.string.key_pref_logging), false)
                    .apply();
        }
    }

    startService(new Intent(this, ActivityLogService.class));

    Logger.log(Logger.ASSERT, null, "======Easer started======", null);
}
 
Example 7
Source File: Configurator.java    From HHComicViewer with Apache License 2.0 6 votes vote down vote up
public final void configure() {
    //初始化OkHttpClient
    if (HH_CONFIGS.get(ConfigKeys.OKHTTP_CLIENT) == null) {
        //添加interceptor
        for (Interceptor interceptor : INTERCEPTORS) {
            BUILDER.addInterceptor(interceptor);
        }
        HH_CONFIGS.put(ConfigKeys.OKHTTP_CLIENT, BUILDER.build());
    }
    //初始化Utils库
    Utils.init((Application) HHEngine.getApplicationContext());
    //初始化icon库
    initIcons();
    //初始化logger库
    Logger.addLogAdapter(new AndroidLogAdapter());
    HH_CONFIGS.put(ConfigKeys.CONFIG_READY, true);
}
 
Example 8
Source File: App.java    From landlord_client with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Logger.addLogAdapter(new AndroidLogAdapter() {
        @Override
        public boolean isLoggable(int priority, @Nullable String tag) {
            return priority != Logger.DEBUG;
        }
    });
    app = this;
    connectLogin();
}
 
Example 9
Source File: WanAndroidApp.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
private void initLogger() {
    //DEBUG版本才打控制台log
    if (BuildConfig.DEBUG) {
        Logger.addLogAdapter(new AndroidLogAdapter(PrettyFormatStrategy.newBuilder().
                tag(getString(R.string.app_name)).build()));
    }
    //把log存到本地
    Logger.addLogAdapter(new DiskLogAdapter(TxtFormatStrategy.newBuilder().
            tag(getString(R.string.app_name)).build(getPackageName(), getString(R.string.app_name))));
}
 
Example 10
Source File: InitWalletTest.java    From dapp-wallet-demo with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    PrettyFormatStrategy strategy = PrettyFormatStrategy.newBuilder()
            .showThreadInfo(true)  // (Optional) Whether to show thread info or not. Default true
            .methodCount(0)         // (Optional) How many method line to show. Default 2
            .methodCount(2)
            .tag("halcyon")
            .build();
    Logger.addLogAdapter(new AndroidLogAdapter(strategy));
}
 
Example 11
Source File: BaseApplication.java    From Sunshine with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    BaseApplication.context = getApplicationContext();

    //根据打包类型判断是否打印日志
    Logger.addLogAdapter(new AndroidLogAdapter() {
        @Override
        public boolean isLoggable(int priority, String tag) {
            return BuildConfig.DEBUG_MODE;
        }
    });

}
 
Example 12
Source File: SampleApplication.java    From iroha-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    instance = this;
    applicationComponent = DaggerApplicationComponent.builder().build();
    Logger.addLogAdapter(new AndroidLogAdapter());
}
 
Example 13
Source File: CommonApplication.java    From iMoney with Apache License 2.0 4 votes vote down vote up
/**
 * init logger adapter.
 */
private static void initLogger() {
    Logger.addLogAdapter(new AndroidLogAdapter());
}
 
Example 14
Source File: App.java    From android-open-framework-analysis with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Logger.addLogAdapter(new AndroidLogAdapter());
}