
package org.usfirst.frc2811.RecycleRush.subsystems;

import java.util.HashMap;

import edu.wpi.first.wpilibj.command.Subsystem;

/**
 * Subsystem to help manage large amounts of print statements 
 * Can be used to print common DEBUB, WARNING, INFO, or STATUS messages, 
 * as well as specially named channels  
 */
public class Logger extends Subsystem {
    
	//This is used to store special channels 
    public HashMap<String, Boolean> specials=new HashMap<String, Boolean>(32);

    public void initDefaultCommand() {
        // Set the default command for a subsystem here.
        //setDefaultCommand(new MySpecialCommand());
    }
    
    public Logger(){
       	WARNING=true;
    	STATUS=true;
    }
        
    private boolean DEBUG=false;
    private boolean WARNING=false;
    private boolean INFO=false;
    private boolean STATUS=false;
    
    //Create some setter functions
    /**
     * Enable DEBUG level print statements
     * @param string
     */
    void setDebug(boolean state){DEBUG=state;}
    /**
     * Enable WARNING level print statements
     * @param string
     */
    void setWarning(boolean state){DEBUG=state;}
    /**
     * Enable STATUS level print statements
     * @param string
     */
    void setStatus(boolean state){DEBUG=state;}
    /**
     * Enable INFO level print statements
     * @param string
     */
    void setInfo(boolean state){DEBUG=state;}

    
    /**
     * Print a DEBUG level statement, if enabled
     * @param string
     */
    public void debug(String string){
    	if(DEBUG)System.out.println("(DEBUG) "+string);   
    	}
    /**
     * Print a WARNING level statement, if enabled
     * @param string
     */
    public void warning(String string){
    	if(WARNING)System.out.println("(WARNING) "+string);  
    	}
    /**
     * Print a INFO level statement, if enabled
     * @param string
     */
    public void info(String string){    
    	if(INFO)System.out.println("(INFO) "+string);   
    }
    /**
     * Print a STATUS level statement, if enabled
     * @param string
     */
    public void status(String string){  
    	if(STATUS)System.out.println("(STATUS) "+string);   
    }
    	    
    /**
     * Print a special logging statement, if enabled by setSpecial
     * @param name : Provide a name for custom logging channels
     * @param string : The data to print
     */
    public void special(String name, String string){
    	if(specials.get(name)!=null){
        	//if it exists, it's true
    		System.out.println("("+name+")	" +string);
    	}
    }
    /**
     * Create custom logging channels, and enable or disable printing from it.
     * @param name
     * @param state
     */
    public void setSpecial(String name, boolean state){
    	//This will create a key with the value of True, or remove it from the channel list
    	if(state){
    		specials.put(name, state);
    	}
    	else{
    		specials.remove(name);
    	}
    	
    }
}


@@ -121,16 +121,52 @@
 bsystem;
+%0Aimport edu.wpi.first.wpilibj.Timer;
 %0A%0A/**%0A *
@@ -730,24 +730,30 @@
 TATUS=true;%0A
+    %09%0A
     %7D%0A      
@@ -898,43 +898,8 @@
    %0A
-    //Create some setter functions%0A
     
@@ -1569,16 +1569,26 @@
 println(
+getTime()+
 %22(DEBUG)
@@ -1772,16 +1772,26 @@
 println(
+getTime()+
 %22(WARNIN
@@ -1971,16 +1971,26 @@
 println(
+getTime()+
 %22(INFO) 
@@ -2171,16 +2171,26 @@
 println(
+getTime()+
 %22(STATUS
@@ -2500,18 +2500,9 @@
 ll)%7B
-%0A        %09
+ 
 //if
@@ -2522,16 +2522,33 @@
 t's true
+, so we can print
 %0A    %09%09S
@@ -2565,16 +2565,26 @@
 println(
+getTime()+
 %22(%22+name
@@ -2994,23 +2994,119 @@
 %0A    %09%7D%0A    
-%09
+%7D%0A    %0A    private String getTime()%7B%0A    %09return String.format(%22%255.2f%22,Timer.getFPGATimestamp());
 %0A    %7D%0A%7D%0A%0A

Add timestamping to logging system