com.orhanobut.logger.DiskLogAdapter Java Examples

The following examples show how to use com.orhanobut.logger.DiskLogAdapter. 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: 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 #2
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))));
}