Android Open Source - AGOGCyberStat Abstract Logger






From Project

Back to project page AGOGCyberStat.

License

The source code is released under:

MIT License

If you think the Android project AGOGCyberStat listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.allenz.androidapplog;
//www .  j a v  a2  s.  c  om
import android.util.Log;

public abstract class AbstractLogger implements Logger {

    protected String name;

    protected LogLevel level;

    protected String tag;

    protected boolean showThreadName;

    public AbstractLogger(final String name){
        this(name, Configure.DEFAULT_ROOT_LOG_LEVEL, null, false);
    }

    public AbstractLogger(final String name, final LogLevel level, final String tag, final boolean showThreadName){
        this.name = name;
        this.level = level;
        this.tag = tag;
        this.showThreadName = showThreadName;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public LogLevel getLogLevel() {
        return level;
    }

    @Override
    public void setLogLevel(final LogLevel level) {
        this.level = level;
    }

    @Override
    public String getTag() {
        return tag;
    }

    @Override
    public void setTag(final String tag) {
        this.tag = tag;
    }

    @Override
    public boolean isShowThreadName() {
        return showThreadName;
    }

    @Override
    public void setShowThreadName(final boolean show) {
        showThreadName = show;
    }

    @Override
    public void verbose(final String format, final Object... args) {
        println(LogLevel.VERBOSE, null, format, args);
    }

    @Override
    public void verbose(final Throwable t) {
        println(LogLevel.VERBOSE, t, null);
    }

    @Override
    public void verbose(final Throwable t, final String format,
                        final Object... args) {
        println(LogLevel.VERBOSE, t, null);
    }

    @Override
    public void verbose(final String message) {
        println(LogLevel.VERBOSE, null, message);
    }

    @Override
    public void verbose(final Throwable t, final String message) {
        println(LogLevel.VERBOSE, t, message);
    }

    @Override
    public void verbose(final Object obj) {
        println(LogLevel.VERBOSE, null, obj.toString());
    }

    @Override
    public void debug(final String format, final Object... args) {
        println(LogLevel.DEBUG, null, format, args);
    }

    @Override
    public void debug(final Throwable t) {
        println(LogLevel.DEBUG, t, null);
    }

    @Override
    public void debug(final Throwable t, final String format,
                      final Object... args) {
        println(LogLevel.DEBUG, t, format, args);
    }

    @Override
    public void debug(final String message) {
        println(LogLevel.DEBUG, null, message);
    }

    @Override
    public void debug(final Throwable t, final String message) {
        println(LogLevel.DEBUG, t, message);
    }

    @Override
    public void debug(final Object obj) {
        println(LogLevel.DEBUG, null, obj.toString());
    }

    @Override
    public void info(final String format, final Object... args) {
        println(LogLevel.INFO, null, format, args);
    }

    @Override
    public void info(final Throwable t) {
        println(LogLevel.INFO, t, null);
    }

    @Override
    public void info(final Throwable t, final String format,
                     final Object... args) {
        println(LogLevel.INFO, t, format, args);
    }

    @Override
    public void info(final String message) {
        println(LogLevel.INFO, null, message);
    }

    @Override
    public void info(final Throwable t, final String message) {
        println(LogLevel.INFO, t, message);
    }

    @Override
    public void info(final Object obj) {
        println(LogLevel.INFO, null, obj.toString());
    }

    @Override
    public void warn(final String format, final Object... args) {
        println(LogLevel.WARN, null, format, args);
    }

    @Override
    public void warn(final Throwable t) {
        println(LogLevel.WARN, t, null);
    }

    @Override
    public void warn(final Throwable t, final String format,
                     final Object... args) {
        println(LogLevel.WARN, t, format, args);
    }

    @Override
    public void warn(final String message) {
        println(LogLevel.WARN, null, message);
    }

    @Override
    public void warn(final Throwable t, final String message) {
        println(LogLevel.WARN, t, message);
    }

    @Override
    public void warn(final Object obj) {
        println(LogLevel.WARN, null, obj.toString());
    }

    @Override
    public void error(final String format, final Object... args) {
        println(LogLevel.ERROR, null, format, args);
    }

    @Override
    public void error(final Throwable t) {
        println(LogLevel.ERROR, t, null);
    }

    @Override
    public void error(final Throwable t, final String format,
                      final Object... args) {
        println(LogLevel.ERROR, t, format, args);
    }

    @Override
    public void error(final String message) {
        println(LogLevel.ERROR, null, message);
    }

    @Override
    public void error(final Throwable t, final String message) {
        println(LogLevel.ERROR, t, message);
    }

    @Override
    public void error(final Object obj) {
        println(LogLevel.ERROR, null, obj.toString());
    }

    @Override
    public void wtf(final String format, final Object... args) {
        println(LogLevel.ASSERT, null, format, args);
    }

    @Override
    public void wtf(final Throwable t) {
        println(LogLevel.ASSERT, t, null);
    }

    @Override
    public void wtf(final Throwable t, final String format,
                    final Object... args) {
        println(LogLevel.ASSERT, t, format, args);
    }

    @Override
    public void wtf(final String message) {
        println(LogLevel.ASSERT, null, message);
    }

    @Override
    public void wtf(final Throwable t, final String message) {
        println(LogLevel.ASSERT, t, message);
    }

    @Override
    public void wtf(final Object obj) {
        println(LogLevel.ASSERT, null, obj.toString());
    }

    protected LogEvent buidLogEvent(final LogLevel level, final Throwable t,
                                    final String format, final Object... args) {
        String message = null;
        if (format != null &&
            format.length() > 0) {
            message = (args != null && args.length > 0)? String.format(
                format, args): format;
        }
        if (t != null) {
            message = message != null? message +
                                       "\n"
                                       + Log.getStackTraceString(t): Log
                .getStackTraceString(t);
        }
        String tag;
        if (showThreadName) {
            final StringBuilder sb = new StringBuilder();
            sb.append("[").append(Thread.currentThread().getName())
                .append("]").append(this.tag);
            tag = sb.toString();
        } else {
            tag = this.tag;
        }
        return new LogEvent(level, tag, message);
    }

    protected abstract void println(final LogLevel level, final Throwable t,
                                    final String format, final Object... args);

    @Override
    public String toString() {
        return "Logger [name=" +
               name + ", level=" + level + ", tag=" + tag + ", showThreadName=" + showThreadName + "]";
    }

}




Java Source Code List

com.agog.cyberstat.BrR.java
com.agog.cyberstat.JSONSettings.java
com.agog.cyberstat.MainActivity.java
com.agog.cyberstat.MotisonNetTask.java
com.agog.cyberstat.MotisonXML.java
com.agog.cyberstat.MyPrefs.java
com.agog.cyberstat.NetR.java
com.agog.cyberstat.Trigger.java
me.allenz.androidapplog.AbstractAppender.java
me.allenz.androidapplog.AbstractLogger.java
me.allenz.androidapplog.AppenderSupportLogger.java
me.allenz.androidapplog.Appender.java
me.allenz.androidapplog.AsyncAppender.java
me.allenz.androidapplog.Configure.java
me.allenz.androidapplog.InternalLogger.java
me.allenz.androidapplog.LogCatAppender.java
me.allenz.androidapplog.LogEvent.java
me.allenz.androidapplog.LogLevel.java
me.allenz.androidapplog.LogTextView.java
me.allenz.androidapplog.LoggerConfig.java
me.allenz.androidapplog.LoggerFactory.java
me.allenz.androidapplog.Logger.java
me.allenz.androidapplog.PropertiesParser.java
me.allenz.androidapplog.ReflectUtils.java
me.allenz.androidapplog.Repository.java
me.allenz.androidapplog.RollingFileAppender.java
me.allenz.androidapplog.TextViewAppender.java