debug.java

来自「ErGo是一个很早的Java通用围棋服务器(IGS/NNGS)客户端程序。有全部」· Java 代码 · 共 61 行

JAVA
61
字号
package ergo.util;

// $Id: Debug.java,v 1.3 1999/08/27 03:08:11 sigue Exp $

/*
 *  Copyright (C) 1999  Carl L. Gay and Antranig M. Basman.
 *  See the file copyright.txt, distributed with this software,
 *  for further information.
 */

/// Debugging code.
///
/// The rest of the classes use this to do conditional debugging output.

public final class Debug {
  private static boolean debugp = false;
  public  static boolean debugGameLogicp = false;

  public static void setDebug (boolean state) {
    debugp = state;
  }

  public static boolean getDebug () {
    return debugp;
  }

  public static void println (String s) {
    if (debugp)
      System.err.println(s);
  }

  /** Print a message with the current millisecond clock prepended.
   */
  public static void tprintln (String msg) {
    println(System.currentTimeMillis() + " " + Thread.currentThread() + ": " + msg);
  }

  public static void backtrace () {
    backtrace(new Exception());
  }

  public static void backtrace (Exception e) {
    if (debugp)
      e.printStackTrace();
  }

  public static void asser (boolean valid, String error) {
    if (!valid) {
      if (debugp) {
	AssertionFailureException e
	  = new AssertionFailureException("Assertion failed: " + error);
	backtrace(e);
	throw e;
      }
      else 
	System.err.println(error);
    }
  }

} // end class Debug

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?