diff --git a/bsp/src/mill/bsp/BspContext.scala b/bsp/src/mill/bsp/BspContext.scala index a9908d77bea..f5439e1eabd 100644 --- a/bsp/src/mill/bsp/BspContext.scala +++ b/bsp/src/mill/bsp/BspContext.scala @@ -52,6 +52,7 @@ private[mill] class BspContext( } override def info(s: String): Unit = streams.err.println(s) + override def warn(s: String): Unit = streams.err.println(s) override def error(s: String): Unit = streams.err.println(s) override def ticker(s: String): Unit = streams.err.println(s) diff --git a/contrib/scoverage/api/src/mill/contrib/scoverage/api/ScoverageReportWorkerApi2.java b/contrib/scoverage/api/src/mill/contrib/scoverage/api/ScoverageReportWorkerApi2.java index 14dc82d6dd1..29150520454 100644 --- a/contrib/scoverage/api/src/mill/contrib/scoverage/api/ScoverageReportWorkerApi2.java +++ b/contrib/scoverage/api/src/mill/contrib/scoverage/api/ScoverageReportWorkerApi2.java @@ -10,6 +10,8 @@ public interface ScoverageReportWorkerApi2 { interface Logger { void info(String msg); + void warn(String msg); + void error(String msg); void debug(String msg); diff --git a/contrib/scoverage/src/mill/contrib/scoverage/ScoverageReportWorker.scala b/contrib/scoverage/src/mill/contrib/scoverage/ScoverageReportWorker.scala index b536549608c..51ff53b78d8 100644 --- a/contrib/scoverage/src/mill/contrib/scoverage/ScoverageReportWorker.scala +++ b/contrib/scoverage/src/mill/contrib/scoverage/ScoverageReportWorker.scala @@ -39,6 +39,7 @@ class ScoverageReportWorker extends AutoCloseable { def ctx0(implicit ctx: Ctx): ApiCtx = { val logger = new ApiLogger { def info(msg: String): Unit = ctx.log.info(msg) + def warn(msg: String): Unit = ctx.log.warn(msg) def error(msg: String): Unit = ctx.log.error(msg) def debug(msg: String): Unit = ctx.log.debug(msg) } diff --git a/core/api/src/mill/api/Logger.scala b/core/api/src/mill/api/Logger.scala index 51b754e05e3..37f5a34373c 100644 --- a/core/api/src/mill/api/Logger.scala +++ b/core/api/src/mill/api/Logger.scala @@ -37,6 +37,12 @@ trait Logger { */ def debug(s: String): Unit + /** + * Prints logging output which represents warnings the user should care + * about + */ + def warn(s: String): Unit + /** * Prints logging output which represents problems the user should care * about @@ -128,7 +134,7 @@ private[mill] object Logger { private[mill] def enableTicker: Boolean def infoColor: fansi.Attrs - + def warnColor: fansi.Attrs def errorColor: fansi.Attrs def colored: Boolean } @@ -148,6 +154,7 @@ private[mill] object Logger { def enableTicker: Boolean = false def infoColor: fansi.Attrs = fansi.Attrs.Empty + def warnColor: fansi.Attrs = fansi.Attrs.Empty def errorColor: fansi.Attrs = fansi.Attrs.Empty def colored: Boolean = false } diff --git a/core/internal/src/mill/internal/Colors.scala b/core/internal/src/mill/internal/Colors.scala index 98b8c48b4aa..99c6fed05b4 100644 --- a/core/internal/src/mill/internal/Colors.scala +++ b/core/internal/src/mill/internal/Colors.scala @@ -1,7 +1,7 @@ package mill.internal -private[mill] case class Colors(info: fansi.Attrs, error: fansi.Attrs) +private[mill] case class Colors(info: fansi.Attrs, warn: fansi.Attrs, error: fansi.Attrs) private[mill] object Colors { - object Default extends Colors(fansi.Color.Blue, fansi.Color.Red) - object BlackWhite extends Colors(fansi.Attrs.Empty, fansi.Attrs.Empty) + object Default extends Colors(fansi.Color.Blue, fansi.Color.Yellow, fansi.Color.Red) + object BlackWhite extends Colors(fansi.Attrs.Empty, fansi.Attrs.Empty, fansi.Attrs.Empty) } diff --git a/core/internal/src/mill/internal/DummyLogger.scala b/core/internal/src/mill/internal/DummyLogger.scala index f3ea93f8afa..e9905692b90 100644 --- a/core/internal/src/mill/internal/DummyLogger.scala +++ b/core/internal/src/mill/internal/DummyLogger.scala @@ -14,6 +14,7 @@ private[mill] object DummyLogger extends Logger { ) def info(s: String) = () + def warn(s: String) = () def error(s: String) = () def ticker(s: String) = () def debug(s: String) = () diff --git a/core/internal/src/mill/internal/FileLogger.scala b/core/internal/src/mill/internal/FileLogger.scala index b65a669483a..1a0e1ca3ce0 100644 --- a/core/internal/src/mill/internal/FileLogger.scala +++ b/core/internal/src/mill/internal/FileLogger.scala @@ -44,6 +44,7 @@ private[mill] class FileLogger( val streams = new SystemStreams(fileStream, fileStream, mill.api.DummyInputStream) def info(s: String): Unit = streams.out.println(s) + def warn(s: String): Unit = streams.out.println(s) def error(s: String): Unit = streams.out.println(s) def ticker(s: String): Unit = streams.out.println(s) def debug(s: String): Unit = if (prompt.debugEnabled) streams.out.println(s) diff --git a/core/internal/src/mill/internal/MultiLogger.scala b/core/internal/src/mill/internal/MultiLogger.scala index a93c1ac0e5b..970708a5a43 100644 --- a/core/internal/src/mill/internal/MultiLogger.scala +++ b/core/internal/src/mill/internal/MultiLogger.scala @@ -27,6 +27,10 @@ private[mill] class MultiLogger( logger1.info(s) logger2.info(s) } + def warn(s: String): Unit = { + logger1.warn(s) + logger2.warn(s) + } def error(s: String): Unit = { logger1.error(s) logger2.error(s) @@ -85,7 +89,7 @@ private[mill] class MultiLogger( override def debugEnabled: Boolean = logger1.prompt.debugEnabled || logger2.prompt.debugEnabled override def infoColor: Attrs = logger1.prompt.infoColor ++ logger2.prompt.infoColor - + override def warnColor: Attrs = logger1.prompt.warnColor ++ logger2.prompt.warnColor override def errorColor: Attrs = logger1.prompt.errorColor ++ logger2.prompt.errorColor override def colored: Boolean = logger1.prompt.colored || logger2.prompt.colored } diff --git a/core/internal/src/mill/internal/PrefixLogger.scala b/core/internal/src/mill/internal/PrefixLogger.scala index 4e694b50e18..d8eb0f3219f 100644 --- a/core/internal/src/mill/internal/PrefixLogger.scala +++ b/core/internal/src/mill/internal/PrefixLogger.scala @@ -60,6 +60,10 @@ private[mill] class PrefixLogger( prompt.reportKey(logKey) logger0.info("" + prompt.infoColor(linePrefix) + s) } + override def warn(s: String): Unit = { + prompt.reportKey(logKey) + logger0.warn("" + prompt.warnColor(linePrefix) + s) + } override def error(s: String): Unit = { prompt.reportKey(logKey) logger0.error("" + prompt.infoColor(linePrefix) + s) diff --git a/core/internal/src/mill/internal/PromptLogger.scala b/core/internal/src/mill/internal/PromptLogger.scala index 5c0ef03ca6a..622afae7fff 100644 --- a/core/internal/src/mill/internal/PromptLogger.scala +++ b/core/internal/src/mill/internal/PromptLogger.scala @@ -20,6 +20,7 @@ private[mill] class PromptLogger( colored: Boolean, enableTicker: Boolean, infoColor: fansi.Attrs, + warnColor: fansi.Attrs, errorColor: fansi.Attrs, systemStreams0: SystemStreams, debugEnabled: Boolean, @@ -96,6 +97,8 @@ private[mill] class PromptLogger( def info(s: String): Unit = streams.err.println(s) + def warn(s: String): Unit = streams.err.println(s) + def error(s: String): Unit = streams.err.println(s) object prompt extends Logger.Prompt { @@ -147,6 +150,7 @@ private[mill] class PromptLogger( def debugEnabled = PromptLogger.this.debugEnabled def infoColor: fansi.Attrs = PromptLogger.this.infoColor + def warnColor: fansi.Attrs = PromptLogger.this.warnColor def errorColor: fansi.Attrs = PromptLogger.this.errorColor def colored: Boolean = PromptLogger.this.colored } diff --git a/core/internal/src/mill/internal/ProxyLogger.scala b/core/internal/src/mill/internal/ProxyLogger.scala index 192139f743f..8337f34b966 100644 --- a/core/internal/src/mill/internal/ProxyLogger.scala +++ b/core/internal/src/mill/internal/ProxyLogger.scala @@ -12,6 +12,7 @@ private[mill] class ProxyLogger(logger: Logger) extends Logger { lazy val streams = logger.streams def info(s: String): Unit = logger.info(s) + def warn(s: String): Unit = logger.warn(s) def error(s: String): Unit = logger.error(s) def ticker(s: String): Unit = logger.ticker(s) def debug(s: String): Unit = logger.debug(s) diff --git a/core/internal/test/src/mill/internal/PromptLoggerTests.scala b/core/internal/test/src/mill/internal/PromptLoggerTests.scala index 51517fc03f5..b88208be6d1 100644 --- a/core/internal/test/src/mill/internal/PromptLoggerTests.scala +++ b/core/internal/test/src/mill/internal/PromptLoggerTests.scala @@ -15,6 +15,7 @@ object PromptLoggerTests extends TestSuite { colored = false, enableTicker = true, infoColor = fansi.Attrs.Empty, + warnColor = fansi.Attrs.Empty, errorColor = fansi.Attrs.Empty, systemStreams0 = new SystemStreams(baosOut, baosErr, System.in), debugEnabled = false, diff --git a/runner/src/mill/runner/MillMain.scala b/runner/src/mill/runner/MillMain.scala index 9e59cdc79ed..00e93bd3b5c 100644 --- a/runner/src/mill/runner/MillMain.scala +++ b/runner/src/mill/runner/MillMain.scala @@ -372,6 +372,7 @@ object MillMain { colored = colored, enableTicker = enableTicker.getOrElse(true), infoColor = colors.info, + warnColor = colors.warn, errorColor = colors.error, systemStreams0 = streams, debugEnabled = config.debugLog.value, diff --git a/testkit/src/mill/testkit/UnitTester.scala b/testkit/src/mill/testkit/UnitTester.scala index 627c80ba683..0f499db7e79 100644 --- a/testkit/src/mill/testkit/UnitTester.scala +++ b/testkit/src/mill/testkit/UnitTester.scala @@ -69,6 +69,7 @@ class UnitTester( colored = true, enableTicker = false, infoColor = mill.internal.Colors.Default.info, + warnColor = mill.internal.Colors.Default.warn, errorColor = mill.internal.Colors.Default.error, systemStreams0 = new SystemStreams(out = outStream, err = errStream, in = inStream), debugEnabled = debugEnabled, @@ -82,6 +83,7 @@ class UnitTester( else fullName.value } override def error(s: String): Unit = super.error(s"${prefix}: ${s}") + override def warn(s: String): Unit = super.warn(s"${prefix}: ${s}") override def info(s: String): Unit = super.info(s"${prefix}: ${s}") override def debug(s: String): Unit = super.debug(s"${prefix}: ${s}") override def ticker(s: String): Unit = super.ticker(s"${prefix}: ${s}")