diff --git a/compile/inc/src/main/scala/sbt/inc/Incremental.scala b/compile/inc/src/main/scala/sbt/inc/Incremental.scala index 5966ea52d..db2cff86e 100644 --- a/compile/inc/src/main/scala/sbt/inc/Incremental.scala +++ b/compile/inc/src/main/scala/sbt/inc/Incremental.scala @@ -20,6 +20,12 @@ import java.io.File * - IncrementalAnyStyle */ object Incremental { + class PrefixingLogger(val prefix: String)(orig: Logger) extends Logger { + def trace(t: => Throwable): Unit = orig.trace(t) + def success(message: => String): Unit = orig.success(message) + def log(level: sbt.Level.Value, message: => String): Unit = orig.log(level, message.replaceAll("(?m)^", prefix)) + } + /** * Runs the incremental compiler algorithm. * @@ -45,7 +51,7 @@ object Incremental { { val incremental: IncrementalCommon = if (options.nameHashing) - new IncrementalNameHashing(log, options) + new IncrementalNameHashing(new PrefixingLogger("[naha] ")(log), options) else if (options.antStyle) new IncrementalAntStyle(log, options) else diff --git a/compile/inc/src/main/scala/sbt/inc/IncrementalCommon.scala b/compile/inc/src/main/scala/sbt/inc/IncrementalCommon.scala index e11939285..e38c68e2c 100644 --- a/compile/inc/src/main/scala/sbt/inc/IncrementalCommon.scala +++ b/compile/inc/src/main/scala/sbt/inc/IncrementalCommon.scala @@ -22,7 +22,8 @@ private[inc] abstract class IncrementalCommon(log: Logger, options: IncOptions) if (invalidatedRaw.isEmpty) previous else { - def debug(s: => String) = if (incDebug(options)) log.debug(s) else () + val wrappedLog = new Incremental.PrefixingLogger("[inv] ")(log) + def debug(s: => String) = if (incDebug(options)) wrappedLog.debug(s) else () val withPackageObjects = invalidatedRaw ++ invalidatedPackageObjects(invalidatedRaw, previous.relations) val invalidated = expand(withPackageObjects, allSources) val pruned = Incremental.prune(invalidated, previous, classfileManager) @@ -64,23 +65,23 @@ private[inc] abstract class IncrementalCommon(log: Logger, options: IncOptions) newAPIMapping: T => Source): Unit = { val contextSize = options.apiDiffContextSize try { + val wrappedLog = new Incremental.PrefixingLogger("[diff] ")(log) val apiDiff = new APIDiff apiChanges foreach { case APIChangeDueToMacroDefinition(src) => - log.debug(s"Public API is considered to be changed because $src contains a macro definition.") + wrappedLog.debug(s"Public API is considered to be changed because $src contains a macro definition.") case apiChange @ (_: SourceAPIChange[T] | _: NamesChange[T]) => val src = apiChange.modified val oldApi = oldAPIMapping(src) val newApi = newAPIMapping(src) val apiUnifiedPatch = apiDiff.generateApiDiff(src.toString, oldApi.api, newApi.api, contextSize) - log.debug(s"Detected a change in a public API (${src.toString}):\n" - + apiUnifiedPatch) + wrappedLog.debug(s"Detected a change in a public API ($src):\n$apiUnifiedPatch") } } catch { case e: ClassNotFoundException => log.error("You have api debugging enabled but DiffUtils library cannot be found on sbt's classpath") case e: LinkageError => - log.error("Encoutared linkage error while trying to load DiffUtils library.") + log.error("Encountered linkage error while trying to load DiffUtils library.") log.trace(e) case e: Exception => log.error("An exception has been thrown while trying to dump an api diff.")