Search in sources :

Example 1 with CustomLogger

use of com.birbit.android.jobqueue.log.CustomLogger in project android-priority-jobqueue by yigit.

the class TwitterApplication method configureJobManager.

private void configureJobManager() {
    Configuration.Builder builder = new Configuration.Builder(this).customLogger(new CustomLogger() {

        private static final String TAG = "JOBS";

        @Override
        public boolean isDebugEnabled() {
            return true;
        }

        @Override
        public void d(String text, Object... args) {
            Log.d(TAG, String.format(text, args));
        }

        @Override
        public void e(Throwable t, String text, Object... args) {
            Log.e(TAG, String.format(text, args), t);
        }

        @Override
        public void e(String text, Object... args) {
            Log.e(TAG, String.format(text, args));
        }

        @Override
        public void v(String text, Object... args) {
        }
    }).minConsumerCount(//always keep at least one consumer alive
    1).maxConsumerCount(//up to 3 consumers at a time
    3).loadFactor(//3 jobs per consumer
    3).consumerKeepAlive(//wait 2 minute
    120);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        builder.scheduler(FrameworkJobSchedulerService.createSchedulerFor(this, MyJobService.class), true);
    } else {
        int enableGcm = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this);
        if (enableGcm == ConnectionResult.SUCCESS) {
            builder.scheduler(GcmJobSchedulerService.createSchedulerFor(this, MyGcmJobService.class), true);
        }
    }
    jobManager = new JobManager(builder.build());
}
Also used : Configuration(com.birbit.android.jobqueue.config.Configuration) MyJobService(com.birbit.android.jobqueue.examples.twitter.services.MyJobService) CustomLogger(com.birbit.android.jobqueue.log.CustomLogger) JobManager(com.birbit.android.jobqueue.JobManager) MyGcmJobService(com.birbit.android.jobqueue.examples.twitter.services.MyGcmJobService)

Example 2 with CustomLogger

use of com.birbit.android.jobqueue.log.CustomLogger in project android-priority-jobqueue by yigit.

the class TestBase method enableDebug.

protected void enableDebug() {
    ShadowLog.stream = System.out;
    JqLog.setCustomLogger(new CustomLogger() {

        private String TAG = "test_logger";

        @Override
        public boolean isDebugEnabled() {
            return true;
        }

        @Override
        public void d(String text, Object... args) {
            Log.d(TAG, prefix() + String.format(text, args));
        }

        @Override
        public void e(Throwable t, String text, Object... args) {
            Log.e(TAG, prefix() + String.format(text, args), t);
        }

        @Override
        public void e(String text, Object... args) {
            Log.e(TAG, prefix() + String.format(text, args));
        }

        @Override
        public void v(String text, Object... args) {
            Log.v(TAG, prefix() + String.format(text, args));
        }

        private String prefix() {
            return Thread.currentThread().getName() + "[" + System.currentTimeMillis() + "]";
        }
    });
}
Also used : CustomLogger(com.birbit.android.jobqueue.log.CustomLogger)

Aggregations

CustomLogger (com.birbit.android.jobqueue.log.CustomLogger)2 JobManager (com.birbit.android.jobqueue.JobManager)1 Configuration (com.birbit.android.jobqueue.config.Configuration)1 MyGcmJobService (com.birbit.android.jobqueue.examples.twitter.services.MyGcmJobService)1 MyJobService (com.birbit.android.jobqueue.examples.twitter.services.MyJobService)1