Merge change 21751 into eclair
* changes: Make sure we log exceptions in FileLogger
This commit is contained in:
commit
2cf87e6c3c
@ -203,6 +203,12 @@ public abstract class AbstractSyncService implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void userLog(Exception e) {
|
||||||
|
if (Eas.FILE_LOG) {
|
||||||
|
FileLogger.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard logging for EAS.
|
* Standard logging for EAS.
|
||||||
* If user logging is active, we concatenate any arguments and log them using Log.d
|
* If user logging is active, we concatenate any arguments and log them using Log.d
|
||||||
|
@ -1025,7 +1025,8 @@ public class EasSyncService extends AbstractSyncService {
|
|||||||
userLog("Caught IOException: ", ((message == null) ? "" : message));
|
userLog("Caught IOException: ", ((message == null) ? "" : message));
|
||||||
mExitStatus = EXIT_IO_ERROR;
|
mExitStatus = EXIT_IO_ERROR;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Uncaught exception in EasSyncService", e);
|
Log.e(TAG, "Uncaught exception in EasSyncService" + e);
|
||||||
|
userLog(e);
|
||||||
} finally {
|
} finally {
|
||||||
if (!mStop) {
|
if (!mStop) {
|
||||||
userLog(mMailbox.mDisplayName, ": sync finished");
|
userLog(mMailbox.mDisplayName, ": sync finished");
|
||||||
|
@ -105,7 +105,7 @@ public abstract class AbstractSyncParser extends Parser {
|
|||||||
// Make this a push box through the first sync
|
// Make this a push box through the first sync
|
||||||
// TODO Make frequency conditional on user settings!
|
// TODO Make frequency conditional on user settings!
|
||||||
mMailbox.mSyncInterval = Mailbox.CHECK_INTERVAL_PUSH;
|
mMailbox.mSyncInterval = Mailbox.CHECK_INTERVAL_PUSH;
|
||||||
mService.errorLog("Bad sync key; RESET and delete contacts");
|
mService.errorLog("Bad sync key; RESET and delete data");
|
||||||
wipe();
|
wipe();
|
||||||
// Indicate there's more so that we'll start syncing again
|
// Indicate there's more so that we'll start syncing again
|
||||||
moreAvailable = true;
|
moreAvailable = true;
|
||||||
|
@ -20,13 +20,13 @@ import android.content.Context;
|
|||||||
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class FileLogger {
|
public class FileLogger {
|
||||||
private static FileLogger LOGGER = null;
|
private static FileLogger LOGGER = null;
|
||||||
private static FileWriter mLogWriter = null;
|
private static FileWriter mLogWriter = null;
|
||||||
public static String LOG_FILE_NAME = "/sdcard/emaillog.txt";
|
public static String LOG_FILE_NAME = "/sdcard/emaillog.txt";
|
||||||
private static Object mLock = new Object();
|
|
||||||
|
|
||||||
public synchronized static FileLogger getLogger (Context c) {
|
public synchronized static FileLogger getLogger (Context c) {
|
||||||
LOGGER = new FileLogger();
|
LOGGER = new FileLogger();
|
||||||
@ -34,12 +34,10 @@ public class FileLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private FileLogger() {
|
private FileLogger() {
|
||||||
synchronized (mLock) {
|
try {
|
||||||
try {
|
mLogWriter = new FileWriter(LOG_FILE_NAME, true);
|
||||||
mLogWriter = new FileWriter(LOG_FILE_NAME, true);
|
} catch (IOException e) {
|
||||||
} catch (IOException e) {
|
// Doesn't matter
|
||||||
// Doesn't matter
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +52,15 @@ public class FileLogger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public synchronized void log(Exception e) {
|
||||||
|
if (mLogWriter != null) {
|
||||||
|
log("Exception", "Stack trace follows...");
|
||||||
|
PrintWriter pw = new PrintWriter(mLogWriter);
|
||||||
|
e.printStackTrace(pw);
|
||||||
|
pw.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
static public synchronized void log(String prefix, String str) {
|
static public synchronized void log(String prefix, String str) {
|
||||||
if (LOGGER == null) {
|
if (LOGGER == null) {
|
||||||
@ -87,14 +94,12 @@ public class FileLogger {
|
|||||||
sb.append("\r\n");
|
sb.append("\r\n");
|
||||||
String s = sb.toString();
|
String s = sb.toString();
|
||||||
|
|
||||||
synchronized (mLock) {
|
if (mLogWriter != null) {
|
||||||
if (mLogWriter != null) {
|
try {
|
||||||
try {
|
mLogWriter.write(s);
|
||||||
mLogWriter.write(s);
|
mLogWriter.flush();
|
||||||
mLogWriter.flush();
|
} catch (IOException e) {
|
||||||
} catch (IOException e) {
|
// Doesn't matter
|
||||||
// Doesn't matter
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user