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

tofu.logging.impl.PlusLoggable.scala Maven / Gradle / Ivy

The newest version!
package tofu.logging
package impl

import cats.syntax.monoid._
import tofu.logging.Loggable.Base

class PlusLoggable[A](first: Base[A], second: Loggable.Base[A]) extends Loggable[A] {
  def fields[I, V, R, M](a: A, input: I)(implicit receiver: LogRenderer[I, V, R, M]): R =
    first.fields(a, input) |+| second.fields(a, input)

  def putValue[I, V, R, M](a: A, v: V)(implicit r: LogRenderer[I, V, R, M]): M =
    r.coalesce(first.putValue(a, _), second.putValue(a, _), v)

  override def logShow(a: A): String = {
    val s = first.logShow(a)
    if (s.nonEmpty) s else second.logShow(a)
  }
  override def putField[I, V, R, M](a: A, name: String, input: I)(implicit receiver: LogRenderer[I, V, R, M]): R =
    first.putField(a, name, input) |+| second.putField(a, name, input)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy