mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Adopt to new loggin api
This commit is contained in:
@ -12,7 +12,7 @@ import cats.implicits._
|
||||
import fs2.concurrent.SignallingRef
|
||||
import fs2.{Pipe, Stream}
|
||||
|
||||
import docspell.common.Logger
|
||||
import docspell.logging.Logger
|
||||
|
||||
trait PubSubT[F[_]] {
|
||||
|
||||
@ -33,7 +33,7 @@ trait PubSubT[F[_]] {
|
||||
|
||||
object PubSubT {
|
||||
def noop[F[_]: Async]: PubSubT[F] =
|
||||
PubSubT(PubSub.noop[F], Logger.off[F])
|
||||
PubSubT(PubSub.noop[F], Logger.offF[F])
|
||||
|
||||
def apply[F[_]: Async](pubSub: PubSub[F], logger: Logger[F]): PubSubT[F] =
|
||||
new PubSubT[F] {
|
||||
@ -57,7 +57,7 @@ object PubSubT {
|
||||
m.body.as[A](topic.codec) match {
|
||||
case Right(a) => Stream.emit(Message(m.head, a))
|
||||
case Left(err) =>
|
||||
logger.s
|
||||
logger.stream
|
||||
.error(err)(
|
||||
s"Could not decode message to topic ${topic.name} to ${topic.msgClass}: ${m.body.noSpaces}"
|
||||
)
|
||||
|
@ -14,6 +14,7 @@ import fs2.Stream
|
||||
import fs2.concurrent.{Topic => Fs2Topic}
|
||||
|
||||
import docspell.common._
|
||||
import docspell.logging.Logger
|
||||
import docspell.pubsub.api._
|
||||
import docspell.pubsub.naive.NaivePubSub.State
|
||||
import docspell.store.Store
|
||||
@ -60,7 +61,7 @@ final class NaivePubSub[F[_]: Async](
|
||||
store: Store[F],
|
||||
client: Client[F]
|
||||
) extends PubSub[F] {
|
||||
private val logger: Logger[F] = Logger.log4s(org.log4s.getLogger)
|
||||
private val logger: Logger[F] = docspell.logging.getLogger[F]
|
||||
|
||||
def withClient(client: Client[F]): NaivePubSub[F] =
|
||||
new NaivePubSub[F](cfg, state, store, client)
|
||||
@ -85,7 +86,7 @@ final class NaivePubSub[F[_]: Async](
|
||||
|
||||
def subscribe(topics: NonEmptyList[Topic]): Stream[F, Message[Json]] =
|
||||
(for {
|
||||
_ <- logger.s.info(s"Adding subscriber for topics: $topics")
|
||||
_ <- logger.stream.info(s"Adding subscriber for topics: $topics")
|
||||
_ <- Stream.resource[F, Unit](addRemote(topics))
|
||||
m <- Stream.eval(addLocal(topics))
|
||||
} yield m).flatten
|
||||
|
@ -9,6 +9,7 @@ package docspell.pubsub.naive
|
||||
import cats.effect._
|
||||
|
||||
import docspell.common._
|
||||
import docspell.logging.Logger
|
||||
import docspell.pubsub.api._
|
||||
import docspell.store.{Store, StoreFixture}
|
||||
|
||||
@ -45,7 +46,7 @@ trait Fixtures extends HttpClientOps { self: CatsEffectSuite =>
|
||||
}
|
||||
|
||||
object Fixtures {
|
||||
private val loggerIO: Logger[IO] = Logger.log4s(org.log4s.getLogger)
|
||||
private val loggerIO: Logger[IO] = docspell.logging.getLogger[IO]
|
||||
|
||||
final case class Env(store: Store[IO], cfg: PubSubConfig) {
|
||||
def pubSub: Resource[IO, NaivePubSub[IO]] = {
|
||||
|
@ -55,5 +55,5 @@ trait HttpClientOps {
|
||||
}
|
||||
|
||||
object HttpClientOps {
|
||||
private val logger: Logger[IO] = Logger.log4s(org.log4s.getLogger)
|
||||
private val logger = docspell.logging.getLogger[IO]
|
||||
}
|
||||
|
@ -12,14 +12,13 @@ import cats.effect._
|
||||
import cats.implicits._
|
||||
import fs2.concurrent.SignallingRef
|
||||
|
||||
import docspell.common._
|
||||
import docspell.pubsub.api._
|
||||
import docspell.pubsub.naive.Topics._
|
||||
|
||||
import munit.CatsEffectSuite
|
||||
|
||||
class NaivePubSubTest extends CatsEffectSuite with Fixtures {
|
||||
private[this] val logger = Logger.log4s[IO](org.log4s.getLogger)
|
||||
private[this] val logger = docspell.logging.getLogger[IO]
|
||||
|
||||
def subscribe[A](ps: PubSubT[IO], topic: TypedTopic[A]) =
|
||||
for {
|
||||
|
Reference in New Issue
Block a user