mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
add timestamps to logs where older OS doesn't provide
This commit is contained in:
parent
2e5f6128f2
commit
f0a05c004c
1 changed files with 12 additions and 0 deletions
|
@ -25,6 +25,7 @@ import android.content.Context;
|
|||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.Process;
|
||||
|
||||
|
@ -62,6 +63,13 @@ public class Log {
|
|||
private static boolean sUseDB;
|
||||
private static WeakReference<Context> sContextRef;
|
||||
|
||||
private static SimpleDateFormat sTSFormatter;
|
||||
static {
|
||||
if ( Build.VERSION_CODES.LOLLIPOP >= Build.VERSION.SDK_INT ) {
|
||||
sTSFormatter = new SimpleDateFormat(" MM-dd HH:mm:ss.SSS ");
|
||||
}
|
||||
}
|
||||
|
||||
private static enum LOG_LEVEL {
|
||||
INFO,
|
||||
ERROR,
|
||||
|
@ -158,6 +166,10 @@ public class Log {
|
|||
{
|
||||
String str = new Formatter().format( fmt, args ).toString();
|
||||
String fullTag = PRE_TAG + tag;
|
||||
if ( null != sTSFormatter ) {
|
||||
fullTag = sTSFormatter.format(new Date()) + fullTag;
|
||||
}
|
||||
|
||||
switch ( level ) {
|
||||
case DEBUG:
|
||||
android.util.Log.d( fullTag, str );
|
||||
|
|
Loading…
Reference in a new issue