1
0
mirror of https://github.com/etesync/android synced 2024-12-23 07:08:16 +00:00

Improve logging for login/account creation

This commit is contained in:
Tom Hacohen 2020-09-11 17:17:10 +03:00
parent 2b88ad6896
commit bf1acb1ff5
2 changed files with 9 additions and 2 deletions

View File

@ -70,10 +70,10 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
val userInfoManager = UserInfoManager(authenticatedHttpClient, uri.toHttpUrlOrNull()!!)
userInfo = userInfoManager.fetch(credentials.userName)
} catch (e: Exceptions.HttpException) {
Logger.log.warning(e.message)
Logger.log.warning(e.localizedMessage)
exception = e
} catch (e: IOException) {
Logger.log.warning(e.message)
Logger.log.warning(e.localizedMessage)
exception = e
}
@ -98,6 +98,7 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
val etebase = Account.login(client, credentials.userName, credentials.password)
etebaseSession = etebase.save(null)
} catch (e: EtebaseException) {
Logger.log.warning(e.localizedMessage)
exception = e
}
@ -114,8 +115,10 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
fun findInitialConfiguration(): Configuration {
try {
if (isServerEtebase()) {
Logger.log.fine("Attempting to login to etebase")
return findInitialConfigurationEtebase()
} else {
Logger.log.fine("Attempting to login to EteSync legacy")
return findInitialConfigurationLegacy()
}
} catch (e: Exception) {

View File

@ -39,6 +39,7 @@ class DetectConfigurationFragment : DialogFragment(), LoaderManager.LoaderCallba
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Logger.log.fine("DetectConfigurationFragment: loading")
loaderManager.initLoader(0, arguments, this)
}
@ -49,17 +50,20 @@ class DetectConfigurationFragment : DialogFragment(), LoaderManager.LoaderCallba
override fun onLoadFinished(loader: Loader<Configuration>, data: Configuration?) {
if (data != null) {
if (data.isFailed) {
Logger.log.warning("Failed login configuration ${data.error?.localizedMessage}")
// no service found: show error message
requireFragmentManager().beginTransaction()
.add(NothingDetectedFragment.newInstance(data.error!!.localizedMessage), null)
.commitAllowingStateLoss()
} else if (data.isLegacy) {
// legacy service found: continue
Logger.log.info("Found legacy account - asking for encryption details")
requireFragmentManager().beginTransaction()
.replace(android.R.id.content, EncryptionDetailsFragment.newInstance(data))
.addToBackStack(null)
.commitAllowingStateLoss()
} else {
Logger.log.info("Found Etebase account account")
requireFragmentManager().beginTransaction()
.replace(android.R.id.content, CreateAccountFragment.newInstance(data))
.addToBackStack(null)