[SyncLogging] just logs don't return an IO

This commit is contained in:
Paul Campbell 2019-05-24 07:59:38 +01:00
parent 4cff0dd0c9
commit 44cf67c9cc
2 changed files with 5 additions and 5 deletions

View file

@ -12,7 +12,7 @@ class Sync(s3Client: S3Client)
with SyncLogging {
def run(implicit c: Config): IO[Unit] = {
logRunStart(c).unsafeRunSync
logRunStart
listObjects(c.bucket, c.prefix)
.map { implicit s3ObjectsData => {
val actions = for {
@ -29,7 +29,7 @@ class Sync(s3Client: S3Client)
ioDelAction <- submitAction(ToDelete(key))
} yield ioDelAction).toStream.sequence
val delList = delActions.unsafeRunSync.toList
logRunFinished(list ++ delList).unsafeRunSync
logRunFinished(list ++ delList)
}}
}

View file

@ -5,13 +5,13 @@ import cats.effect.IO
// Logging for the Sync class
trait SyncLogging extends Logging {
def logRunStart(c: Config): IO[Unit] = IO {
def logRunStart(implicit c: Config): Unit =
log1(s"Bucket: ${c.bucket.name}, Prefix: ${c.prefix.key}, Source: ${c.source}, " +
s"Filter: ${c.filters.map{f => f.filter}.mkString(""", """)}")(c)
}
def logRunFinished(actions: List[S3Action])
(implicit c: Config): IO[Unit] = IO {
(implicit c: Config): Unit = {
val counters = actions.foldLeft(Counters())(logActivity)
log1(s"Uploaded ${counters.uploaded} files")
log1(s"Copied ${counters.copied} files")