typelevel / typelevel/cats-effect

Add thread name to IO.debug

Open
#4,409 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
2.2k
Forks
576
Avg merge
2d 11h
Merged PRs (30d)
18

Description

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")
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the IO.debug extension method shown in the issue and inspect how its success, error, and cancellation messages are assembled. Add the current thread name to the debug output in the requested format, then find or run the relevant existing tests to verify all three outcomes.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.