Skip to content

Commit

Permalink
refactor: move log4catsLogger given instance from class to companio…
Browse files Browse the repository at this point in the history
…n object
  • Loading branch information
yoshinorin committed Jul 20, 2024
1 parent 36c84e7 commit 7da30ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/main/scala/net/yoshinorin/qualtet/BootStrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import cats.effect.{ExitCode, IO, IOApp}
import cats.effect.kernel.Resource
import org.typelevel.log4cats.SelfAwareStructuredLogger
import org.typelevel.log4cats.{LoggerFactory => Log4CatsLoggerFactory}
import org.typelevel.log4cats.slf4j.{Slf4jFactory => Log4CatsSlf4jFactory}
import org.http4s.*
import org.http4s.ember.server.EmberServerBuilder
import org.http4s.server.Server
Expand All @@ -15,7 +14,7 @@ import scala.concurrent.duration._

object BootStrap extends IOApp {

given log4catsLogger: Log4CatsLoggerFactory[IO] = Log4CatsSlf4jFactory.create[IO]
import Modules.log4catsLogger

val logger: SelfAwareStructuredLogger[IO] = Log4CatsLoggerFactory[IO].getLoggerFromClass(this.getClass)

Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/net/yoshinorin/qualtet/Modules.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ object Modules {
val config = ApplicationConfig.load
val doobieTransactor: DoobieTransactor[Aux] = summon[DoobieTransactor[Aux]]
val transactorResource = doobieTransactor.make(config.db)
given log4catsLogger: Log4CatsLoggerFactory[IO] = Log4CatsSlf4jFactory.create[IO]
}

class Modules(tx: Transactor[IO]) {

val config = ApplicationConfig.load
import Modules.log4catsLogger

given log4catsLogger: Log4CatsLoggerFactory[IO] = Log4CatsSlf4jFactory.create[IO]
val config = Modules.config
given doobieExecuterContext: DoobieExecuter = new DoobieExecuter(tx)

val migrator: Migrator = new Migrator(config.db)
Expand Down

0 comments on commit 7da30ee

Please sign in to comment.