package CoreFS.SD03;

import java.util.Date;


public class CoreSimpleLogger
    implements CoreFileLog
{

    public CoreSimpleLogger(String s)
    {
        this(s, f);
    }

    public CoreSimpleLogger(String s, boolean flag)
    {
        g = true;
        h = s;
        g = flag;
    }

    public boolean isDebugEnabled()
    {
        return true;
    }

    public boolean isInfoEnabled()
    {
        return true;
    }

    public boolean isWarnEnabled()
    {
        return true;
    }

    public boolean isErrorEnabled()
    {
        return true;
    }

    public boolean isFatalEnabled()
    {
        return true;
    }

    public void logDebug(Object obj)
    {
        log(4, obj, null);
    }

    public void logDebug(Object obj, Throwable throwable)
    {
        log(4, obj, throwable);
    }

    public void logInfo(Object obj)
    {
        log(3, obj, null);
    }

    public void logInfo(Object obj, Throwable throwable)
    {
        log(3, obj, throwable);
    }

    public void logWarn(Object obj)
    {
        log(2, obj, null);
    }

    public void logWarn(Object obj, Throwable throwable)
    {
        log(2, obj, throwable);
    }

    public void logFatal(Object obj)
    {
        log(0, obj, null);
    }

    public void logFatal(Object obj, Throwable throwable)
    {
        log(0, obj, throwable);
    }

    public void logError(Object obj)
    {
        log(1, obj, null);
    }

    public void logError(Object obj, Throwable throwable)
    {
        log(1, obj, throwable);
    }

    private void log(int i, Object obj, Throwable throwable)
    {
        StringBuffer stringbuffer = new StringBuffer();
        stringbuffer.append((new Date()).toString()).append(" ");
        switch(i)
        {
        case 0: // '\0'
            stringbuffer.append("FATAL: ");
            break;

        case 1: // '\001'
            stringbuffer.append("ERROR: ");
            break;

        case 2: // '\002'
            stringbuffer.append("WARN: ");
            break;

        case 3: // '\003'
            stringbuffer.append("INFO: ");
            break;

        case 4: // '\004'
            stringbuffer.append("DEBUG: ");
            break;
        }
        if(g)
        {
            Throwable throwable1 = new Throwable();
            StackTraceElement astacktraceelement1[] = throwable1.getStackTrace();
            stringbuffer.append(astacktraceelement1[2].getClassName());
            stringbuffer.append(".");
            stringbuffer.append(astacktraceelement1[2].getMethodName());
            stringbuffer.append("(");
            stringbuffer.append(astacktraceelement1[2].getLineNumber());
            stringbuffer.append(") ");
        }
        if(obj != null)
            stringbuffer.append(obj.toString());
        if(throwable != null)
        {
            stringbuffer.append("\n");
            stringbuffer.append("EXCEPTION STACK TRACE:");
            stringbuffer.append("\n");
            stringbuffer.append(throwable.toString());
            StackTraceElement astacktraceelement[] = throwable.getStackTrace();
            for(int j = 0; j < astacktraceelement.length; j++)
            {
                stringbuffer.append("\n");
                stringbuffer.append("\tat ");
                stringbuffer.append(astacktraceelement[j]);
            }

        }
        System.err.println(stringbuffer.toString());
    }

    public String getName()
    {
        return h;
    }

    private static final boolean f = Boolean.getBoolean("glue.logging.callerLocationInfoEnabled");
    public static StringBuffer bufferedLog = null;
    private boolean g;
    private String h;
	public String getFileLogInfo(String path) {
		// TODO Auto-generated method stub
		return null;
	}

}