Fixed HTTP logging.
This commit is contained in:
parent
aa43c1a11a
commit
ccc2daaae8
1 changed files with 9 additions and 11 deletions
|
@ -132,17 +132,15 @@ open class Akismet(apiKey: String, blog: String) {
|
||||||
this.apiKey = apiKey
|
this.apiKey = apiKey
|
||||||
this.blog = blog
|
this.blog = blog
|
||||||
|
|
||||||
if (logger.isLoggable(Level.FINE)) {
|
|
||||||
val logging = HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
|
val logging = HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
|
||||||
override fun log(message: String) {
|
override fun log(message: String) {
|
||||||
logger.log(Level.FINE, message)
|
if (logger.isLoggable(Level.FINE)) {
|
||||||
|
logger.log(Level.FINE, message.replace(apiKey, "xxxxxxxx" + apiKey.substring(8), true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
logging.level = HttpLoggingInterceptor.Level.BODY
|
logging.level = HttpLoggingInterceptor.Level.BODY
|
||||||
client = OkHttpClient.Builder().addInterceptor(logging).build()
|
client = OkHttpClient.Builder().addInterceptor(logging).build()
|
||||||
} else {
|
|
||||||
client = OkHttpClient()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -472,7 +470,7 @@ open class Akismet(apiKey: String, blog: String) {
|
||||||
logger.log(Level.SEVERE, "An IO error occurred while communicating with the Akismet service.", e)
|
logger.log(Level.SEVERE, "An IO error occurred while communicating with the Akismet service.", e)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.severe("Invalid API end point URL: $method. The API Key is likely invalid.")
|
logger.severe("Invalid API end point URL. The API Key is likely invalid.")
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue