Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 922f161d authored by Allen Xu's avatar Allen Xu
Browse files

Allow enable/disablement of logging

Bug: 343478281
Test: make & manual tests
Change-Id: I9fc8ff97385299dde6ac457983e85dd51ba00b54
Merged-In: I9fc8ff97385299dde6ac457983e85dd51ba00b54
parent 69ce2deb
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ public class DropBoxManagerLoggerBackend implements PersistentLoggerBackend {
    private final Handler mHandler;
    // Flag for determining if logging is enabled as a general feature
    private final boolean mDropBoxManagerLoggingEnabled;
    // Flag for controlling if logging is enabled at runtime
    private boolean mIsLoggingEnabled = false;

    /**
     * Returns a singleton instance of {@code DropBoxManagerLoggerBackend} that will log to
@@ -91,6 +93,15 @@ public class DropBoxManagerLoggerBackend implements PersistentLoggerBackend {
        }
    }

    /**
     * Enable or disable logging to DropBoxManager
     * @param isLoggingEnabled Whether logging should be enabled
     */
    public void setLoggingEnabled(boolean isLoggingEnabled) {
        Log.i(DROPBOX_TAG, "toggle logging: " + isLoggingEnabled);
        mIsLoggingEnabled = isLoggingEnabled;
    }

    /**
     * Persist a DEBUG log message.
     * @param tag Used to identify the source of a log message.
@@ -170,6 +181,10 @@ public class DropBoxManagerLoggerBackend implements PersistentLoggerBackend {
            @NonNull String tag,
            @NonNull String msg,
            Optional<Throwable> t) {
        if (!mIsLoggingEnabled) {
            return;
        }

        if (mBufferStartTime == -1L) {
            mBufferStartTime = System.currentTimeMillis();
        }