Skip to content

Commit

Permalink
Add warnOnNonMainThreadDetected configuration to IOApp
Browse files Browse the repository at this point in the history
  • Loading branch information
diogocanut committed Sep 8, 2023
1 parent d2759d5 commit be646e0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions core/jvm/src/main/scala/cats/effect/IOApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,13 @@ trait IOApp {
* isn't the main process thread. This condition can happen when we are running inside of an
* `sbt run` with `fork := false`
*/
def warnOnNonMainThreadDetected: Boolean =
Option(System.getProperty("cats.effect.warnOnNonMainThreadDetected"))
.map(_.equalsIgnoreCase("true"))
.getOrElse(true)

private def onNonMainThreadDetected(): Unit = {
val shouldPrint =
Option(System.getProperty("cats.effect.warnOnNonMainThreadDetected"))
.map(_.equalsIgnoreCase("true"))
.getOrElse(true)
if (shouldPrint)
if (warnOnNonMainThreadDetected)
System
.err
.println(
Expand Down

0 comments on commit be646e0

Please sign in to comment.