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

Fix Scala.js toolchain logs in server-client mode #3196

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Changes from 1 commit
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 @@ -17,7 +17,7 @@ import org.scalajs.linker.interface.{
ModuleSplitStyle => _,
_
}
import org.scalajs.logging.ScalaConsoleLogger
import org.scalajs.logging.{Level, Logger}
import org.scalajs.jsenv.{Input, JSEnv, RunConfig}
import org.scalajs.testing.adapter.TestAdapter
import org.scalajs.testing.adapter.{TestAdapterInitializer => TAI}
Expand Down Expand Up @@ -158,6 +158,15 @@ class ScalaJSWorkerImpl extends ScalaJSWorkerApi {
(linker, irFileCacheCache)
}
}
private val logger = new Logger {
def log(level: Level, message: => String): Unit = level match {
case Level.Warn | Level.Error => System.err.println(message)
case Level.Info | Level.Debug => System.out.println(message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should go all log messages to the same channel, STDERR? If a user wants to use STDOUT, she would use println instead of logging, I'd assume.

Copy link
Member Author

@lolgab lolgab Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what ConsoleScalaLogger from Scala.js does.
That would deviate from Sbt but it would mean that the Starting process: node log will be printed to stderr and not to stdout anymore, which is nice.

I don't know what's best to be honest.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the message you mentioned is predestinated to end up on STDERR. It's just tooling side-output, not the output of the actual process to run.

}
def trace(t: => Throwable): Unit = {
t.printStackTrace()
}
}
def link(
runClasspath: Seq[Path],
dest: File,
Expand Down Expand Up @@ -190,7 +199,6 @@ class ScalaJSWorkerImpl extends ScalaJSWorkerApi {
dest = dest
))
val irContainersAndPathsFuture = PathIRContainer.fromClasspath(runClasspath)
val logger = new ScalaConsoleLogger
val testInitializer =
if (testBridgeInit)
ModuleInitializer.mainMethod(TAI.ModuleClassName, TAI.MainMethodName) :: Nil
Expand Down Expand Up @@ -284,7 +292,7 @@ class ScalaJSWorkerImpl extends ScalaJSWorkerApi {
def run(config: JsEnvConfig, report: Report): Unit = {
val env = jsEnv(config)
val input = jsEnvInput(report)
val runConfig0 = RunConfig().withLogger(new ScalaConsoleLogger)
val runConfig0 = RunConfig().withLogger(logger)
val runConfig =
if (mill.api.SystemStreams.isOriginal()) runConfig0
else runConfig0
Expand Down Expand Up @@ -315,7 +323,7 @@ class ScalaJSWorkerImpl extends ScalaJSWorkerApi {
): (() => Unit, sbt.testing.Framework) = {
val env = jsEnv(config)
val input = jsEnvInput(report)
val tconfig = TestAdapter.Config().withLogger(new ScalaConsoleLogger)
val tconfig = TestAdapter.Config().withLogger(logger)

val adapter = new TestAdapter(env, input, tconfig)

Expand Down