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:
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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[_]] {
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user