All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.softwaremill.macwire.Debug.scala Maven / Gradle / Ivy

The newest version!
package com.softwaremill.macwire

private[macwire] class Debug {
  var ident = 0

  def apply(msg: => String) {
    if (enabled) {
      val prefix = "   " * ident
      println(s"$prefix[debug] $msg")
    }
  }

  def withBlock[T](msg: => String)(block: => T): T = {
    apply(msg)
    beginBlock()
    try {
      block
    } finally {
      endBlock()
    }
  }

  def beginBlock() {
    ident += 1
  }

  def endBlock() {
    ident -= 1
  }

  private val enabled = System.getProperty("macwire.debug") != null
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy