Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Enable file logger
Browse files Browse the repository at this point in the history
Blocked by valskalla/odin!240
  • Loading branch information
kubukoz committed Feb 9, 2021
1 parent db0d6a7 commit 92751d9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ lazy val pitgull =
"io.circe" %% "circe-generic-extras" % "0.13.0",
"io.estatico" %% "newtype" % "0.4.4",
"io.scalaland" %% "chimney" % "0.6.1",
"org.typelevel" %% "cats-mtl-core" % "0.7.1",
"io.chrisdavenport" %% "cats-time" % "0.3.4",
"com.github.valskalla" %% "odin-core" % "0.10.0",
"com.github.valskalla" %% "odin-slf4j" % "0.10.0",
Expand Down
9 changes: 4 additions & 5 deletions src/main/scala/io/pg/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,23 @@ import org.http4s.server.middleware

object Main extends IOApp {

def mkLogger[F[_]: ConcurrentEffect: Timer: ContextShift] = {
def mkLogger[F[_]: ConcurrentEffect: Timer: ContextShift]: Resource[F, Logger[F]] = {

// is withMinimalLevel even working??
val console = io.odin.consoleLogger[F](formatter = Formatter.colorful).withMinimalLevel(Level.Info).pure[Resource[F, *]]

val file = io
.odin
.asyncRollingFileLogger[F](
// https://github.com/valskalla/odin/issues/229
fileNamePattern = dateTime => show"/tmp/log/pitgull/pitgull-logs-${dateTime.toLocalDate}.txt",
rolloverInterval = 1.day.some,
maxFileSizeInBytes = (10L * 1024 * 1024 /* 10MB */ ).some,
maxBufferSize = 10.some,
formatter = Formatter.colorful,
minLevel = Level.Debug
)
//todo
console // |+| file

console |+| file
}
.evalTap { logger =>
Sync[F].delay(OdinInterop.globalLogger.set(logger.mapK(Effect.toIOK).some))
Expand Down Expand Up @@ -79,7 +78,7 @@ object Main extends IOApp {
_ <- mkServer[F](config.http, config.meta, resources.routes)
_ <- resources.background.parTraverse_(_.run).background
_ <- logStarted(config.meta).resource_
} yield resources.background
} yield ()

def run(args: List[String]): IO[ExitCode] =
AppConfig
Expand Down

0 comments on commit 92751d9

Please sign in to comment.