org.cybergarage.util.Debug Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of upnp-stack Show documentation
Show all versions of upnp-stack Show documentation
A pure Java Open Source implementation of the UPnP stack for JDK 1.4 or above
The newest version!
/******************************************************************
*
* CyberUtil for Java
*
* Copyright (C) Satoshi Konno 2002
*
* File: Debug.java
*
* Revision;
*
* 11/18/02
* - first revision.
*
******************************************************************/
package org.cybergarage.util;
import java.io.PrintStream;
/**
*
* This class contains all the utlity and methods used for debugging pupose by the library
*
* @author Satoshi "skonno" Konno
* @author Stefano "Kismet" Lenzi
* @version 1.8
*
*/
public final class Debug{
public static Debug debug = new Debug();
private PrintStream out = System.out;
public Debug(){
}
public synchronized PrintStream getOut() {
return out;
}
public synchronized void setOut(PrintStream out) {
this.out = out;
}
public static boolean enabled = false;
public static Debug getDebug(){
return Debug.debug;
}
public static final void on() {
enabled = true;
}
public static final void off() {
enabled = false;
}
public static boolean isOn() {
return enabled;
}
public static final void message(String s) {
if (enabled == true)
Debug.debug.getOut().println("CyberDomo message : " + s);
}
public static final void message(String m1, String m2) {
if (enabled == true)
Debug.debug.getOut().println("CyberDomo message : ");
Debug.debug.getOut().println(m1);
Debug.debug.getOut().println(m2);
}
public static final void warning(String s) {
Debug.debug.getOut().println("CyberDomo warning : " + s);
}
public static final void warning(String m, Exception e) {
if(e.getMessage()==null){
Debug.debug.getOut().println("CyberDomo warning : " + m + " START");
e.printStackTrace(Debug.debug.getOut());
Debug.debug.getOut().println("CyberDomo warning : " + m + " END");
}else{
Debug.debug.getOut().println("CyberDomo warning : " + m + " (" + e.getMessage() + ")");
}
}
public static final void warning(Exception e) {
warning(e.getMessage());
e.printStackTrace(Debug.debug.getOut());
}
}