-
-
Notifications
You must be signed in to change notification settings - Fork 13
Description
The weaver.Log logger currently supports levels via different methods for info, warn, error and debug.
The log level is prepended to the message and then logged using the sbt.testing.Logger using the logger.error method.
This means that two levels are displayed in the console output: the SBT error, and then the weaver log level.
It's not possible to filter the logs using specific levels. On test failure, all the logs are displayed.
We could make logs easier to understand by one of two approaches:
- removing log levels
- logging using the
sbt.testing.Loggerlevels
Removing log levels
Given no issues have been raised for log filtering yet, this aspect of the weaver logger is not likely to be used. We could remove levels entirely, and deprecate the log.info and log.error methods in favour of a single log(...) method.
The printed logs would then look like:
[error] 14:38:01 [HashingSpec.scala:36] An info log
[error] 14:38:01 [HashingSpec.scala:37] A debug log
[error] 14:38:01 [HashingSpec.scala:38] An error log
Users could always add the levels in their own code to get the current behaviour:
def logInfo(msg: String): IO[Unit] = log(s"[INFO] $msg")Logging using the sbt.testing.Logger levels
The weaver log levels could be translated to SBT log levels. This would be more complex to support, but would enable filtering via SBT's logLevel setting.
The logs would then look like:
[info] 14:38:01 [HashingSpec.scala:36] An info log
[debug] 14:38:01 [HashingSpec.scala:37] A debug log
[error] 14:38:01 [HashingSpec.scala:38] An error log