Skip to content

Commit c29ea6d

Browse files
authored
[MOBILE-3631] Update logger interface (#1269)
* [MOBILE-3631] Update logger interface * Fix
1 parent 790e4c8 commit c29ea6d

File tree

197 files changed

+1002
-1053
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+1002
-1053
lines changed

sample/src/main/java/com/urbanairship/sample/SampleLiveUpdate.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import android.app.PendingIntent;
44
import android.content.Context;
55
import android.content.Intent;
6+
import android.util.Log;
67
import android.widget.RemoteViews;
78

8-
import com.urbanairship.Logger;
99
import com.urbanairship.json.JsonMap;
1010
import com.urbanairship.liveupdate.LiveUpdate;
1111
import com.urbanairship.liveupdate.LiveUpdateEvent;
@@ -24,7 +24,7 @@ public class SampleLiveUpdate implements LiveUpdateNotificationHandler {
2424
@NotNull
2525
public LiveUpdateResult<NotificationCompat.Builder> onUpdate(@NonNull Context context, @NonNull LiveUpdateEvent event, @NonNull LiveUpdate update) {
2626

27-
Logger.debug("SampleLiveUpdate - onUpdate: action=" + event + ", update=" + update);
27+
Log.d("SampleLiveUpdate", "onUpdate: action=" + event + ", update=" + update);
2828

2929
if (event == LiveUpdateEvent.END) {
3030
// Dismiss the live update on END. The default behavior will leave the Live Update

urbanairship-adm/src/main/java/com/urbanairship/push/adm/AdmHandlerBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import com.amazon.device.messaging.ADMMessageHandlerBase;
88
import com.urbanairship.Autopilot;
9-
import com.urbanairship.Logger;
9+
import com.urbanairship.UALog;
1010
import com.urbanairship.push.PushMessage;
1111
import com.urbanairship.push.PushProviderBridge;
1212

@@ -29,7 +29,7 @@ protected void onMessage(Intent intent) {
2929

3030
@Override
3131
protected void onRegistrationError(String errorId) {
32-
Logger.error("An error occured during ADM Registration : " + errorId);
32+
UALog.e("An error occured during ADM Registration : " + errorId);
3333
}
3434

3535
@Override

urbanairship-adm/src/main/java/com/urbanairship/push/adm/AdmHandlerJobBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import com.amazon.device.messaging.ADMMessageHandlerJobBase;
99
import com.urbanairship.Autopilot;
10-
import com.urbanairship.Logger;
10+
import com.urbanairship.UALog;
1111
import com.urbanairship.push.PushMessage;
1212
import com.urbanairship.push.PushProviderBridge;
1313

@@ -22,7 +22,7 @@ protected void onMessage(Context context, Intent intent) {
2222

2323
@Override
2424
protected void onRegistrationError(Context context, String errorId) {
25-
Logger.error("An error occured during ADM Registration : " + errorId);
25+
UALog.e("An error occured during ADM Registration : " + errorId);
2626
}
2727

2828
@Override

urbanairship-adm/src/main/java/com/urbanairship/push/adm/AdmPushProvider.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import com.amazon.device.messaging.ADMConstants;
1414
import com.urbanairship.AirshipVersionInfo;
15-
import com.urbanairship.Logger;
15+
import com.urbanairship.UALog;
1616
import com.urbanairship.UAirship;
1717
import com.urbanairship.push.PushProvider;
1818

@@ -125,7 +125,7 @@ private static class RegistrationReceiver extends BroadcastReceiver {
125125
public void onReceive(Context context, Intent intent) {
126126
if (intent != null && intent.getExtras() != null && ADMConstants.LowLevel.ACTION_APP_REGISTRATION_EVENT.equals(intent.getAction())) {
127127
if (intent.getExtras().containsKey(ADMConstants.LowLevel.EXTRA_ERROR)) {
128-
Logger.error("ADM error occurred: %s", intent.getExtras().getString(ADMConstants.LowLevel.EXTRA_ERROR));
128+
UALog.e("ADM error occurred: %s", intent.getExtras().getString(ADMConstants.LowLevel.EXTRA_ERROR));
129129
this.error = intent.getExtras().getString(ADMConstants.LowLevel.EXTRA_ERROR);
130130
} else {
131131
this.registrationToken = intent.getStringExtra(ADMConstants.LowLevel.EXTRA_REGISTRATION_ID);

urbanairship-adm/src/main/java/com/urbanairship/push/adm/AdmPushReceiver.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
package com.urbanairship.push.adm;
44

55
import com.amazon.device.messaging.ADMMessageReceiver;
6-
import com.urbanairship.Logger;
6+
import com.urbanairship.UALog;
77
import androidx.annotation.RestrictTo;
88

99
/**
@@ -21,7 +21,7 @@ public AdmPushReceiver() {
2121
Class.forName("com.amazon.device.messaging.ADMMessageHandlerJobBase");
2222
registerJobServiceClass(AdmHandlerJobBase.class, 3004);
2323
} catch (ClassNotFoundException e) {
24-
Logger.warn("Using legacy ADM class : " + e.getMessage());
24+
UALog.w("Using legacy ADM class : " + e.getMessage());
2525
}
2626
}
2727
}

urbanairship-adm/src/main/java/com/urbanairship/push/adm/AdmWrapper.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import android.content.Context;
66

77
import com.amazon.device.messaging.ADM;
8-
import com.urbanairship.Logger;
8+
import com.urbanairship.UALog;
99
import com.urbanairship.UAirship;
1010

1111
import androidx.annotation.NonNull;
@@ -25,7 +25,7 @@ static boolean isSupported() {
2525
try {
2626
return new ADM(UAirship.getApplicationContext()).isSupported();
2727
} catch (RuntimeException ex) {
28-
Logger.warn("Failed to call ADM. Make sure ADM jar is not bundled with the APK.");
28+
UALog.w("Failed to call ADM. Make sure ADM jar is not bundled with the APK.");
2929
return false;
3030
}
3131
}

urbanairship-ads-identifier/src/main/java/com/urbanairship/aaid/AdvertisingIdTracker.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.google.android.gms.common.GooglePlayServicesRepairableException;
1111
import com.urbanairship.AirshipComponent;
1212
import com.urbanairship.AirshipExecutors;
13-
import com.urbanairship.Logger;
13+
import com.urbanairship.UALog;
1414
import com.urbanairship.PreferenceDataStore;
1515
import com.urbanairship.PrivacyManager;
1616
import com.urbanairship.UAirship;
@@ -118,7 +118,7 @@ public void setEnabled(boolean isEnabled) {
118118
getDataStore().put(ENABLED_KEY, isEnabled);
119119

120120
if (!privacyManager.isEnabled(PrivacyManager.FEATURE_ANALYTICS)) {
121-
Logger.warn("AdvertisingIdTracker - Unable to track advertising ID when analytics is disabled.");
121+
UALog.w("AdvertisingIdTracker - Unable to track advertising ID when analytics is disabled.");
122122
return;
123123
}
124124

@@ -168,7 +168,7 @@ public void run() {
168168
advertisingId = adInfo.getId();
169169
limitedAdTrackingEnabled = adInfo.isLimitAdTrackingEnabled();
170170
} catch (IOException | GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) {
171-
Logger.error(e, "AdvertisingIdTracker - Failed to retrieve and update advertising ID.");
171+
UALog.e(e, "AdvertisingIdTracker - Failed to retrieve and update advertising ID.");
172172
return;
173173
}
174174

urbanairship-automation/src/main/java/com/urbanairship/automation/AudienceChecks.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import android.content.Context;
66

7-
import com.urbanairship.Logger;
7+
import com.urbanairship.UALog;
88
import com.urbanairship.PrivacyManager;
99
import com.urbanairship.UAirship;
1010
import com.urbanairship.channel.AirshipChannel;
@@ -166,7 +166,7 @@ private static Set<String> sanitizeLanguageTags(List<String> languageTags) {
166166
// Remove trailing dashes and underscores
167167
if (!UAStringUtil.isEmpty(languageTag)) {
168168
if (languageTag.endsWith("_") || languageTag.endsWith("-")) {
169-
Logger.debug("Sanitizing malformed language tag: " + languageTag);
169+
UALog.d("Sanitizing malformed language tag: " + languageTag);
170170
sanitizedLanguageTags.add(languageTag.substring(0, languageTag.length() - 1));
171171
} else {
172172
sanitizedLanguageTags.add(languageTag);
@@ -222,7 +222,7 @@ private static boolean isLocaleConditionMet(@NonNull Context context, @NonNull A
222222
return true;
223223
}
224224
} catch (Exception e) {
225-
Logger.error("Unable to construct locale list: ", e);
225+
UALog.e("Unable to construct locale list: ", e);
226226
}
227227

228228
return false;
@@ -262,9 +262,9 @@ private static JsonMap createPermissionsMap(@NonNull PermissionsManager permissi
262262
builder.putOpt(permission.getValue(), status.getValue());
263263
}
264264
} catch (ExecutionException e) {
265-
Logger.error(e, "Failed to get permissions status: %s", permission);
265+
UALog.e(e, "Failed to get permissions status: %s", permission);
266266
} catch (InterruptedException e) {
267-
Logger.error(e, "Failed to get permissions status: %s", permission);
267+
UALog.e(e, "Failed to get permissions status: %s", permission);
268268
Thread.currentThread().interrupt();
269269
}
270270
}

urbanairship-automation/src/main/java/com/urbanairship/automation/AutomationEngine.java

+24-25
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import androidx.core.util.Consumer;
1919

2020
import com.urbanairship.CancelableOperation;
21-
import com.urbanairship.Logger;
21+
import com.urbanairship.UALog;
2222
import com.urbanairship.PendingResult;
2323
import com.urbanairship.Predicate;
2424
import com.urbanairship.PreferenceDataStore;
@@ -52,7 +52,6 @@
5252
import com.urbanairship.reactive.Subscriber;
5353
import com.urbanairship.reactive.Subscription;
5454
import com.urbanairship.util.AirshipHandlerThread;
55-
import com.urbanairship.util.Network;
5655

5756
import java.math.BigDecimal;
5857
import java.util.ArrayList;
@@ -358,7 +357,7 @@ public void run() {
358357
cleanSchedules();
359358

360359
if (dao.getScheduleCount() >= SCHEDULE_LIMIT) {
361-
Logger.error("AutomationEngine - Unable to insert schedule due to schedule exceeded limit.");
360+
UALog.e("AutomationEngine - Unable to insert schedule due to schedule exceeded limit.");
362361
pendingResult.setResult(false);
363362
return;
364363
}
@@ -369,7 +368,7 @@ public void run() {
369368

370369
notifyNewSchedule(Collections.<Schedule<? extends ScheduleData>>singletonList(schedule));
371370

372-
Logger.verbose("Scheduled entries: %s", schedule);
371+
UALog.v("Scheduled entries: %s", schedule);
373372
pendingResult.setResult(true);
374373
}
375374
});
@@ -393,7 +392,7 @@ public void run() {
393392
cleanSchedules();
394393

395394
if (dao.getScheduleCount() + schedules.size() > SCHEDULE_LIMIT) {
396-
Logger.error("AutomationDataManager - Unable to insert schedule due to schedule exceeded limit.");
395+
UALog.e("AutomationDataManager - Unable to insert schedule due to schedule exceeded limit.");
397396
pendingResult.setResult(false);
398397
return;
399398
}
@@ -410,7 +409,7 @@ public void run() {
410409
Collection<Schedule<? extends ScheduleData>> result = convertSchedulesUnknownTypes(entries);
411410
notifyNewSchedule(result);
412411

413-
Logger.verbose("Scheduled entries: %s", result);
412+
UALog.v("Scheduled entries: %s", result);
414413
pendingResult.setResult(true);
415414
}
416415
});
@@ -437,7 +436,7 @@ public void run() {
437436
return;
438437
}
439438

440-
Logger.verbose("Cancelled schedules: %s", ids);
439+
UALog.v("Cancelled schedules: %s", ids);
441440

442441
dao.deleteSchedules(entries);
443442
notifyCancelledSchedule(entries);
@@ -467,7 +466,7 @@ public void run() {
467466
ids.add(entry.schedule.scheduleId);
468467
}
469468

470-
Logger.verbose("Cancelled schedules: %s", ids);
469+
UALog.v("Cancelled schedules: %s", ids);
471470
dao.deleteSchedules(entries);
472471
notifyCancelledSchedule(entries);
473472
cancelScheduleAlarms(ids);
@@ -494,7 +493,7 @@ public void run() {
494493
List<FullSchedule> entries = dao.getSchedulesWithGroup(group);
495494

496495
if (entries.isEmpty()) {
497-
Logger.verbose("Failed to cancel schedule group: %s", group);
496+
UALog.v("Failed to cancel schedule group: %s", group);
498497
pendingResult.setResult(false);
499498
} else {
500499
dao.deleteSchedules(entries);
@@ -635,7 +634,7 @@ public void run() {
635634
FullSchedule entry = dao.getSchedule(scheduleId);
636635

637636
if (entry == null) {
638-
Logger.error("AutomationEngine - Schedule no longer exists. Unable to edit: %s", scheduleId);
637+
UALog.e("AutomationEngine - Schedule no longer exists. Unable to edit: %s", scheduleId);
639638
pendingResult.setResult(false);
640639
return;
641640
}
@@ -669,7 +668,7 @@ public void run() {
669668
subscribeStateObservables(entry, stateChangeTimeStamp);
670669
}
671670

672-
Logger.verbose("Updated schedule: %s", scheduleId);
671+
UALog.v("Updated schedule: %s", scheduleId);
673672
pendingResult.setResult(true);
674673
}
675674
});
@@ -921,7 +920,7 @@ private void resetWaitingSchedules() {
921920
}
922921

923922
dao.updateSchedules(entries);
924-
Logger.verbose("AutomationEngine: Schedules reset state to STATE_PREPARING_SCHEDULE: %s", entries);
923+
UALog.v("AutomationEngine: Schedules reset state to STATE_PREPARING_SCHEDULE: %s", entries);
925924
}
926925

927926
/**
@@ -955,7 +954,7 @@ private void cleanSchedules() {
955954
}
956955

957956
if (!schedulesToDelete.isEmpty()) {
958-
Logger.verbose("Deleting finished schedules: %s", schedulesToDelete);
957+
UALog.v("Deleting finished schedules: %s", schedulesToDelete);
959958
dao.deleteSchedules(schedulesToDelete);
960959
}
961960
}
@@ -1073,7 +1072,7 @@ private void onEventAdded(@NonNull final JsonSerializable json, final int type,
10731072
backgroundHandler.post(new Runnable() {
10741073
@Override
10751074
public void run() {
1076-
Logger.debug("Updating triggers with type: %s", type);
1075+
UALog.d("Updating triggers with type: %s", type);
10771076
List<TriggerEntity> triggerEntities = dao.getActiveTriggers(type);
10781077
if (triggerEntities.isEmpty()) {
10791078
return;
@@ -1294,9 +1293,9 @@ private <T extends ScheduleData> Schedule<T> convert(@Nullable FullSchedule entr
12941293
try {
12951294
return ScheduleConverters.convert(entry);
12961295
} catch (ClassCastException e) {
1297-
Logger.error(e, "Exception converting entity to schedule %s", entry.schedule.scheduleId);
1296+
UALog.e(e, "Exception converting entity to schedule %s", entry.schedule.scheduleId);
12981297
} catch (Exception e) {
1299-
Logger.error(e, "Exception converting entity to schedule %s. Cancelling.", entry.schedule.scheduleId);
1298+
UALog.e(e, "Exception converting entity to schedule %s. Cancelling.", entry.schedule.scheduleId);
13001299
cancel(Collections.singleton(entry.schedule.scheduleId));
13011300
}
13021301
return null;
@@ -1334,7 +1333,7 @@ private <T extends ScheduleData> Collection<Schedule<T>> convertSchedules(@NonNu
13341333
@WorkerThread
13351334
private void attemptExecution(@NonNull final FullSchedule entry) {
13361335
if (entry.schedule.executionState != ScheduleState.WAITING_SCHEDULE_CONDITIONS) {
1337-
Logger.error("Unable to execute schedule when state is %s scheduleID: %s", entry.schedule.executionState, entry.schedule.scheduleId);
1336+
UALog.e("Unable to execute schedule when state is %s scheduleID: %s", entry.schedule.executionState, entry.schedule.scheduleId);
13381337
return;
13391338
}
13401339

@@ -1360,7 +1359,7 @@ public void run() {
13601359
schedule = ScheduleConverters.convert(entry);
13611360
result = driver.onCheckExecutionReadiness(schedule);
13621361
} catch (Exception e) {
1363-
Logger.error(e, "Unable to create schedule.");
1362+
UALog.e(e, "Unable to create schedule.");
13641363
this.exception = e;
13651364
}
13661365
}
@@ -1377,36 +1376,36 @@ public void run() {
13771376
try {
13781377
latch.await();
13791378
} catch (InterruptedException ex) {
1380-
Logger.error(ex, "Failed to execute schedule. ");
1379+
UALog.e(ex, "Failed to execute schedule. ");
13811380
Thread.currentThread().interrupt();
13821381
}
13831382

13841383
if (runnable.exception != null) {
1385-
Logger.error("Failed to check conditions. Deleting schedule: %s", entry.schedule.scheduleId);
1384+
UALog.e("Failed to check conditions. Deleting schedule: %s", entry.schedule.scheduleId);
13861385
dao.delete(entry);
13871386
notifyCancelledSchedule(Collections.singleton(entry));
13881387
} else {
13891388
int result = runnable.result == null ? AutomationDriver.READY_RESULT_NOT_READY : runnable.result;
13901389
switch (result) {
13911390
case AutomationDriver.READY_RESULT_INVALIDATE:
1392-
Logger.verbose("Schedule invalidated: %s", entry.schedule.scheduleId);
1391+
UALog.v("Schedule invalidated: %s", entry.schedule.scheduleId);
13931392
updateExecutionState(entry, ScheduleState.PREPARING_SCHEDULE);
13941393
dao.update(entry);
13951394
prepareSchedules(Collections.singletonList(dao.getSchedule(entry.schedule.scheduleId)));
13961395
break;
13971396

13981397
case AutomationDriver.READY_RESULT_CONTINUE:
1399-
Logger.verbose("Schedule executing: %s", entry.schedule.scheduleId);
1398+
UALog.v("Schedule executing: %s", entry.schedule.scheduleId);
14001399
updateExecutionState(entry, ScheduleState.EXECUTING);
14011400
dao.update(entry);
14021401
break;
14031402

14041403
case AutomationDriver.READY_RESULT_NOT_READY:
1405-
Logger.verbose("Schedule not ready for execution: %s", entry.schedule.scheduleId);
1404+
UALog.v("Schedule not ready for execution: %s", entry.schedule.scheduleId);
14061405
break;
14071406

14081407
case AutomationDriver.READY_RESULT_SKIP:
1409-
Logger.verbose("Schedule execution skipped: %s", entry.schedule.scheduleId);
1408+
UALog.v("Schedule execution skipped: %s", entry.schedule.scheduleId);
14101409
updateExecutionState(entry, ScheduleState.IDLE);
14111410
dao.update(entry);
14121411
break;
@@ -1518,7 +1517,7 @@ private void onScheduleFinishedExecuting(@Nullable final FullSchedule entry) {
15181517
return;
15191518
}
15201519

1521-
Logger.verbose("Schedule finished: %s", entry.schedule.scheduleId);
1520+
UALog.v("Schedule finished: %s", entry.schedule.scheduleId);
15221521

15231522
entry.schedule.count++;
15241523
boolean isOverLimit = isOverLimit(entry);

0 commit comments

Comments
 (0)