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

Bugfix: forgot to use the ScalafmtLogger, fix that #182

Merged
merged 1 commit into from
Dec 8, 2021
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
11 changes: 6 additions & 5 deletions plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ object ScalafmtPlugin extends AutoPlugin {
override def trace(t: => Throwable): Unit = log.trace(t)
override def success(message: => String): Unit = success(message)
override def log(level: Level.Value, message: => String): Unit =
log.log(level, "scalafmt: " + message)
log.log(level, getMessage(message))
def getMessage(message: String): String = "scalafmt: " + message
}

private class FormatSession(
Expand All @@ -135,7 +136,7 @@ object ScalafmtPlugin extends AutoPlugin {
filterMode: String,
errorHandling: ErrorHandling
) {
private val log = taskStreams.log
private val log = new ScalafmtLogger(taskStreams.log)
private val reporter = new ScalafmtSbtReporter(
log,
new OutputStreamWriter(taskStreams.binary()),
Expand Down Expand Up @@ -201,9 +202,9 @@ object ScalafmtPlugin extends AutoPlugin {
}
val bad = res.count(_ eq None)
if (bad != 0) {
val err = s"scalafmt: failed for $bad sources"
if (errorHandling.failOnErrors) throw new MessageOnlyException(err)
log.error(err)
val err = s"failed for $bad sources"
if (!errorHandling.failOnErrors) log.error(err)
else throw new MessageOnlyException(log.getMessage(err))
}
res
}
Expand Down