Skip to content

Commit 5b8971f

Browse files
committed
take advantage of the new Trace[F].attachError signature to attach attributes to the exception event
1 parent 66d18dc commit 5b8971f

File tree

1 file changed

+4
-4
lines changed
  • core/shared/src/main/scala/org/typelevel/log4cats/natchez

1 file changed

+4
-4
lines changed

core/shared/src/main/scala/org/typelevel/log4cats/natchez/package.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package object natchez {
2222
override def fromName(name: String): F[SelfAwareStructuredLogger[F]] = getLoggerFromName(name).pure[F]
2323
}
2424

25-
implicit def traceLogger[F[_] : Trace : Applicative]: StructuredLogger[F] = new TraceLogger[F]
25+
implicit def traceLogger[F[_] : Trace]: StructuredLogger[F] = new TraceLogger[F]
2626
}
2727

2828
package natchez {
@@ -59,10 +59,10 @@ package natchez {
5959
}
6060

6161
private[TraceLogger] val mapContextToTraceValue: Map[String, String] => List[(String, TraceValue)] =
62-
_.toList.nested.map(TraceValue.StringValue.apply).value
62+
_.toList.nested.map(TraceableValue[String].toTraceValue).value
6363
}
6464

65-
class TraceLogger[F[_] : Trace : Applicative] extends StructuredLogger[F] {
65+
class TraceLogger[F[_] : Trace] extends StructuredLogger[F] {
6666
private def log(logLevel: LogLevel,
6767
ctx: Map[String, String],
6868
maybeThrowable: Option[Throwable],
@@ -73,7 +73,7 @@ package natchez {
7373
"severity_text" -> logLevelToSeverityText(logLevel) ::
7474
mapContextToTraceValue(ctx)
7575

76-
Trace[F].log(attributes: _*) *> maybeThrowable.fold(().pure[F])(Trace[F].attachError)
76+
maybeThrowable.fold(Trace[F].log(attributes: _*))(Trace[F].attachError(_, attributes: _*))
7777
}
7878

7979
override def trace(ctx: Map[String, String])(msg: => String): F[Unit] = log(LogLevel.Trace, ctx, None, msg)

0 commit comments

Comments
 (0)