Open
Description
It appears that log.error(msg, cause = someThrowable)
doesn't actually use the throwable to present a meaningful message: neither the throwable's message nor the stack trace appear in logs by default.
Example (you might as well construct an exception yourself, but I relied on a good old NPE here):
import weaver.SimpleIOSuite
import scala.util.Try
object MyTest extends SimpleIOSuite {
test("null pointer") { (_, log) =>
val e =
try {
(null: String).length()
sys.error("can't get here")
} catch {
case e: NullPointerException => e
}
log
.error
.apply("an error", cause = e)
.as(assert.eql(false, true))
}
}
Actual output on sbt test
:
sbt:root> test
[info] compiling 1 Scala source to /Users/kubukoz/projects/demos/target/scala-2.13/test-classes ...
[info] MyTest
[info] - null pointer 12ms
[info] *************FAILURES**************
[info] MyTest
[error] - null pointer 12ms
[error] Values not equal: (src/test/scala/MyTest.scala:19)
[error]
[error] [false] | [true]
[error]
[error] [ERROR] 14:06:42 [MyTest.scala:18] an error
[error]
[error] Failed: Total 1, Failed 1, Errors 0, Passed 0
[error] Failed tests:
[error] MyTest
[error] (Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 1 s, completed Feb 27, 2023, 2:06:42 PM
I'd expect to see the exception message and stack trace somewhere in the logs.
Versions affected: tried 0.8.1 and a local snapshot of the latest main, 0.8.1+35-b03d8212-SNAPSHOT
.
Metadata
Assignees
Labels
No labels