scalacenter / scalajs-bundler

https://scalacenter.github.io/scalajs-bundler
Other
235 stars 101 forks source link

No log for startWebpackDevServer #389

Closed vhiairrassary closed 3 years ago

vhiairrassary commented 3 years ago

After fastOptJS::startWebpackDevServer succeeded I have no log from webpack-dev-server when recompiling.

Replacing logger usages by println fix the problem in: https://github.com/scalacenter/scalajs-bundler/blob/11cefe060fdcf689796f1e435100ad65525f26fd/sbt-scalajs-bundler/src/main/scala/scalajsbundler/util/Commands.scala#L44-L46

I suspect sbt is "closing" the logger logger when the task is finished, while fastOptJS::startWebpackDevServer launches the devServer in a background progress. Any thoughts on the recommended fix? I am more than happy to work on it if needed

My configuration:

vhiairrassary commented 3 years ago

Logs are here using sbt 1.3.13 but not with sbt 1.4.6.

The root cause is described in https://github.com/sbt/sbt/releases/tag/v1.4.0:

Replaces Apache Log4j with our own logger by default to avoid Appender leakage. Use ThisBuild / useLog4J := true to use Log4j.

Rational is available here: https://github.com/sbt/sbt/pull/5731. After using ThisBuild / useLog4J := true then logs are available.

Would you rather:

Also the decision may sit behind a setting but I think it is not a good idea to expose that for end users.

Anyway, I can prepare a PR for any solution (which would be a code change or a documentation change)

sjrd commented 3 years ago

Whatever we do, we shouldn't use println, since that is not configurable, and does not support last.

vhiairrassary commented 3 years ago

👍 Here is a PoC using sbt global logger. I still need to validate the usage as there is not much documentation about the global logger.

Edit: following sbt repository recommendation, I posted the question on StackOverflow.