Skip to content

Commit

Permalink
Merge pull request #4 from ChristopherDavenport/lazyArguments
Browse files Browse the repository at this point in the history
Lazy Arguments
  • Loading branch information
ChristopherDavenport authored Apr 26, 2018
2 parents 947772c + f0fc671 commit 96b11eb
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/main/scala/io/chrisdavenport/log4cats/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import cats.effect.Sync
import org.log4s.{Logger => Base}

trait Logger[F[_]]{
def error(message: String): F[Unit]
def error(t: Throwable)(message: String): F[Unit]
def warn(message: String): F[Unit]
def warn(t: Throwable)(message: String): F[Unit]
def info(message: String): F[Unit]
def info(t: Throwable)(message: String): F[Unit]
def debug(message: String): F[Unit]
def debug(t: Throwable)(message: String): F[Unit]
def trace(message: String): F[Unit]
def trace(t: Throwable)(message: String): F[Unit]
def error(message: => String): F[Unit]
def error(t: Throwable)(message: => String): F[Unit]
def warn(message: => String): F[Unit]
def warn(t: Throwable)(message: => String): F[Unit]
def info(message: => String): F[Unit]
def info(t: Throwable)(message: => String): F[Unit]
def debug(message: => String): F[Unit]
def debug(t: Throwable)(message: => String): F[Unit]
def trace(message: => String): F[Unit]
def trace(t: Throwable)(message: => String): F[Unit]
}

object Logger {
Expand All @@ -26,29 +26,29 @@ object Logger {


def fromLog4s[F[_]: Sync](logger: Base): Logger[F] = new Logger[F]{
def error(message: String): F[Unit] =
override def error(message: => String): F[Unit] =
Sync[F].delay(logger.error(message))
def error(t: Throwable)(message: String): F[Unit] =
override def error(t: Throwable)(message: => String): F[Unit] =
Sync[F].delay(logger.error(t)(message))

def warn(message: String): F[Unit] =
override def warn(message: => String): F[Unit] =
Sync[F].delay(logger.warn(message))
def warn(t: Throwable)(message: String): F[Unit] =
override def warn(t: Throwable)(message: => String): F[Unit] =
Sync[F].delay(logger.warn(t)(message))

def info(message: String): F[Unit] =
override def info(message: => String): F[Unit] =
Sync[F].delay(logger.info(message))
def info(t: Throwable)(message: String): F[Unit] =
override def info(t: Throwable)(message: => String): F[Unit] =
Sync[F].delay(logger.info(t)(message))

def debug(message: String): F[Unit] =
override def debug(message: => String): F[Unit] =
Sync[F].delay(logger.debug(message))
def debug(t: Throwable)(message: String): F[Unit] =
override def debug(t: Throwable)(message: => String): F[Unit] =
Sync[F].delay(logger.debug(t)(message))

def trace(message: String): F[Unit] =
override def trace(message: => String): F[Unit] =
Sync[F].delay(logger.trace(message))
def trace(t: Throwable)(message: String): F[Unit] =
override def trace(t: Throwable)(message: => String): F[Unit] =
Sync[F].delay(logger.trace(t)(message))
}
}

0 comments on commit 96b11eb

Please sign in to comment.