Skip to content

Commit

Permalink
use ZIO.logAnnotations
Browse files Browse the repository at this point in the history
  • Loading branch information
somdoron committed Oct 9, 2024
1 parent 9058db7 commit 6c9109c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package zio.logging

import zio.test._
import zio.logging.appendLoggerName
import zio.FiberRef
import zio.ZIO

object AppendLoggerNameSpec extends ZIOSpecDefault {

val spec: Spec[Environment, Any] = suite("AppendLoggerNameSpec")(
test("appendLoggerName") {
for {
name <- FiberRef.currentLogAnnotations.get.map(annotations =>
name <- ZIO.logAnnotations.map(annotations =>
annotations.get(loggerNameAnnotationKey)
) @@ appendLoggerName("logging") @@ appendLoggerName("zio")

Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/zio/logging/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ package object logging extends LoggerLayers {
new ZIOAspect[Nothing, Any, Nothing, Any, Nothing, Any] {
def apply[R, E, A](zio: ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A] =
for {
annotations <- FiberRef.currentLogAnnotations.get
annotations <- ZIO.logAnnotations
currentLoggerName = annotations.get(loggerNameAnnotationKey)
newLoggerName = currentLoggerName.fold(value)(currentLoggerName => s"$currentLoggerName.$value")
a <- ZIO.logAnnotate(loggerNameAnnotationKey, newLoggerName)(zio)
Expand Down

0 comments on commit 6c9109c

Please sign in to comment.