typelevel / typelevel/weaver-test

Remove or filter weaver log levels

Open
#262 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
85
Forks
15
PR merge metrics
No merged PRs in 30d

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.

Image

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.Logger levels

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the weaver.Log methods and how they call sbt.testing.Logger. Compare removing the weaver levels with translating them to SBT levels, then confirm the chosen behavior supports understandable output and log-level filtering without showing duplicate levels.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.