summaryrefslogtreecommitdiff
path: root/src/actors/scala/actors/Debug.scala
blob: 17af47310dfd7b19a2ef5e0b7b2ccf3a4d648061 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2005-2011, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */


package scala.actors

/**
 * Provides methods for generating debugging output.
 *
 * @author Philipp Haller
 */
object Debug extends Logger("") {}

private[actors] class Logger(tag: String) {
  private var lev = 2

  def level = lev
  def level_= (lev: Int) = { this.lev = lev }

  private val tagString = if (tag == "") "" else " ["+tag+"]"

  def info(s: String) =
    if (lev > 2) System.out.println("Info" + tagString + ": " + s)

  def warning(s: String) =
    if (lev > 1) System.err.println("Warning" + tagString + ": " + s)

  def error(s: String) =
    if (lev > 0) System.err.println("Error" + tagString + ": " + s)

  def doInfo(b: => Unit) =
    if (lev > 2) b

  def doWarning(b: => Unit) =
    if (lev > 1) b

  def doError(b: => Unit) =
    if (lev > 0) b
}

@deprecated("this class is going to be removed in a future release")
class Debug(tag: String) extends Logger(tag) {}