Skip to content
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

Merged
merged 6 commits into from
Mar 3, 2017
Merged

Use Timber for Logging #2309

merged 6 commits into from
Mar 3, 2017

Conversation

Valodim
Copy link
Contributor

@Valodim Valodim commented Mar 2, 2017

What it says on the tin :) as discussed in #1732.

Includes only the main source, notably not k9mail-library.

@Valodim Valodim changed the title Log timber Use Timber for Logging Mar 2, 2017
import timber.log.Timber;
import timber.log.Timber.DebugTree;

import static timber.log.Timber.i;
Copy link
Member

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."); 😉

Copy link
Contributor Author

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);
Copy link
Member

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 " +
Copy link
Member

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);

Copy link
Contributor Author

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.

@cketti
Copy link
Member

cketti commented Mar 2, 2017

We still need to update Timber when the debug logging setting is changed by the user.

@Valodim
Copy link
Contributor Author

Valodim commented Mar 2, 2017

logging now enabled if K9.DEBUG || BuildConfig.DEBUG

@Valodim Valodim merged commit 05df114 into master Mar 3, 2017
@Valodim Valodim deleted the log-timber branch March 3, 2017 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants