Remove or filter weaver log levels

オープン
#262 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

@Sukuna0007Abhi がすでに取り組んでいます。

2026年1月22日 から。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
scala
領域
testing

調査の方向性

まず、weaver.Log メソッドと、それらが sbt.testing.Logger をどのように呼び出しているかを追跡します。weaver のレベルを削除する場合と、SBT のレベルに変換する場合を比較し、選択した動作によって、重複したレベルを表示せずに、理解しやすい出力とログレベルによるフィルタリングが実現されることを確認します。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Scala
スター
87
フォーク
17
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

typelevel/weaver-test のほかの issue

typelevel/weaver-test の issue をすべて見る

似ている issue

Scala の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。