Skip to content

Centralise all logging in Chucker#526

Merged
MiSikora merged 4 commits into
developfrom
central-logger
Jan 5, 2021
Merged

Centralise all logging in Chucker#526
MiSikora merged 4 commits into
developfrom
central-logger

Conversation

@MiSikora

@MiSikora MiSikora commented Dec 21, 2020

Copy link
Copy Markdown
Contributor

📄 Context

Some parts of the code used printStackTrace() to log failures. I wanted to centralise logging point that can be used in Chucker. This also gives an opportunity to let users set an external logger in the future.

📝 Changes

I changed Logger to an interface and made an instance of it available in Chucker object. Companion object of Logger delegates then to this property.

I also added a test extension that sets no-op logger. It is needed as we can't have a centralised logger that is not static due to logging in Android components as well.

One more thing – I removed "Chucker" from log messages. It is present in the tag anyway.

📎 Related PR

#452

🚫 Breaking

No.

🛠️ How to test

Nothing special to check. Rely on unit tests.

⏱️ Next steps

N/A

@MiSikora MiSikora added the enhancement New feature or improvement to the library label Dec 21, 2020
@MiSikora MiSikora changed the title Central logger Centralise all logging in Chucker Dec 21, 2020

@cortinico cortinico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review but I was 🎅 -ing.
LGTM other than a minor comment 👍

val cache = cacheDirectoryProvider.provide()
return if (cache == null) {
IOException("Failed to obtain a valid cache directory for Chucker transaction file").printStackTrace()
Logger.warn("Failed to obtain a valid cache directory transaction file")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we generate an Exception here and call Logger.error instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed Exception because I thought it was used only to avoid println as there was no access here to a logger. I'm fine either way and can bring it back if you think it helps.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about the value added tbh. I'm fine either way 👍

@MiSikora MiSikora Jan 5, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll leave it then. Just will fix a typo that I noticed.

@MiSikora MiSikora merged commit a198ff4 into develop Jan 5, 2021
@MiSikora MiSikora deleted the central-logger branch January 5, 2021 19:07
@vbuberen

vbuberen commented Jan 7, 2021

Copy link
Copy Markdown
Collaborator

Wanted to take part in review as well 😕

@MiSikora

MiSikora commented Jan 8, 2021

Copy link
Copy Markdown
Contributor Author

Sorry, I didn't think this to be an important change to require review from everyone. If you have any comments leave them and I'll make a subsequent PR. :)

@vbuberen vbuberen added this to the 4.0.0 milestone Jan 25, 2021
@vbuberen

Copy link
Copy Markdown
Collaborator

Ok, no problem. I thought that changes in classes with our public API would require more maintainers to check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants