diff --git a/.gitignore b/.gitignore index a6454986..d605a331 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,13 @@ project/target project/project/* !project/project/plugins.sbt +# Metals + Bloop +.metals/ +metals.sbt +.bloop/ +.bsp/ +.vscode/ + # IDEA specific .idea diff --git a/build.sbt b/build.sbt index 3272542d..19e8df8e 100644 --- a/build.sbt +++ b/build.sbt @@ -3,10 +3,10 @@ lazy val scala_213 = "2.13.5" lazy val versionOf = new { val cats = "2.6.0" - val catsEffect = "2.5.0" - val fs2 = "2.5.5" + val catsEffect = "3.1.0" + val fs2 = "3.0.2" val kindProjector = "0.11.3" - val log4cats = "1.3.0" + val log4cats = "2.1.0" val log4s = "1.9.0" val scalaCheck = "1.15.4" val scalaTest = "3.2.8" @@ -139,25 +139,15 @@ lazy val root = project .settings( name := "log-effect", publishArtifact := false, - addCommandAlias("fmt", ";scalafmt;test:scalafmt;scalafmtSbt"), - addCommandAlias( - "checkFormat", - ";scalafmtCheck;test:scalafmtCheck;scalafmtSbtCheck" - ), - addCommandAlias( - "ciBuild", - ";clean;test" - ), - addCommandAlias( - "fullBuild", - ";checkFormat;ciBuild" - ), - // travis release aliases + addCommandAlias("fmt", "scalafmt;Test/scalafmt;scalafmtSbt"), + addCommandAlias("checkFormat", "scalafmtCheck;Test/scalafmtCheck;scalafmtSbtCheck"), + addCommandAlias("ciBuild", "clean;test"), + addCommandAlias("fullBuild", "checkFormat;ciBuild"), addCommandAlias( "setReleaseOptions", "set scalacOptions ++= Seq(\"-opt:l:method\", \"-opt:l:inline\", \"-opt-inline-from:laserdisc.**\", \"-opt-inline-from:\")" ), - addCommandAlias("releaseIt", ";clean;setReleaseOptions;session list;compile;ci-release") + addCommandAlias("releaseIt", "clean;setReleaseOptions;session list;compile;ci-release") ) lazy val core = project diff --git a/fs2/src/test/scala/ReadmeLogSubmissionCodeSnippetsTest.scala b/fs2/src/test/scala/ReadmeLogSubmissionCodeSnippetsTest.scala index 697399a7..aa0a37eb 100644 --- a/fs2/src/test/scala/ReadmeLogSubmissionCodeSnippetsTest.scala +++ b/fs2/src/test/scala/ReadmeLogSubmissionCodeSnippetsTest.scala @@ -23,7 +23,7 @@ import org.scalatest.wordspec.AnyWordSpecLike "`in a streaming environment using `LogWriter`'s syntax` snippet should compile" in { import java.nio.channels.AsynchronousChannelGroup - import cats.effect.{ConcurrentEffect, ContextShift, Timer} + import cats.effect.Async import cats.syntax.flatMap._ import log.effect.LogWriter @@ -40,18 +40,18 @@ import org.scalatest.wordspec.AnyWordSpecLike implicit def EC: ExecutionContext = ??? implicit def CG: AsynchronousChannelGroup = ??? - def redisClient[F[_]: ConcurrentEffect: ContextShift: Timer]( + def redisClient[F[_]: Async]( address: String )(implicit log: LogWriter[F]): fs2.Stream[F, RedisClient[F]] = RedisClient[F](address) evalMap { client => - log.info(s"Laserdisc Redis client for $address") >> ConcurrentEffect[F].pure(client) + log.info(s"Laserdisc Redis client for $address") >> Async[F].pure(client) } } "`in a streaming environment using `fs2` streams' syntax` snippet should compile" in { import java.nio.channels.AsynchronousChannelGroup - import cats.effect.{ConcurrentEffect, ContextShift, Timer} + import cats.effect.Async import log.effect.LogWriter import log.effect.fs2.syntax._ @@ -68,7 +68,7 @@ import org.scalatest.wordspec.AnyWordSpecLike implicit def EC: ExecutionContext = ??? implicit def CG: AsynchronousChannelGroup = ??? - def redisCache[F[_]: ConcurrentEffect: ContextShift: Timer]( + def redisCache[F[_]: Async]( address: String )(implicit log: LogWriter[F]): fs2.Stream[F, RedisClient[F]] = for { @@ -119,7 +119,7 @@ import org.scalatest.wordspec.AnyWordSpecLike import java.nio.channels.AsynchronousChannelGroup import cats.Show - import cats.effect.{ConcurrentEffect, ContextShift, Timer} + import cats.effect.Async import cats.instances.string._ import cats.syntax.either._ import cats.syntax.flatMap._ @@ -142,7 +142,7 @@ import org.scalatest.wordspec.AnyWordSpecLike implicit def EC: ExecutionContext = ??? implicit def CG: AsynchronousChannelGroup = ??? - def redisClient[F[_]: ConcurrentEffect: ContextShift: Timer: LogWriter]( + def redisClient[F[_]: Async: LogWriter]( address: String ): fs2.Stream[F, Throwable | RedisClient[F]] = { // Cats Show instances are needed for every logged type @@ -152,13 +152,13 @@ import org.scalatest.wordspec.AnyWordSpecLike LogWriter.write(Debug, "Connected client details:") >> // Or LogWriter.debug(address) >> // And LogWriter.debug(client) >> - ConcurrentEffect[F].pure(client.asRight) + Async[F].pure(client.asRight) } handleErrorWith { th => fs2.Stream eval ( LogWriter.write( Error, Failure("Ops, something didn't work", th) - ) >> ConcurrentEffect[F].pure(th.asLeft) + ) >> Async[F].pure(th.asLeft) ) } } diff --git a/fs2/src/test/scala/log/effect/fs2/TestLogCapture.scala b/fs2/src/test/scala/log/effect/fs2/TestLogCapture.scala index 3f090315..624846f4 100644 --- a/fs2/src/test/scala/log/effect/fs2/TestLogCapture.scala +++ b/fs2/src/test/scala/log/effect/fs2/TestLogCapture.scala @@ -4,6 +4,7 @@ package fs2 import java.io.{ByteArrayOutputStream, PrintStream} import cats.effect.IO +import cats.effect.unsafe.implicits.global trait TestLogCapture { diff --git a/interop/src/test/scala/InteropTest.scala b/interop/src/test/scala/InteropTest.scala index 335d1d04..f5f28b61 100644 --- a/interop/src/test/scala/InteropTest.scala +++ b/interop/src/test/scala/InteropTest.scala @@ -8,7 +8,7 @@ final class InteropTest extends AnyWordSpecLike with Matchers with TestLogCaptur "A LogWriter instance can be derived from a log4cats Logger" in { import cats.effect.IO - import cats.syntax.flatMap._ + import cats.effect.unsafe.implicits.global import org.typelevel.log4cats.slf4j.Slf4jLogger import log.effect.LogWriter import log.effect.internal.Show @@ -21,7 +21,7 @@ final class InteropTest extends AnyWordSpecLike with Matchers with TestLogCaptur } } - val logged = capturedLog4sOutOf[IO] { logger => + val logged = capturedLog4sOutOf { logger => import log.effect.interop.log4cats._ implicit val buildMessageLogger = diff --git a/interop/src/test/scala/log/effect/interop/TestLogCapture.scala b/interop/src/test/scala/log/effect/interop/TestLogCapture.scala index cab89b8a..d3273d3a 100644 --- a/interop/src/test/scala/log/effect/interop/TestLogCapture.scala +++ b/interop/src/test/scala/log/effect/interop/TestLogCapture.scala @@ -1,24 +1,23 @@ package log.effect package interop -import cats.effect.{Effect, Sync} +import cats.effect.IO +import cats.effect.unsafe.implicits.global import cats.syntax.flatMap._ import org.log4s.{LoggedEvent, TestAppender, getLogger} import org.slf4j.Logger trait TestLogCapture { - protected final def capturedLog4sOutOf[F[_]: Effect]( - logWrite: Logger => F[Unit] + protected final def capturedLog4sOutOf( + logWrite: Logger => IO[Unit] ): Seq[LoggedEvent] = { - val loggingAction: F[Unit] = - Sync[F].delay(getLogger("Test Logger").logger) >>= { logger => - TestAppender.withAppender() { - logWrite(logger) - } + val loggingAction = IO.delay(getLogger("Test Logger").logger) >>= { logger => + TestAppender.withAppender() { + logWrite(logger) } - - Effect[F].toIO(loggingAction).unsafeRunSync() + } + loggingAction.unsafeRunSync() TestAppender.dequeueAll() }