package com.vaguehope.onosendai.util;

import android.util.Log;

import com.vaguehope.onosendai.C;

public class LogWrapper {

	private String prefix;

	public LogWrapper () {}

	public LogWrapper (final String prefix) {
		this.prefix = prefix;
	}

	public void setPrefix (final String prefix) {
		this.prefix = prefix;
	}

	public String getPrefix () {
		return this.prefix;
	}

	public void i (final String msg) {
		if (!Log.isLoggable(C.TAG, Log.INFO)) return;
		Log.i(C.TAG, this.prefix == null ? msg : String.format("%s %s", this.prefix, msg));
	}

	public void i (final String msg, final Object... args) {
		if (!Log.isLoggable(C.TAG, Log.INFO)) return;
		Log.i(C.TAG, this.prefix == null ? msg : String.format("%s %s", this.prefix, String.format(msg, args)));
	}

	public void w (final String msg) {
		if (!Log.isLoggable(C.TAG, Log.WARN)) return;
		Log.w(C.TAG, this.prefix == null ? msg : String.format("%s %s", this.prefix, msg));
	}

	public void e (final String msg) {
		if (!Log.isLoggable(C.TAG, Log.ERROR)) return;
		Log.e(C.TAG, this.prefix == null ? msg : String.format("%s %s", this.prefix, msg));
	}

	public void e (final String msg, final Throwable t) {
		if (!Log.isLoggable(C.TAG, Log.ERROR)) return;
		Log.e(C.TAG, this.prefix == null ? msg : String.format("%s %s", this.prefix, msg), t);
	}

	public void d (final String msg) {
		if (!Log.isLoggable(C.TAG, Log.DEBUG)) return;
		Log.d(C.TAG, msg);
	}

}

@@ -378,33 +378,33 @@
 %7D%0A%0A%09public void 
-i
+e
  (final String m
@@ -434,36 +434,37 @@
 able(C.TAG, Log.
-INFO
+ERROR
 )) return;%0A%09%09Log
@@ -456,33 +456,33 @@
 ) return;%0A%09%09Log.
-i
+e
 (C.TAG, this.pre
@@ -505,44 +505,18 @@
 g : 
-String.format(%22%25s %25s%22, this.p
+addP
 refix
-, 
+(
 msg)
@@ -535,17 +535,17 @@
 ic void 
-i
+e
  (final 
@@ -566,22 +566,19 @@
 nal 
-Object... args
+Throwable t
 ) %7B%0A
@@ -614,12 +614,13 @@
 Log.
-INFO
+ERROR
 )) r
@@ -632,17 +632,17 @@
 ;%0A%09%09Log.
-i
+e
 (C.TAG, 
@@ -673,69 +673,25 @@
 g : 
-String.format(%22%25s %25s%22, this.prefix, String.format
+addPrefix
 (msg
+)
 , 
-args))
+t
 );%0A%09
@@ -824,44 +824,18 @@
 g : 
-String.format(%22%25s %25s%22, this.p
+addP
 refix
-, 
+(
 msg)
@@ -846,33 +846,33 @@
 %7D%0A%0A%09public void 
-e
+i
  (final String m
@@ -902,37 +902,36 @@
 able(C.TAG, Log.
-ERROR
+INFO
 )) return;%0A%09%09Log
@@ -923,33 +923,33 @@
 ) return;%0A%09%09Log.
-e
+i
 (C.TAG, this.pre
@@ -972,44 +972,18 @@
 g : 
-String.format(%22%25s %25s%22, this.p
+addP
 refix
-, 
+(
 msg)
@@ -994,33 +994,33 @@
 %7D%0A%0A%09public void 
-e
+i
  (final String m
@@ -1025,35 +1025,38 @@
  msg, final 
-Throwable t
+Object... args
 ) %7B%0A%09%09if (!L
@@ -1072,37 +1072,36 @@
 able(C.TAG, Log.
-ERROR
+INFO
 )) return;%0A%09%09Log
@@ -1093,33 +1093,33 @@
 ) return;%0A%09%09Log.
-e
+i
 (C.TAG, this.pre
@@ -1138,16 +1138,26 @@
 ? msg : 
+addPrefix(
 String.f
@@ -1166,37 +1166,19 @@
 mat(
-%22%25s %25s%22, this.prefix, msg), t
+msg, args))
 );%0A%09
@@ -1279,16 +1279,157 @@
 d(C.TAG,
+ this.prefix == null ? msg : addPrefix(msg));%0A%09%7D%0A%0A%09private String addPrefix (final String msg) %7B%0A%09%09return String.format(%22%25s %25s%22, this.prefix,
  msg);%0A%09

reorder log methods