import com.visibleworkings.trace.Trace;
import com.visibleworkings.trace.TraceController;
import java.util.Properties;
import java.io.File;

public class Write {

    static private Trace tr = new Trace("Write");

    public static void main(String[] args) {

        Properties p = new Properties();
        // Use a unique name.
        p.setProperty("TraceLog_tag", "TraceWrite");

        // This is an example of a launch-time check to see if the log
        // should be turned on.
        if (args.length > 0 && args[0].equals("--trace")) {
            p.setProperty("TraceLog_write", "true");
        }
        
        // For this program, writing is off unless the user
        // specifically turns it on. So we override the default.
        if (p.getProperty("TraceLog_write") == null) {
            p.setProperty("TraceLog_write", "false");
            tr.worldm("Tracing turned on by user request.");
        }

        TraceController.start(p); 

        tr.worldm("This message will not appear in the log. There is no log yet.");
        tr.worldm("It *will*, however, appear in the transient buffer.");

        // Turning writing on.
        TraceController.setProperty("TraceLog_write", "true");
        tr.errorm("This message will appear in both the log and the buffer.");

        // See what's in the buffer.
        TraceController.setProperty("Tracebuffer_dump", "true");

        // Turn writing off.
        TraceController.setProperty("TraceLog_write", "false");
        
        tr.worldm("This message will not appear in the log. It's closed.");

        // The buffer can't be dumped - there's no place to dump it to.
        TraceController.setProperty("Tracebuffer_dump", "true");

    }
}


