import com.visibleworkings.trace.Trace;
import com.visibleworkings.trace.TraceController;
import java.util.Properties;

public class DumpExample {

    // Send trace messages to this object. The argument to the
    // constructor is a "subsystem". Each subsystem's tracing can be
    // controlled independently.
    static private Trace tr = new Trace("DumpExample");

    public static void main(String[] args) {
        // Trace defaults are overriden at launch time by passing in
        // properties. 
        Properties p = new Properties();
        // The log file should be "TraceDump.txt".
        p.setProperty("TraceLog_tag", "TraceDump");
        TraceController.start(p);

        tr.usagem("This USAGE message will appear in the buffer. It will appear in the log once the buffer is dumped there.");
        tr.debugm("This DEBUG message will appear nowhere.");

        // This is how you control Trace.java at runtime. This particular
        // command changes the buffer's threshold, but not the log's. 
        TraceController.setProperty("TraceBuffer_DumpExample", "debug");

        tr.debugm("This DEBUG message will appear in the buffer. It will appear in the log once the buffer is dumped there.");

        // This is how you dump the buffer into the log. Notice that
        // the name of this property prevents me from having a
        // subsystem called "Dump". If I did, the command is
        // ambiguous. Is it an attempt to set the threshold of the
        // dump subsystem? Although the use of properties at runtime
        // is kind of kludgy, I'm not sure it's worth changing.
        TraceController.setProperty("TraceBuffer_dump", "true");

    }
}


