[2.x] fix: Respect global log level in continuous build watcher (#8864)

**Problem**
Running `sbt -error ~run` still prints [info] messages from the watcher
("Monitoring source files...", "Build triggered by...", etc). The watcher
creates its logger using only the watchLogLevel setting (default Info),
ignoring the global log level set via CLI flags like -error or -warn.

**Solution**
In Continuous.getCallbacks, take the more restrictive of the watchLogLevel
and the global log level from State when configuring the watcher appender.

Fixes #7355
This commit is contained in:
Dream 2026-03-04 02:35:18 -05:00 committed by GitHub
parent 4ba457d5d1
commit 3579dd0a9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -271,7 +271,9 @@ private[sbt] object Continuous {
validateCommands(s, commands)
val configs = getAllConfigs(s, commands, dynamicInputs)
val appender = ConsoleAppender(channel.name + "-watch", channel.terminal)
val level = configs.minBy(_.watchSettings.logLevel).watchSettings.logLevel
val watchLevel = configs.minBy(_.watchSettings.logLevel).watchSettings.logLevel
val globalLevel = s.get(Keys.logLevel.key).getOrElse(Level.Info)
val level = Seq(watchLevel, globalLevel).max
context.addAppender(channel.name + "-watch", appender -> level)
aggregate(
configs,