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

Make mill show skip -j prefixes to ensure machine readability #2884

Merged
merged 3 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions bsp/src/mill/bsp/BspContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ private[mill] class BspContext(
override def error(s: String): Unit = streams.err.println(s)
override def ticker(s: String): Unit = streams.err.println(s)
override def debug(s: String): Unit = streams.err.println(s)

override def debugEnabled: Boolean = true

override def rawOutputStream: PrintStream = systemStreams.out
}

BspWorker(os.pwd, home, log).flatMap { worker =>
Expand Down
8 changes: 8 additions & 0 deletions main/api/src/mill/api/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ trait Logger {

def errorStream: PrintStream = systemStreams.err
def outputStream: PrintStream = systemStreams.out

/**
* [[rawOutputStream]] is intended to be a version of [[outputStream]]
* without decoration: colors, prefixes, timestamps, etc. It is intended
* for the use of tasks like `show` which output data in a way that is
* easily readable by downstream programs.
*/
def rawOutputStream: PrintStream = systemStreams.out
def inStream: InputStream = systemStreams.in

def info(s: String): Unit
Expand Down
3 changes: 3 additions & 0 deletions main/eval/src/mill/eval/GroupEvaluator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import mill.define._
import mill.eval.Evaluator.TaskResult
import mill.util._

import java.io.PrintStream
import scala.collection.mutable
import scala.reflect.NameTransformer.decode
import scala.util.DynamicVariable
Expand Down Expand Up @@ -268,6 +269,8 @@ private[mill] trait GroupEvaluator {
if (enableTicker) super.ticker(tickerPrefix.getOrElse("") + s)
else () // do nothing
}

override def rawOutputStream: PrintStream = logger.rawOutputStream
}
// This is used to track the usage of `T.dest` in more than one Task
// But it's not really clear what issue we try to prevent here
Expand Down
2 changes: 1 addition & 1 deletion main/src/mill/main/MainModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object MainModule {
case Right((watched, Right(res))) =>
val output = f(res)
watched.foreach(watch0)
log.outputStream.println(output.render(indent = 2))
log.rawOutputStream.println(output.render(indent = 2))
Result.Success(output)
}
}
Expand Down
1 change: 1 addition & 0 deletions main/util/src/mill/util/DummyLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ object DummyLogger extends Logger {
new PrintStream(_ => ()),
new ByteArrayInputStream(Array())
)
override def rawOutputStream = systemStreams.out

def info(s: String) = ()
def error(s: String) = ()
Expand Down
2 changes: 2 additions & 0 deletions main/util/src/mill/util/FileLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ class FileLogger(
if (outputStreamUsed)
outputStream.close()
}

override def rawOutputStream: PrintStream = outputStream
}
2 changes: 2 additions & 0 deletions main/util/src/mill/util/MultiLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class MultiLogger(
logger1.close()
logger2.close()
}

override def rawOutputStream: PrintStream = systemStreams.out
}

class MultiStream(stream1: OutputStream, stream2: OutputStream)
Expand Down
2 changes: 2 additions & 0 deletions main/util/src/mill/util/PrefixLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class PrefixLogger(
logger0.systemStreams.in
)

override def rawOutputStream = logger0.rawOutputStream

override def info(s: String): Unit = logger0.info(context + s)
override def error(s: String): Unit = logger0.error(context + s)
override def ticker(s: String): Unit = logger0.ticker(context + tickerContext + s)
Expand Down
2 changes: 2 additions & 0 deletions main/util/src/mill/util/PrintLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class PrintLogger(
systemStreams.err.println(context + s)
}
}

override def rawOutputStream: PrintStream = systemStreams.out
}

object PrintLogger {
Expand Down
4 changes: 4 additions & 0 deletions main/util/src/mill/util/ProxyLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package mill.util

import mill.api.Logger

import java.io.PrintStream

/**
* A Logger that forwards all logging to another Logger. Intended to be
* used as a base class for wrappers that modify logging behavior.
Expand All @@ -19,4 +21,6 @@ class ProxyLogger(logger: Logger) extends Logger {
override def debugEnabled: Boolean = logger.debugEnabled

override def close() = logger.close()

override def rawOutputStream: PrintStream = logger.rawOutputStream
}