adyen-android
adyen-android copied to clipboard
Ability to provide Logger instances
Sometimes while analysing payment issues in qa/release builds it might be useful to know what's happening inside the SDK. The logs are visible while debugging and developing but generally qa/release builds have logcat(android.util.Log) and Adyen logging disabled. Since Adyen uses it's own Logger instance it is hard to achieve this.
An idea would be to use patterns used in libraries like Timber and Beagle where there is a Logger interface/abstract class that defines the contract and prepares the logs/ handle common functionality for all log levels. Clients could provide their own instance of Logger which might log to their own backend or services like Firebase or Sentry on release builds so issues can be solved better. Adyen SDK could include the default logger which might log to logcat for debugging builds and can still make sure all sensitive logs are handled by the default logger and other loggers won't get access to it.
An example of how Timber is configured with a CrashReportingTree
class CrashReportingTree : Timber.Tree() {
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
if (priority != Log.VERBOSE) {
Firebase.crashlytics.log("${getPriorityLabel(priority)}/ $message")
}
t?.let {
Firebase.crashlytics.recordException(it)
}
}
private fun getPriorityLabel(priority: Int): String =
when (priority) {
Log.ASSERT -> "A"
Log.DEBUG -> "D"
Log.INFO -> "I"
Log.WARN -> "W"
Log.ERROR -> "E"
else -> "X"
}
}
// Setting up
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
} else {
Timber.plant(CrashReportingTree())
}
Adyen logger could also be theoretically setup similarly. This was originally discussed in #514 in a comment.
Hi, thanks for the suggestion! We discussed this internally following your comment on the other issue and we added this feature to the pipeline 🙂
We don't have an ETA for it unfortunately but we will make sure we update this ticket when we have a PR.
We have released 5.3.0 which supports adding a custom logger. You can now set your own AdyenLogger instance with AdyenLogger.setLogger.