Skip to content

Add thread name to IO.debug #4409

@asarkar

Description

@asarkar

It'd be very useful to have the thread name in the IO.debug extension method, which is implemented as follows in v3.7-4972921. Something like IO.println(s"[${Thread.currentThread().getName}] ${prefix}: Succeeded: ${S.show(a)}").

 def debug[B >: A](prefix: String = "DEBUG")(
      implicit S: Show[B] = Show.fromToString[B]): IO[A] =
    guaranteeCase {
      case Outcome.Succeeded(ioa) =>
        ioa.flatMap(a => IO.println(s"${prefix}: Succeeded: ${S.show(a)}"))

      case Outcome.Errored(ex) =>
        IO.println(s"${prefix}: Errored: ${ex}")

      case Outcome.Canceled() =>
        IO.println(s"${prefix}: Canceled")
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions