Skip to content

Commit

Permalink
Merge pull request #137 from pitgull/file-logger
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Feb 11, 2021
2 parents 70fac0c + 6bb2002 commit 9f64521
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
13 changes: 6 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ThisBuild / githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("docker:publish")

Test / fork := true

missinglinkExcludedDependencies in ThisBuild += moduleFilter(
ThisBuild / missinglinkExcludedDependencies += moduleFilter(
organization = "org.slf4j",
name = "slf4j-api"
)
Expand All @@ -74,14 +74,14 @@ val commonSettings = List(
"org.typelevel" %% "cats-effect" % "2.3.1",
"org.typelevel" %% "cats-tagless-macros" % "0.12",
"co.fs2" %% "fs2-core" % "2.5.0",
"com.github.valskalla" %% "odin-core" % "0.10.0",
"com.github.valskalla" %% "odin-core" % "0.11.0",
"io.circe" %% "circe-core" % "0.13.0",
"com.github.julien-truffaut" %% "monocle-macro" % "2.1.0",
"com.disneystreaming" %% "weaver-framework" % "0.5.1" % Test,
"com.disneystreaming" %% "weaver-scalacheck" % "0.5.1" % Test
) ++ compilerPlugins,
testFrameworks += new TestFramework("weaver.framework.TestFramework"),
skip in publish := true
publish / skip := true
)

lazy val gitlab = project
Expand All @@ -103,7 +103,7 @@ lazy val gitlab = project
lazy val core = project.settings(commonSettings).settings(name += "-core")

//workaround for docker not accepting + (the default separator in sbt-dynver)
dynverSeparator in ThisBuild := "-"
ThisBuild / dynverSeparator := "-"

val installDhallJson =
ExecCmd(
Expand Down Expand Up @@ -151,10 +151,9 @@ 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",
"com.github.valskalla" %% "odin-core" % "0.11.0",
"com.github.valskalla" %% "odin-slf4j" % "0.11.0",
"io.github.vigoo" %% "prox" % "0.5.2"
)
)
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 9f64521

Please sign in to comment.