package de.lemona.android.slf4j;

import org.slf4j.helpers.MarkerIgnoringBase;
import org.slf4j.helpers.MessageFormatter;

import android.util.Log;

public class AndroidLogger extends MarkerIgnoringBase {

    private static final String tag = "Slf4J";

    private final String name;
    private final String prefix;

    public AndroidLogger(String name) {
         this.name = name == null ? "" : name;
         this.prefix = this.name.length() == 0 ? this.name : this.name + ": ";
    }

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

    /* ====================================================================== */

    private String format(final String format, final Object arg1) {
        return this.prefix + MessageFormatter.format(format, arg1).getMessage();
    }

    private String format(final String format, final Object arg1, final Object arg2) {
        return this.prefix + MessageFormatter.format(format, arg1, arg2).getMessage();
    }

    private String format(final String format, final Object[] args) {
        return this.prefix + MessageFormatter.arrayFormat(format, args).getMessage();
    }

    /* ====================================================================== */

    @Override
    public boolean isTraceEnabled() {
        return Log.isLoggable(tag, Log.VERBOSE);
    }

    @Override
    public void trace(final String msg) {
        Log.v(tag, prefix + msg);
    }

    @Override
    public void trace(final String format, final Object arg1) {
        Log.v(tag, format(format, arg1));
    }

    @Override
    public void trace(final String format, final Object arg1, final Object arg2) {
        Log.v(tag, format(format, arg1, arg2));
    }

    @Override
    public void trace(final String format, final Object... args) {
        Log.v(tag, format(format, args));
    }

    @Override
    public void trace(final String msg, final Throwable t) {
        Log.v(tag, prefix + msg, t);
    }

    /* ====================================================================== */

    @Override
    public boolean isDebugEnabled() {
        return Log.isLoggable(tag, Log.DEBUG);
    }

    @Override
    public void debug(final String msg) {
        Log.d(tag, prefix + msg);
    }

    @Override
    public void debug(final String format, final Object arg1) {
        Log.d(tag, format(format, arg1));
    }

    @Override
    public void debug(final String format, final Object arg1, final Object arg2) {
        Log.d(tag, format(format, arg1, arg2));
    }

    @Override
    public void debug(final String format, final Object... args) {
        Log.d(tag, format(format, args));
    }

    @Override
    public void debug(final String msg, final Throwable t) {
        Log.d(tag, prefix + msg, t);
    }

    /* ====================================================================== */

    @Override
    public boolean isInfoEnabled() {
        return Log.isLoggable(tag, Log.INFO);
    }

    @Override
    public void info(final String msg) {
        Log.i(tag, prefix + msg);
    }

    @Override
    public void info(final String format, final Object arg) {
        Log.i(tag, format(format, arg));
    }

    @Override
    public void info(final String format, final Object arg1, final Object arg2) {
        Log.i(tag, format(format, arg1, arg2));
    }

    @Override
    public void info(final String format, final Object... args) {
        Log.i(tag, format(format, args));
    }

    @Override
    public void info(final String msg, final Throwable t) {
        Log.i(tag, prefix + msg, t);
    }

    /* ====================================================================== */

    @Override
    public boolean isWarnEnabled() {
        return Log.isLoggable(tag, Log.WARN);
    }

    @Override
    public void warn(final String msg) {
        Log.w(tag, prefix + msg);
    }

    @Override
    public void warn(final String format, final Object arg) {
        Log.w(tag, format(format, arg));
    }

    @Override
    public void warn(final String format, final Object arg1, final Object arg2) {
        Log.w(tag, format(format, arg1, arg2));
    }

    @Override
    public void warn(final String format, final Object... args) {
        Log.w(tag, format(format, args));
    }

    @Override
    public void warn(final String msg, final Throwable t) {
        Log.w(tag, prefix + msg, t);
    }

    /* ====================================================================== */

    @Override
    public boolean isErrorEnabled() {
        return Log.isLoggable(tag, Log.ERROR);
    }

    @Override
    public void error(final String msg) {
        Log.e(tag, prefix + msg);
    }

    @Override
    public void error(final String format, final Object arg) {
        Log.e(tag, format(format, arg));
    }

    @Override
    public void error(final String format, final Object arg1, final Object arg2) {
        Log.e(tag, format(format, arg1, arg2));
    }

    @Override
    public void error(final String format, final Object... args) {
        Log.e(tag, format(format, args));
    }

    @Override
    public void error(final String msg, final Throwable t) {
        Log.e(tag, prefix + msg, t);
    }
}
@@ -218,22 +218,16 @@
  static 
-final 
 String t
@@ -241,16 +241,198 @@
 lf4J%22;%0A%0A
+    public static void initTag(String tagName) %7B%0A        if (tagName != null) tag = tagName;%0A    %7D%0A%0A    /* ====================================================================== */%0A%0A
     priv

Add a way to customize the tag name.