outr / scribe

The fastest logging library in the world. Built from scratch in Scala and programmatically configurable.
MIT License
523 stars 42 forks source link

unexpected expression evaluation #645

Closed gfrison closed 1 month ago

gfrison commented 1 month ago

Hello!

The example below shows that a trace log is evaluated even if the level (debug) should not allow that.

sbt: 1.10.3 scala: 3.5.2 scribe: 3.15.1

import org.scalatest.freespec.AsyncFreeSpec
import cats.effect.testing.scalatest.AsyncIOSpec
import org.scalatest.matchers.should.Matchers
import scribe.*

class ScribeTest extends AsyncFreeSpec with AsyncIOSpec with Matchers:
  Logger.root.withMinimumLevel(Level.Debug).replace()
  "scribe" in:
    trace {
      println("no good")
      "trace log"
    }
    "a" should be("a")

output:

testOnly *Scribe*
no good
[info] ScribeTest:
[info] - scribe
darkfrog26 commented 1 month ago

If you do:

scribe.info(LogFeature.logOutput2LoggableMessage {
        throw new RuntimeException("Should not evaluate!")
        "testing"
      })

It works as it should. There's a problem with a change I made for varargs on LogFeatures apparently.

darkfrog26 commented 1 month ago

See release 3.15.2

gfrison commented 1 month ago

great! Thank you!