settings-sync: improve logging

GitOrigin-RevId: 2b1f836c12255b506b632897aa23df4eb5569a8a
This commit is contained in:
Kirill Likhodedov
2022-01-03 16:46:16 +00:00
committed by intellij-monorepo-bot
parent 1f613933f6
commit f60d448dba
3 changed files with 6 additions and 4 deletions
@@ -49,6 +49,7 @@ private const val TIMEOUT = 10000
private fun sendSnapshotFile(inputStream: InputStream) {
val currentVersion = getCurrentVersion()
LOG.info("Sending $SETTINGS_SYNC_SNAPSHOT_ZIP, current version: $currentVersion")
if (currentVersion != null) {
clientVersionContext.doWithVersion(SETTINGS_SYNC_SNAPSHOT_ZIP, currentVersion) {
client.write(SETTINGS_SYNC_SNAPSHOT_ZIP, inputStream)
@@ -125,7 +126,7 @@ private const val TIMEOUT = 10000
return SettingsSyncPushResult.Success
}
catch (ive: InvalidVersionIdException) {
LOG.info("Rejected: version doesn't match the version on server")
LOG.info("Rejected: version doesn't match the version on server: ${ive.message}")
return SettingsSyncPushResult.Rejected
}
// todo handle authentication failure: propose to login
@@ -148,7 +148,7 @@ internal class GitSettingsLog(private val settingsSyncStorage: Path,
private fun applySnapshotAndCommit(refName: String, snapshot: SettingsSnapshot) {
// todo check repository consistency before each operation: that we're on master, that rb is deleted, that there're no uncommitted changes
LOG.info("Applying settings changes to $refName")
LOG.info("Applying settings changes to branch $refName")
val addCommand = git.add()
val message = "Apply changes received from $refName"
for (fileState in snapshot.fileStates) {
@@ -217,7 +217,7 @@ internal class GitSettingsLog(private val settingsSyncStorage: Path,
private fun fastForwardMaster(branchOnSamePosition: Ref, targetBranch: Ref): BranchPosition {
LOG.info("Advancing master. Its position is equal to ${branchOnSamePosition.short}: ${master.objectId.short}. " +
"Expecting fast-forward merge to ${targetBranch.short} ${targetBranch.objectId.short}")
"Fast-forwarding to ${targetBranch.short} ${targetBranch.objectId.short}")
val mergeResult = git.merge().include(targetBranch).call()
if (mergeResult.mergeStatus != FAST_FORWARD) {
LOG.warn("Non-fast-forward result: $mergeResult")
@@ -93,7 +93,7 @@ internal class SettingsSyncBridge(application: Application,
if (newIdePosition != masterPosition) { // master has advanced further that ide => the ide needs to be updated
val pushResult: SettingsSyncPushResult = pushToIde(settingsLog.collectCurrentSnapshot())
LOG.info("Result of pushing settings to the cloud: $pushResult")
LOG.info("Result of pushing settings to the IDE: $pushResult")
when (pushResult) {
SettingsSyncPushResult.Success -> settingsLog.setIdePosition(masterPosition)
is SettingsSyncPushResult.Error -> {
@@ -113,6 +113,7 @@ internal class SettingsSyncBridge(application: Application,
if (pushToCloudRequired || newCloudPosition != masterPosition) {
val pushResult: SettingsSyncPushResult = pushToCloud(settingsLog.collectCurrentSnapshot())
LOG.info("Result of pushing settings to the cloud: $pushResult")
when (pushResult) {
SettingsSyncPushResult.Success -> settingsLog.setCloudPosition(masterPosition)
is SettingsSyncPushResult.Error -> {