All Downloads are FREE. Search and download functionalities are using the official Maven repository.

a8.common.logging.LoggingBootstrapConfigServiceLoader.scala Maven / Gradle / Ivy

There is a newer version: 1.0.0-20240213_1428_master
Show newest version
package a8.common.logging


import scala.jdk.CollectionConverters._
import a8.common.logging.{LoggerFactory, LoggingBootstrapConfig}
import java.util.ServiceLoader

object LoggingBootstrapConfigServiceLoader {

  lazy val loggingBootstrapConfig = loadLoggingBootstrapConfig()

  private def loadLoggingBootstrapConfig(): LoggingBootstrapConfig = {
    ServiceLoader
      .load(classOf[LoggingBootstrapConfigServiceLoader])
      .iterator()
      .asScala
      .toList
      .sortBy(_.priority)
      .reverse
      .headOption
      .map(_.loggingBootstrapConfig)
      .getOrElse(sys.error("no a8.common.logging.LoggingBootstrapConfigServiceLoader found"))
  }


}

class LoggingBootstrapConfigServiceLoader {

  /**
   * highest numbered priority takes precedence
   */
  def priority: Int = 0

  def loggingBootstrapConfig: LoggingBootstrapConfig =
    LoggingBootstrapConfig.finalizedConfig

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy