tofu.logging.impl.PlusLoggable.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tofu-logging-structured_2.11 Show documentation
Show all versions of tofu-logging-structured_2.11 Show documentation
Opinionated Set of tool for functional programming in scala
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