package com.sl.games;
import android.util.Log;
public class SLLog
{
private static String TAG = "com.sl.games";
private static String INFOTAG = "SL";
private static SLLog log;
public static SLLog getInstance()
{
if(log == null)
{
log = new SLLog();
}
return log;
}
private String getFunName()
{
StackTraceElement[] stes = Thread.currentThread().getStackTrace();
if(stes == null)
{
return null;
}
for (StackTraceElement ste : stes)
{
//Ingore java call other language error information
if(ste.isNativeMethod())
{
continue;
}
if(ste.getClassName().equals(Thread.class.getName()))
{
continue;
}
if(!ste.getClassName().equals(super.getClass().getName()))
{
return "[" + Thread.currentThread().getId() + ":" + ste.getFileName() + ":" + ste.getLineNumber() + "]";
}
}
return null;
}
public synchronized void d(Object obj)
{
try
{
if(obj != null)
{
String funName = getFunName();
String info = funName + ":" + obj.toString();
Log.d(TAG, INFOTAG + info);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public synchronized void e(Exception exception)
{
try
{
Log.e(TAG, INFOTAG, exception);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public synchronized void e(Object obj)
{
try
{
if(obj != null)
{
String funName = getFunName();
String info = funName + ":" + obj.toString();
Log.e(TAG, INFOTAG + info);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public synchronized void i(Object obj)
{
try
{
if(obj != null)
{
String funName = getFunName();
String info = funName + ":" + obj.toString();
Log.i(TAG, INFOTAG + info);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public synchronized void v(Object obj)
{
try
{
if(obj != null)
{
String funName = getFunName();
String info = funName + ":" + obj.toString();
Log.v(TAG, INFOTAG + info);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public synchronized void w(Object obj)
{
try
{
if(obj != null)
{
String funName = getFunName();
String info = funName + ":" + obj.toString();
Log.w(TAG, INFOTAG + info);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
import android.util.Log;
public class SLLog
{
private static String TAG = "com.sl.games";
private static String INFOTAG = "SL";
private static SLLog log;
public static SLLog getInstance()
{
if(log == null)
{
log = new SLLog();
}
return log;
}
private String getFunName()
{
StackTraceElement[] stes = Thread.currentThread().getStackTrace();
if(stes == null)
{
return null;
}
for (StackTraceElement ste : stes)
{
//Ingore java call other language error information
if(ste.isNativeMethod())
{
continue;
}
if(ste.getClassName().equals(Thread.class.getName()))
{
continue;
}
if(!ste.getClassName().equals(super.getClass().getName()))
{
return "[" + Thread.currentThread().getId() + ":" + ste.getFileName() + ":" + ste.getLineNumber() + "]";
}
}
return null;
}
public synchronized void d(Object obj)
{
try
{
if(obj != null)
{
String funName = getFunName();
String info = funName + ":" + obj.toString();
Log.d(TAG, INFOTAG + info);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public synchronized void e(Exception exception)
{
try
{
Log.e(TAG, INFOTAG, exception);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public synchronized void e(Object obj)
{
try
{
if(obj != null)
{
String funName = getFunName();
String info = funName + ":" + obj.toString();
Log.e(TAG, INFOTAG + info);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public synchronized void i(Object obj)
{
try
{
if(obj != null)
{
String funName = getFunName();
String info = funName + ":" + obj.toString();
Log.i(TAG, INFOTAG + info);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public synchronized void v(Object obj)
{
try
{
if(obj != null)
{
String funName = getFunName();
String info = funName + ":" + obj.toString();
Log.v(TAG, INFOTAG + info);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public synchronized void w(Object obj)
{
try
{
if(obj != null)
{
String funName = getFunName();
String info = funName + ":" + obj.toString();
Log.w(TAG, INFOTAG + info);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}