1 package org.sapia.ubik.util; 2 3 import java.io.PrintStream ; 4 5 16 public class StdoutDebug implements Debug{ 17 18 private boolean _on; 19 20 23 public PrintStream out() { 24 return System.out; 25 } 26 27 30 public boolean on() { 31 return _on; 32 } 33 34 public void on(boolean on){ 35 _on = on; 36 } 37 38 41 public void out(Class caller, String msg) { 42 if(_on){ 43 StringBuffer buf = new StringBuffer ("["); 44 buf.append(caller.getName()); 45 buf.append("] "); 46 buf.append(msg); 47 System.out.println(buf.toString()); 48 } 49 } 50 51 54 public void out(Class caller, String msg, Throwable err) { 55 if(_on){ 56 StringBuffer buf = new StringBuffer ("["); 57 buf.append(caller.getName()); 58 buf.append("] "); 59 if(msg != null) 60 buf.append(msg); 61 System.out.println(buf.toString()); 62 if(err != null) 63 err.printStackTrace(System.out); 64 } 65 } 66 67 } 68 | Popular Tags |