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

improvement: Only log messages on resolution #5740

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ object MtagsResolver {
}
}

def fetch(tries: Int = 0): State = {
def fetch(tries: Int = 0): State = logResolution {
try {
val metalsVersion = removedScalaVersions.getOrElse(
scalaVersion,
Expand Down Expand Up @@ -148,6 +148,31 @@ object MtagsResolver {
.currentTimeMillis() - failure.lastTryMillis) > 5.minutes.toMillis
}

def logResolution(state: State): State = {
state match {
case _: State.Success =>
val msg = resolveType match {
case ResolveType.Regular => s"Resolved mtags for $scalaVersion"
case ResolveType.StablePC =>
s"Resolved Scala 3 presentation compiler for $scalaVersion"
case ResolveType.Nightly =>
s"Resolved latest nightly mtags version: $scalaVersion"
}
scribe.debug(msg)
case _: State.Failure =>
val errorMsg = resolveType match {
case ResolveType.Regular =>
s"Failed to resolve mtags for $scalaVersion"
case ResolveType.StablePC =>
s"Failed to resolve Scala 3 presentation compiler for $scalaVersion"
case ResolveType.Nightly =>
s"Failed to resolve latest nightly mtags version: $scalaVersion"
}
scribe.info(errorMsg)
}
state
}

// The metals_2.12 artifact depends on mtags_2.12.x where "x" matches
// `mtags.BuildInfo.scalaCompilerVersion`. In the case when
// `info.getScalaVersion == mtags.BuildInfo.scalaCompilerVersion` then we
Expand All @@ -165,16 +190,6 @@ object MtagsResolver {
if (shouldResolveAgain(failure))
fetch(failure.tries + 1)
else {
val errorMsg = resolveType match {
case ResolveType.Regular =>
s"Failed to resolve mtags for $scalaVersion"
case ResolveType.StablePC =>
s"Failed to resolve Scala 3 presentation compiler for $scalaVersion"
case ResolveType.Nightly =>
s"Failed to resolve latest nightly mtags version: $scalaVersion"
}

scribe.info(errorMsg)
failure
}
}
Expand All @@ -183,14 +198,6 @@ object MtagsResolver {

computed match {
case State.Success(v) =>
val msg = resolveType match {
case ResolveType.Regular => s"Resolved mtags for $scalaVersion"
case ResolveType.StablePC =>
s"Resolved Scala 3 presentation compiler for $scalaVersion"
case ResolveType.Nightly =>
s"Resolved latest nightly mtags version: $scalaVersion"
}
scribe.debug(msg)
Some(v)
// Fallback to Stable PC version
case _: State.Failure
Expand Down