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

Overrides HttpLoggingInterceptor or Logger on DefaultClient #763

Open
5 tasks done
RafaelMagalhaesN opened this issue Oct 3, 2024 · 0 comments
Open
5 tasks done
Labels
feature request A feature has been asked for or suggested by the community

Comments

@RafaelMagalhaesN
Copy link

RafaelMagalhaesN commented Oct 3, 2024

Checklist

  • I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

Hello,
I'm looking at the DefaultClient implementation, and there isn't a way to override logs emitted by Auth0 requests.
In the current implementation, the HttpLoggingInterceptor has been built inside the init of DefaultClient and cannot be overridden. And I don't want to implement something similar to this just to override the log output.
We need it in the company to logs out a few breadcrumbs to our secure log vault.

Describe the ideal solution

I'd suggest to include two different ways:
1:

package com.auth0.android.request
// code..
public class DefaultClient @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) internal constructor(
    connectTimeout: Int,
    readTimeout: Int,
    private val defaultHeaders: Map<String, String>,
    enableLogging: Boolean,
    private val gson: Gson,
    sslSocketFactory: SSLSocketFactory?,
    trustManager: X509TrustManager?,
    logger: HttpLoggingInterceptor = Interceptor = HttpLoggingInterceptor()
            .setLevel(HttpLoggingInterceptor.Level.BODY)
) : NetworkingClient {
// code 
   init {
        // code
        if (enableLogging) {
          // remove it
          //  val logger: Interceptor = HttpLoggingInterceptor()
           //    .setLevel(HttpLoggingInterceptor.Level.BODY)
            builder.addInterceptor(logger)
        }

        // code
    }
  

}

or

2:

package com.auth0.android.request
// code..
public class DefaultClient @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) internal constructor(
    connectTimeout: Int,
    readTimeout: Int,
    private val defaultHeaders: Map<String, String>,
    enableLogging: Boolean,
    private val gson: Gson,
    sslSocketFactory: SSLSocketFactory?,
    trustManager: X509TrustManager?,
    defaultLogger: Logger = Logger.DEFAULT
) : NetworkingClient {
// code 
   init {
        // code
        if (enableLogging) {
          
            val logger: Interceptor = HttpLoggingInterceptor(defaultLogger)
                  .setLevel(HttpLoggingInterceptor.Level.BODY)
            builder.addInterceptor(logger)
        }

        // code
    }
  

}

Alternatives and current workarounds

That is possible to create a custom NetworkingClient object and that include the HttpLoggingInteceptor by my own, but for a simple log, I guess DefaultClient could provide it

Additional context

We are going to use it in our Dev Env

@RafaelMagalhaesN RafaelMagalhaesN added the feature request A feature has been asked for or suggested by the community label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A feature has been asked for or suggested by the community
Projects
None yet
Development

No branches or pull requests

1 participant