Skip to content

Commit

Permalink
refactor(logger): move log4catsLogger instance from BootStrap to …
Browse files Browse the repository at this point in the history
…`Modules`
  • Loading branch information
yoshinorin committed Mar 3, 2024
1 parent d387505 commit a35c9e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/scala/net/yoshinorin/qualtet/BootStrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package net.yoshinorin.qualtet
import cats.data.Kleisli
import cats.effect.{ExitCode, IO, IOApp}
import cats.effect.kernel.Resource
import org.typelevel.log4cats.SelfAwareStructuredLogger
import org.typelevel.log4cats.{LoggerFactory => Log4CatsLoggerFactory}
import org.http4s.*
import org.http4s.ember.server.EmberServerBuilder
import org.http4s.server.Server
import com.comcast.ip4s.*
import org.typelevel.log4cats.SelfAwareStructuredLogger
import org.typelevel.log4cats.{LoggerFactory => Log4CatsLoggerFactory}
import org.typelevel.log4cats.slf4j.{Slf4jFactory => Log4CatsSlf4jFactory}
import net.yoshinorin.qualtet.http.{AuthProvider, CorsProvider}
import net.yoshinorin.qualtet.http.routes.HomeRoute
import net.yoshinorin.qualtet.http.routes.v1.{
Expand All @@ -32,8 +31,9 @@ import scala.concurrent.duration._

object BootStrap extends IOApp {

given log4catsLogger: Log4CatsLoggerFactory[IO] = Log4CatsSlf4jFactory.create[IO]
val logger: SelfAwareStructuredLogger[IO] = Log4CatsLoggerFactory[IO].getLogger
import net.yoshinorin.qualtet.Modules.log4catsLogger

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

val authProvider = new AuthProvider(Modules.authService)
val corsProvider = new CorsProvider(Modules.config.cors)
Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/net/yoshinorin/qualtet/Modules.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package net.yoshinorin.qualtet

import cats.effect.IO
import doobie.ConnectionIO
import org.typelevel.log4cats.{LoggerFactory => Log4CatsLoggerFactory}
import org.typelevel.log4cats.slf4j.{Slf4jFactory => Log4CatsSlf4jFactory}
import com.github.benmanes.caffeine.cache.{Cache => CaffeineCache, Caffeine}
import net.yoshinorin.qualtet.auth.{AuthService, Jwt, KeyPair}
import net.yoshinorin.qualtet.cache.CacheModule
Expand Down Expand Up @@ -34,6 +37,7 @@ object Modules {

val config = ApplicationConfig.load

given log4catsLogger: Log4CatsLoggerFactory[IO] = Log4CatsSlf4jFactory.create[IO]
given dbContext: DoobieTransactor = new DoobieTransactor(config.db)
val migrator: Migrator = new Migrator(config.db)

Expand Down

0 comments on commit a35c9e5

Please sign in to comment.