import com.visibleworkings.trace.Trace;
import com.visibleworkings.trace.TraceController;

public class Basic {

    // 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("Basic");

    public static void main(String[] args) {
        // Let's announce that this subsystem has been started. Notice
        // that you can post trace messages before the trace subsystem
        // is started. The messages are queued up. 
        tr.worldm("Basic subsystem starts. Messages at different levels will be printed.");

        // This is the simple way to start the trace subsystem.        
        TraceController.start(); 

        // Send messages at every level; only the first three are
        // actually logged.
        LevelPrinter.printMessages();

        // Let us lower the threshold so that debugging messages are
        // printed.

        tr.worldm("Let's set the threshold down to DEBUG.");
        TraceController.setProperty("TraceLog_Basic", "debug");

        // More messages should go to the log now.
        LevelPrinter.printMessages();
    }
}


// This extra class is used to show how different classes can share
// subsystems. Each has its own Trace object, but the underlying data
// structure is shared.
class LevelPrinter {
    static private Trace tr = new Trace("Basic");
    
    static void printMessages() {
        tr.errorm("Here is a trace message at the ERROR level.");
        tr.warningm("Here is a trace message at the WARNING level.");
        tr.worldm("Here is a trace message at the WORLD level.");
        tr.usagem("This USAGE message is normally at too low a level to appear in the log.");
        tr.eventm("This EVENT message is normally at too low a level to appear in the log.");
        tr.debugm("This DEBUG message is normally at too low a level to appear in the log.");
        tr.verbosem("This VERBOSE message is normally at too low a level to appear in the log.");
    }
}

