-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
modules/logging/structured/src/main/scala/tofu/logging/impl/ComposedLoggedValue.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package tofu.logging.impl | ||
|
||
import tofu.logging.{LogRenderer, LoggedValue} | ||
|
||
/** This is supposed to be used to log several `LoggedValue` as if they were passed as arguments to the logging method. | ||
* E.g. to provide a single `LoggedValue` into `ContextMarker`. Be careful: the resulting structured log may contain | ||
* the same fields. | ||
*/ | ||
class ComposedLoggedValue(values: Iterable[LoggedValue]) extends LoggedValue { | ||
override def toString: String = values.map(_.toString).mkString(", ") | ||
|
||
override def logFields[I, V, @specialized R, @specialized M](input: I)(implicit r: LogRenderer[I, V, R, M]): R = | ||
values.foldLeft(r.noop(input)) { (acc, value) => | ||
r.combine(acc, value.logFields(input)) | ||
} | ||
} |