Skip to content

Instantly share code, notes, and snippets.

@Signifies
Created January 13, 2015 04:00
Show Gist options
  • Save Signifies/761fab7816979d2ae297 to your computer and use it in GitHub Desktop.
Save Signifies/761fab7816979d2ae297 to your computer and use it in GitHub Desktop.
A debugging class that you can add to your programs.
package me.ES359.Debugger;
/**
* Functions as a debug option for your code.
* Instead of commenting out or removing your debug statements,
* you can use a method to control if they are to be displayed or disabled.
*/
/**
* Created by ES359 on 1/12/15.
*/
public class Debug {
/**
* Datamember variable holds a boolean value.
*/
private boolean control = false;
/**
* Warning method's prefix.
*/
private String prefix_warning = "[WARNING]: ";
/**
* Info methods prefix.
*/
private String prefix_info = "[INFO]: ";
/**
* Checks to see the status of debugging. Is it enabled or disabled?
*
* @return debugging status.
*/
private boolean status() {
return control;
}
/**
* Informs the operator/user the status of debugging.
*/
public void getStatus() {
if(status() == false) {
System.out.print("Debugging is currently disabled.");
}else {
System.out.println("Debugging is enabled! All debug statements\nwritten in code will now appear!");
}
}
/**
*
* @param value Takes a boolean value, that sets debugging enabled or disabled.
*/
public void setDebugStatus(boolean value)
{
control = value;
}
/**
* Warning message.
*
* @param msg Takes a string parameter.
*/
public void warning(String msg) {
if(status()) {
System.out.println(prefix_warning+msg);
}
}
/**
* Info console logger.
* @param msg
*/
public void info(String msg) {
if(status()) {
System.out.println(prefix_info+msg);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment