diff --git a/src/java/JavaFileStorage/.classpath b/src/java/JavaFileStorage/.classpath index 88ceb869..c8c2cd23 100644 --- a/src/java/JavaFileStorage/.classpath +++ b/src/java/JavaFileStorage/.classpath @@ -3,7 +3,6 @@ - diff --git a/src/java/JavaFileStorage/src/keepass2android/javafilestorage/GoogleDriveFileStorage.java b/src/java/JavaFileStorage/src/keepass2android/javafilestorage/GoogleDriveFileStorage.java index c39cf97e..3a92f0ab 100644 --- a/src/java/JavaFileStorage/src/keepass2android/javafilestorage/GoogleDriveFileStorage.java +++ b/src/java/JavaFileStorage/src/keepass2android/javafilestorage/GoogleDriveFileStorage.java @@ -265,6 +265,10 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase { }; + public GoogleDriveFileStorage() + { + logDebug("Creating GDrive FileStorage"); + } @Override public boolean checkForFileChangeFast(String path, @@ -570,6 +574,7 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase { private Drive createDriveService(String accountName, Activity activity) { + logDebug("createDriveService "+accountName); GoogleAccountCredential credential = createCredential(activity); credential.setSelectedAccountName(accountName); diff --git a/src/java/JavaFileStorage/src/keepass2android/javafilestorage/JavaFileStorageBase.java b/src/java/JavaFileStorage/src/keepass2android/javafilestorage/JavaFileStorageBase.java index df2f1a1f..a26cd65d 100644 --- a/src/java/JavaFileStorage/src/keepass2android/javafilestorage/JavaFileStorageBase.java +++ b/src/java/JavaFileStorage/src/keepass2android/javafilestorage/JavaFileStorageBase.java @@ -1,11 +1,19 @@ package keepass2android.javafilestorage; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.sql.Date; +import java.text.SimpleDateFormat; +import java.util.Calendar; import org.apache.http.protocol.HTTP; import android.app.Activity; import android.content.Intent; +import android.text.format.DateFormat; import android.util.Log; public abstract class JavaFileStorageBase implements JavaFileStorage{ @@ -16,9 +24,36 @@ public abstract class JavaFileStorageBase implements JavaFileStorage{ final static protected String NAME_ID_SEP = "-KP2A-"; final static protected String TAG = "KP2AJ"; - protected void logDebug(String text) + protected synchronized void logDebug(String text) { Log.d(TAG, text); + + File logFile = new File("/mnt/sdcard/keepass2android.cloud.log"); + if (logFile.exists()) + { + try + { + // Create an instance of SimpleDateFormat used for formatting + // the string representation of date (month/day/year) + SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); + + // Get the date today using Calendar object. + java.util.Date today = Calendar.getInstance().getTime(); + // Using DateFormat format method we can create a string + // representation of a date with the defined format. + String reportDate = df.format(today); + + //BufferedWriter for performance, true to set append to file flag + BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true)); + buf.append(reportDate + " JFS: "+text); + buf.newLine(); + buf.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } } protected String getProtocolPrefix()