
package uk.co.wingpath.util;

/**
* This class provides a simple implementation of the {@link Reporter}
* interface.
* All messages are simply printed to the standard error output, prefixed by the
* time and an indication of the kind of message ("Error:", "Warning:", etc.).
*/

public class StderrReporter
    implements Reporter
{
    private void print (String prefix, String msg)
    {
        long ms = System.currentTimeMillis ();
        System.out.println (
            String.format ("%1$tH:%1$tM:%1$tS: %2$s: %3$s",
                ms, prefix, msg));
    }

    public void fatal (String msg)
    {
        print ("Fatal", msg);
    }

    public void fatal (String msg, Throwable t)
    {
        print ("Fatal", msg);
        t.printStackTrace ();
    }

    public void error (String helpId, String msg)
    {
        print ("Error", msg);
    }

    public void warning (String helpId, String msg)
    {
        print ("Warning", msg);
    }

    public void info (String helpId, String msg)
    {
        print ("Info", msg);
    }

    public void debug (String msg)
    {
        print ("Debug", msg);
    }

    public void debug (String msg, Throwable t)
    {
        print ("Debug", msg);
        t.printStackTrace ();
    }

    public void trace (String msg)
    {
        print ("Trace", msg);
    }

    public void clear ()
    {
    }
}

