summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/util/SimpleTracer.scala
blob: 4e1cf02a6ef462358d36d2857a0d5ff690c3777e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package scala.tools.nsc
package util

// todo: We should unify this with Tracer. I'd do it but Tracer is
// too complicated for me to understand quickly.
import java.io.PrintStream

/** A simple tracer
 *  @param out: The print stream where trace info should be sent
 *  @param enabled: A condition that must be true for trace info to be produced.
 */
class SimpleTracer(out: PrintStream, enabled: Boolean = true) {
  def apply[T](msg: => String)(value: T): T = {
    if (enabled) out.println(msg+value)
    value
  }
  def when(enabled: Boolean): SimpleTracer = new SimpleTracer(out, enabled)
}