-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Timber for Logging #2309
Use Timber for Logging #2309
Conversation
import timber.log.Timber; | ||
import timber.log.Timber.DebugTree; | ||
|
||
import static timber.log.Timber.i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i("Uh, please don't.");
😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, android studio did this in some files but not others. *shrug
@@ -760,7 +760,7 @@ private void resetVisibleLimits() { | |||
try { | |||
getLocalStore().resetVisibleLimits(getDisplayCount()); | |||
} catch (MessagingException e) { | |||
Log.e(K9.LOG_TAG, "Unable to reset visible limits", e); | |||
Timber.e("Unable to reset visible limits", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With Timber exceptions are the first argument. Format string arguments go at the end.
@@ -953,8 +953,8 @@ public void setLocalStorageProviderId(String id) { | |||
switchLocalStorage(id); | |||
successful = true; | |||
} catch (MessagingException e) { | |||
Log.e(K9.LOG_TAG, "Switching local storage provider from " + | |||
mLocalStorageProviderId + " to " + id + " failed.", e); | |||
Timber.e("Switching local storage provider from " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably switch away from doing string concatenations in log messages. Timber supports format strings. So this could be:
Timber.e(e, "Switching local storage provider from %s to %s failed", mLocalStorageProviderId, id);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. No need to do it all at once though.
We still need to update Timber when the debug logging setting is changed by the user. |
logging now enabled if K9.DEBUG || BuildConfig.DEBUG |
What it says on the tin :) as discussed in #1732.
Includes only the main source, notably not k9mail-library.