Dependency inject logger and replace println
This commit is contained in:
@@ -4,6 +4,7 @@ import cats.effect.IO
|
||||
import cats.effect.unsafe.implicits.global
|
||||
import db.DBService
|
||||
import io.circe.syntax.EncoderOps
|
||||
import org.typelevel.log4cats.slf4j.Slf4jLogger
|
||||
import parse.Aggregate.AggregateValueImplicits.aggregateValueEncoder
|
||||
import parse.Aggregate.{AggregateKey, UserQuery}
|
||||
|
||||
@@ -12,8 +13,6 @@ import java.time.format.DateTimeFormatter
|
||||
|
||||
object Main {
|
||||
private def run: IO[Unit] = {
|
||||
println("================ start parser")
|
||||
|
||||
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmm")
|
||||
val from = LocalDateTime.parse("20230515_0905", formatter)
|
||||
val to = LocalDateTime.parse("20230516_0942", formatter)
|
||||
@@ -21,10 +20,11 @@ object Main {
|
||||
// val userQuery = UserQuery(List("Daugavgrīva"), "precipitation", AggregateKey.List)
|
||||
|
||||
for {
|
||||
log <- Slf4jLogger.create[IO]
|
||||
dbService <- DBService.of
|
||||
lines <- dbService.getInRange(from, to)
|
||||
parsed <- IO.pure(Parser.queryData(userQuery, lines))
|
||||
_ <- IO.println(parsed.asJson)
|
||||
_ <- log.info(parsed.asJson.toString)
|
||||
} yield ()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user