1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-26 01:28:50 -05:00

Log message cleanup

This commit is contained in:
Jesse Vincent 2010-01-03 01:50:32 +00:00
parent f9e8c877ff
commit 875dc31d5a
6 changed files with 72 additions and 60 deletions

View File

@ -916,10 +916,10 @@ public class MessagingController implements Runnable
if (Account.EXPUNGE_ON_POLL.equals(account.getExpungePolicy()))
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "SYNC: Expunging folder " + account.getDescription() + ":" + folder);
}
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "SYNC: Expunging folder " + account.getDescription() + ":" + folder);
}
remoteFolder.expunge();
}

View File

@ -54,7 +54,8 @@ public class BootReceiver extends BroadcastReceiver
}
else
{
Log.w(K9.LOG_TAG, "BootReceiver WakeLock " + wakeLockId + " doesn't exist");
if (K9.DEBUG)
Log.w(K9.LOG_TAG, "BootReceiver WakeLock " + wakeLockId + " doesn't exist");
}
}
}
@ -64,7 +65,8 @@ public class BootReceiver extends BroadcastReceiver
Integer tmpWakeLockId = getWakeLock(context);
try
{
Log.i(K9.LOG_TAG, "BootReceiver.onReceive" + intent);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "BootReceiver.onReceive" + intent);
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()))
{
@ -97,7 +99,8 @@ public class BootReceiver extends BroadcastReceiver
Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT);
String alarmedAction = alarmedIntent.getAction();
Log.i(K9.LOG_TAG, "BootReceiver Got alarm to fire alarmedIntent " + alarmedAction);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "BootReceiver Got alarm to fire alarmedIntent " + alarmedAction);
alarmedIntent.putExtra(WAKE_LOCK_ID, tmpWakeLockId);
tmpWakeLockId = null;
if (alarmedIntent != null)
@ -109,7 +112,8 @@ public class BootReceiver extends BroadcastReceiver
{
long atTime = intent.getLongExtra(AT_TIME, -1);
Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT);
Log.i(K9.LOG_TAG,"BootReceiver Scheduling intent " + alarmedIntent + " for " + new Date(atTime));
if (K9.DEBUG)
Log.i(K9.LOG_TAG,"BootReceiver Scheduling intent " + alarmedIntent + " for " + new Date(atTime));
PendingIntent pi = buildPendingIntent(context, intent);
AlarmManager alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
@ -119,7 +123,8 @@ public class BootReceiver extends BroadcastReceiver
else if (CANCEL_INTENT.equals(intent.getAction()))
{
Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT);
Log.i(K9.LOG_TAG, "BootReceiver Canceling alarmedIntent " + alarmedIntent);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "BootReceiver Canceling alarmedIntent " + alarmedIntent);
PendingIntent pi = buildPendingIntent(context, intent);
@ -131,7 +136,8 @@ public class BootReceiver extends BroadcastReceiver
Integer wakeLockId = intent.getIntExtra(WAKE_LOCK_ID, -1);
if (wakeLockId != -1)
{
Log.i(K9.LOG_TAG, "BootReceiver Release wakeLock " + wakeLockId);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "BootReceiver Release wakeLock " + wakeLockId);
releaseWakeLock(wakeLockId);
}
}
@ -158,7 +164,8 @@ public class BootReceiver extends BroadcastReceiver
public static void scheduleIntent(Context context, long atTime, Intent alarmedIntent)
{
Log.i(K9.LOG_TAG, "BootReceiver Got request to schedule alarmedIntent " + alarmedIntent.getAction());
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "BootReceiver Got request to schedule alarmedIntent " + alarmedIntent.getAction());
Intent i = new Intent();
i.setClass(context, BootReceiver.class);
i.setAction(SCHEDULE_INTENT);
@ -169,7 +176,8 @@ public class BootReceiver extends BroadcastReceiver
public static void cancelIntent(Context context, Intent alarmedIntent)
{
Log.i(K9.LOG_TAG, "BootReceiver Got request to cancel alarmedIntent " + alarmedIntent.getAction());
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "BootReceiver Got request to cancel alarmedIntent " + alarmedIntent.getAction());
Intent i = new Intent();
i.setClass(context, BootReceiver.class);
i.setAction(CANCEL_INTENT);
@ -179,7 +187,8 @@ public class BootReceiver extends BroadcastReceiver
public static void releaseWakeLock(Context context, int wakeLockId)
{
Log.i(K9.LOG_TAG, "BootReceiver Got request to release wakeLock " + wakeLockId);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "BootReceiver Got request to release wakeLock " + wakeLockId);
Intent i = new Intent();
i.setClass(context, BootReceiver.class);
i.setAction(WAKE_LOCK_RELEASE);

View File

@ -49,7 +49,8 @@ public abstract class CoreService extends Service
wakeLock.setReferenceCounted(false);
wakeLock.acquire(K9.MAIL_SERVICE_WAKE_LOCK_TIMEOUT);
Log.i(K9.LOG_TAG, "CoreService: " + this.getClass().getName() + ".onStart(" + intent + ", " + startId);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "CoreService: " + this.getClass().getName() + ".onStart(" + intent + ", " + startId);
int wakeLockId = intent.getIntExtra(BootReceiver.WAKE_LOCK_ID, -1);
if (wakeLockId != -1)
@ -60,16 +61,12 @@ public abstract class CoreService extends Service
if (coreWakeLockId != null && coreWakeLockId != -1)
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "Got core wake lock id " + coreWakeLockId);
}
WakeLock coreWakeLock = wakeLocks.remove(coreWakeLockId);
if (coreWakeLock != null)
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "Found core wake lock with id " + coreWakeLockId + ", releasing");
}
coreWakeLock.release();
}
}
@ -102,7 +99,8 @@ public abstract class CoreService extends Service
@Override
public void onDestroy()
{
Log.i(K9.LOG_TAG, "CoreService: " + this.getClass().getName() + ".onDestroy()");
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "CoreService: " + this.getClass().getName() + ".onDestroy()");
super.onDestroy();
// MessagingController.getInstance(getApplication()).removeListener(mListener);
}

View File

@ -90,7 +90,8 @@ public class MailService extends CoreService
public void onCreate()
{
super.onCreate();
Log.v(K9.LOG_TAG, "***** MailService *****: onCreate");
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "***** MailService *****: onCreate");
}
@Override
@ -121,13 +122,15 @@ public class MailService extends CoreService
}
setForeground(true); // if it gets killed once, it'll never restart
Log.i(K9.LOG_TAG, "MailService.onStart(" + intent + ", " + startId
+ "), hasConnectivity = " + hasConnectivity + ", doBackground = " + doBackground);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "MailService.onStart(" + intent + ", " + startId
+ "), hasConnectivity = " + hasConnectivity + ", doBackground = " + doBackground);
// MessagingController.getInstance(getApplication()).addListener(mListener);
if (ACTION_CHECK_MAIL.equals(intent.getAction()))
{
Log.i(K9.LOG_TAG, "***** MailService *****: checking mail");
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "***** MailService *****: checking mail");
if (hasConnectivity && doBackground)
{
@ -181,7 +184,8 @@ public class MailService extends CoreService
notifyConnectionStatus(hasConnectivity);
rescheduleAll(hasConnectivity, doBackground, startIdObj);
startIdObj = null;
Log.i(K9.LOG_TAG, "Got connectivity action with hasConnectivity = " + hasConnectivity + ", doBackground = " + doBackground);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "Got connectivity action with hasConnectivity = " + hasConnectivity + ", doBackground = " + doBackground);
}
else if (CANCEL_CONNECTIVITY_NOTICE.equals(intent.getAction()))
{
@ -195,8 +199,8 @@ public class MailService extends CoreService
stopSelf(startId);
}
}
long endTime = System.currentTimeMillis();
Log.i(K9.LOG_TAG, "MailService.onStart took " + (endTime - startTime) + "ms");
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "MailService.onStart took " + (System.currentTimeMillis() - startTime) + "ms");
}
private void rescheduleAll(final boolean hasConnectivity, final boolean doBackground, final Integer startId)
@ -246,7 +250,8 @@ public class MailService extends CoreService
@Override
public void onDestroy()
{
Log.v(K9.LOG_TAG, "***** MailService *****: onDestroy()");
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "***** MailService *****: onDestroy()");
super.onDestroy();
// MessagingController.getInstance(getApplication()).removeListener(mListener);
}
@ -278,7 +283,8 @@ public class MailService extends CoreService
if (shortestInterval == -1)
{
Log.v(K9.LOG_TAG, "No next check scheduled for package " + getApplication().getPackageName());
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "No next check scheduled for package " + getApplication().getPackageName());
cancel();
}
else
@ -286,15 +292,18 @@ public class MailService extends CoreService
long delay = (shortestInterval * (60 * 1000));
long nextTime = System.currentTimeMillis() + delay;
try
if (K9.DEBUG)
{
String checkString = "Next check for package " + getApplication().getPackageName() + " scheduled for " + new Date(nextTime);
Log.i(K9.LOG_TAG, checkString);
}
catch (Exception e)
{
// I once got a NullPointerException deep in new Date();
Log.e(K9.LOG_TAG, "Exception while logging", e);
try
{
Log.i(K9.LOG_TAG,
"Next check for package " + getApplication().getPackageName() + " scheduled for " + new Date(nextTime));
}
catch (Exception e)
{
// I once got a NullPointerException deep in new Date();
Log.e(K9.LOG_TAG, "Exception while logging", e);
}
}
Intent i = new Intent();
@ -407,10 +416,9 @@ public class MailService extends CoreService
if (minInterval != -1)
{
long nextTime = System.currentTimeMillis() + minInterval;
String checkString = "Next pusher refresh scheduled for " + new Date(nextTime);
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, checkString);
Log.d(K9.LOG_TAG, "Next pusher refresh scheduled for " + new Date(nextTime));
}
Intent i = new Intent();
i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.MailService");
@ -428,20 +436,23 @@ public class MailService extends CoreService
final WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "K9");
wakeLock.setReferenceCounted(false);
wakeLock.acquire(wakeLockTime);
Log.i(K9.LOG_TAG, "MailService queueing Runnable " + runner.hashCode() + " with startId " + startId);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "MailService queueing Runnable " + runner.hashCode() + " with startId " + startId);
Runnable myRunner = new Runnable()
{
public void run()
{
try
{
Log.i(K9.LOG_TAG, "MailService running Runnable " + runner.hashCode() + " with startId " + startId);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "MailService running Runnable " + runner.hashCode() + " with startId " + startId);
runner.run();
}
finally
{
Log.i(K9.LOG_TAG, "MailService completed Runnable " + runner.hashCode() + " with startId " + startId);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "MailService completed Runnable " + runner.hashCode() + " with startId " + startId);
wakeLock.release();
if (startId != null)
{

View File

@ -40,13 +40,15 @@ public class PollService extends CoreService
{
if (START_SERVICE.equals(intent.getAction()))
{
Log.i(K9.LOG_TAG, "PollService started with startId = " + startId);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "PollService started with startId = " + startId);
MessagingController controller = MessagingController.getInstance(getApplication());
Listener listener = (Listener)controller.getCheckMailListener();
if (listener == null)
{
Log.i(K9.LOG_TAG, "***** PollService *****: starting new check");
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "***** PollService *****: starting new check");
mListener.setStartId(startId);
mListener.wakeLockAcquire();
controller.setCheckMailListener(mListener);
@ -54,14 +56,16 @@ public class PollService extends CoreService
}
else
{
Log.i(K9.LOG_TAG,"***** PollService *****: renewing WakeLock");
if (K9.DEBUG)
Log.i(K9.LOG_TAG,"***** PollService *****: renewing WakeLock");
listener.setStartId(startId);
listener.wakeLockAcquire();
}
}
else if (STOP_SERVICE.equals(intent.getAction()))
{
Log.i(K9.LOG_TAG, "PollService stopping");
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "PollService stopping");
stopSelf();
}
@ -158,7 +162,8 @@ public class PollService extends CoreService
controller.setCheckMailListener(null);
MailService.rescheduleCheck(PollService.this, null);
wakeLockRelease();
Log.i(K9.LOG_TAG, "PollService stopping with startId = " + startId);
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "PollService stopping with startId = " + startId);
stopSelf(startId);
}
@ -167,7 +172,8 @@ public class PollService extends CoreService
public void checkMailFinished(Context context, Account account)
{
Log.v(K9.LOG_TAG, "***** PollService *****: checkMailFinished");
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "***** PollService *****: checkMailFinished");
try
{
checkMailDone(context, account);

View File

@ -26,9 +26,7 @@ public class SleepService extends CoreService
{
Integer id = latchId.getAndIncrement();
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "SleepService Preparing CountDownLatch with id = " + id + ", thread " + Thread.currentThread().getName());
}
SleepDatum sleepDatum = new SleepDatum();
CountDownLatch latch = new CountDownLatch(1);
sleepDatum.latch = latch;
@ -53,9 +51,7 @@ public class SleepService extends CoreService
if (timedOut == false)
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "SleepService latch timed out for id = " + id + ", thread " + Thread.currentThread().getName());
}
// don't call endSleep here or remove the sleepDatum here, instead of the following block.
// We might not get the wakeLock before
// falling asleep again, so we have to get the wakeLock *first* The alarmed version will
@ -77,9 +73,7 @@ public class SleepService extends CoreService
long endTime = System.currentTimeMillis();
long actualSleep = endTime - startTime;
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "SleepService requested sleep time was " + sleepTime + ", actual was " + actualSleep);
}
if (actualSleep < sleepTime)
{
Log.w(K9.LOG_TAG, "SleepService sleep time too short: requested was " + sleepTime + ", actual was " + actualSleep);
@ -101,9 +95,7 @@ public class SleepService extends CoreService
else
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "SleepService Counting down CountDownLatch with id = " + id);
}
latch.countDown();
}
reacquireWakeLock(sleepDatum);
@ -111,9 +103,7 @@ public class SleepService extends CoreService
else
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "SleepService Sleep for id " + id + " already finished");
}
}
}
}
@ -127,9 +117,7 @@ public class SleepService extends CoreService
{
long timeout = sleepDatum.timeout;
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "SleepService Acquring wakeLock for id for " + timeout + "ms");
}
wakeLock.acquire(timeout);
}
}