Adopt to new loggin api

This commit is contained in:
eikek
2022-02-19 14:00:47 +01:00
parent 6442771270
commit e483a97de7
130 changed files with 634 additions and 662 deletions

View File

@ -13,7 +13,7 @@ import cats.effect.std.Queue
import cats.implicits._
import fs2.Stream
import docspell.common.Logger
import docspell.logging.Logger
/** Combines a sink and reader to a place where events can be submitted and processed in a
* producer-consumer manner.
@ -21,8 +21,6 @@ import docspell.common.Logger
trait EventExchange[F[_]] extends EventSink[F] with EventReader[F] {}
object EventExchange {
private[this] val logger = org.log4s.getLogger
def silent[F[_]: Applicative]: EventExchange[F] =
new EventExchange[F] {
def offer(event: Event): F[Unit] =
@ -36,7 +34,7 @@ object EventExchange {
Queue.circularBuffer[F, Event](queueSize).map(q => new Impl(q))
final class Impl[F[_]: Async](queue: Queue[F, Event]) extends EventExchange[F] {
private[this] val log = Logger.log4s[F](logger)
private[this] val log: Logger[F] = docspell.logging.getLogger[F]
def offer(event: Event): F[Unit] =
log.debug(s"Pushing event to queue: $event") *>
@ -47,7 +45,7 @@ object EventExchange {
def consume(maxConcurrent: Int)(run: Kleisli[F, Event, Unit]): Stream[F, Nothing] = {
val stream = Stream.repeatEval(queue.take).evalMap((logEvent >> run).run)
log.s.info(s"Starting up $maxConcurrent notification event consumers").drain ++
log.stream.info(s"Starting up $maxConcurrent notification event consumers").drain ++
Stream(stream).repeat.take(maxConcurrent.toLong).parJoin(maxConcurrent).drain
}
}

View File

@ -13,7 +13,7 @@ import cats.implicits._
import cats.kernel.Monoid
import fs2.Stream
import docspell.common._
import docspell.logging.Logger
/** Pushes notification messages/events to an external system */
trait NotificationBackend[F[_]] {

View File

@ -11,7 +11,7 @@ import cats.data.{Kleisli, OptionT}
import cats.implicits._
import fs2.Stream
import docspell.common.Logger
import docspell.logging.Logger
trait NotificationModule[F[_]]
extends EventSink[F]

View File

@ -9,7 +9,7 @@ package docspell.notification.impl
import cats.effect._
import cats.implicits._
import docspell.common._
import docspell.logging.Logger
import docspell.notification.api._
import emil.Emil

View File

@ -6,7 +6,7 @@
package docspell.notification.impl
import docspell.common.Logger
import docspell.logging.Logger
import docspell.notification.api.EventContext
import io.circe.Json

View File

@ -10,7 +10,6 @@ import cats.data.Kleisli
import cats.data.OptionT
import cats.effect._
import docspell.common.Logger
import docspell.notification.api.Event
import docspell.notification.api.NotificationBackend
import docspell.store.Store
@ -21,13 +20,13 @@ import org.http4s.client.Client
/** Represents the actual work done for each event. */
object EventNotify {
private[this] val log4sLogger = org.log4s.getLogger
def apply[F[_]: Async](
store: Store[F],
mailService: Emil[F],
client: Client[F]
): Kleisli[F, Event, Unit] =
): Kleisli[F, Event, Unit] = {
val logger = docspell.logging.getLogger[F]
Kleisli { event =>
(for {
hooks <- OptionT.liftF(store.transact(QNotification.findChannelsForEvent(event)))
@ -43,10 +42,11 @@ object EventNotify {
NotificationBackendImpl.forChannelsIgnoreErrors(
client,
mailService,
Logger.log4s(log4sLogger)
logger
)(channels)
_ <- OptionT.liftF(backend.send(evctx))
} yield ()).getOrElse(())
}
}
}

View File

@ -9,7 +9,7 @@ package docspell.notification.impl
import cats.effect._
import cats.implicits._
import docspell.common.Logger
import docspell.logging.Logger
import docspell.notification.api._
import io.circe.Json

View File

@ -9,7 +9,7 @@ package docspell.notification.impl
import cats.effect._
import cats.implicits._
import docspell.common.Logger
import docspell.logging.Logger
import docspell.notification.api._
import org.http4s.Uri

View File

@ -9,7 +9,7 @@ package docspell.notification.impl
import cats.effect._
import cats.implicits._
import docspell.common._
import docspell.logging.Logger
import docspell.notification.api.NotificationChannel
import org.http4s.Request

View File

@ -8,7 +8,7 @@ package docspell.notification.impl
import cats.effect._
import docspell.common.Logger
import docspell.logging.Logger
import docspell.notification.api._
import org.http4s.Uri

View File

@ -9,7 +9,7 @@ package docspell.notification.impl
import cats.data.NonEmptyList
import cats.effect._
import docspell.common.Logger
import docspell.logging.Logger
import docspell.notification.api.NotificationBackend.{combineAll, ignoreErrors, silent}
import docspell.notification.api.{NotificationBackend, NotificationChannel}

View File

@ -10,7 +10,7 @@ import cats.data.Kleisli
import cats.effect.kernel.Async
import cats.implicits._
import docspell.common._
import docspell.logging.Logger
import docspell.notification.api._
import docspell.store.Store