7mind / izumi

Productivity-oriented collection of lightweight fancy stuff for Scala toolchain
https://izumi.7mind.io
BSD 2-Clause "Simplified" License
615 stars 66 forks source link

Log configurations broke for specifying specific class level #2190

Closed cholmes-axoni closed 1 month ago

cholmes-axoni commented 1 month ago

When specifying an exact match to the logger name or class. logstage no longer accepts the correct level configurations.

This seems to be more of an issue for loggers that route through logstage rather than logstage routers themselves. (SLF4J and JUL)

Example:

logstage-core version 1.2.12

@     import logstage._ 
import logstage._

@     import izumi.fundamentals.platform.language.{CodePosition, CodePositionMaterializer, SourceFilePosition} 
import izumi.fundamentals.platform.language.{CodePosition, CodePositionMaterializer, SourceFilePosition}

@     import java.util.logging.{Logger, Level => JULevel} 
import java.util.logging.{Logger, Level => JULevel}

@     val levelsMap = Map(
        "org.test"           -> Log.Level.Debug,
        "org.test2.FullName" -> Log.Level.Debug,
      ) 
levelsMap: Map[String, Debug.type] = Map("org.test" -> Debug, "org.test2.FullName" -> Debug)

@     val logger = IzLogger(threshold = Log.Level.Info, levels = levelsMap) 
logger: IzLogger = izumi.logstage.api.IzLogger@45dc4752

@     println(logger.router.acceptable(Log.LoggerId("org.test"), Log.Level.Debug)) 
true

@     println(logger.router.acceptable(Log.LoggerId("org.test.other"), Log.Level.Debug)) 
true

@     println(logger.router.acceptable(Log.LoggerId("org.test2.FullName"), Log.Level.Debug)) 
true

logstage-core version 1.2.13

@     import logstage._ 
import logstage._

@     import izumi.fundamentals.platform.language.{CodePosition, CodePositionMaterializer, SourceFilePosition} 
import izumi.fundamentals.platform.language.{CodePosition, CodePositionMaterializer, SourceFilePosition}

@     import java.util.logging.{Logger, Level => JULevel} 
import java.util.logging.{Logger, Level => JULevel}

@     val levelsMap = Map(
        "org.test"           -> Log.Level.Debug,
        "org.test2.FullName" -> Log.Level.Debug,
      ) 
levelsMap: Map[String, Debug.type] = Map("org.test" -> Debug, "org.test2.FullName" -> Debug)

@     val logger = IzLogger(threshold = Log.Level.Info, levels = levelsMap) 
logger: IzLogger = izumi.logstage.api.IzLogger@51e3d37e

@     println(logger.router.acceptable(Log.LoggerId("org.test"), Log.Level.Debug)) 
false

@     println(logger.router.acceptable(Log.LoggerId("org.test.other"), Log.Level.Debug)) 
true

@     println(logger.router.acceptable(Log.LoggerId("org.test2.FullName"), Log.Level.Debug)) 
false
neko-kai commented 1 month ago

Thanks for reporting this! 🙏 We're looking into it!

pshirshov commented 1 month ago

Fixed, my apologies

pshirshov commented 1 month ago

Also, I forgot to mention that there was a workaround:

val levelsMap = Map(
        "org.test"           -> Log.Level.Debug,
      ) 

=>

val levelsMap = Map(
        "org.test"           -> Log.Level.Debug,
        "org.test.*"           -> Log.Level.Debug,
      ) 

Though, of course, that has to be done at our side.