All Downloads are FREE. Search and download functionalities are using the official Maven repository.

euszjaje.jira4s-core_3.2.4.0.source-code.LoggableFuture.scala Maven / Gradle / Ivy

There is a newer version: 2.4.1
Show newest version
package io.gitlab.mateuszjaje.jiraclient

import com.typesafe.scalalogging.Logger

import scala.concurrent.{ExecutionContext, Future}
import scala.util.Try

case class LoggableFuture[T](f: Future[T], logger: Logger)(implicit ex: ExecutionContext) {
  def logErrors(msg: String): Future[T] = {
    f.recover { case t: Throwable =>
      logger.error(msg, t)
      throw t
    }
  }

  def logWarnings(msg: String): Future[T] = {
    f.recover { case t: Throwable =>
      logger.warn(msg, t)
      throw t
    }
  }

  def logging(func: PartialFunction[Try[T], Unit]): Future[T] = {
    f.onComplete(func)
    f
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy