Merge pull request #3497 from sigmabeta/android-log-refactor

[Android] Refactor logging
This commit is contained in:
Ryan Houdek 2016-01-12 10:05:51 -05:00
commit 8709e8d2c7
15 changed files with 141 additions and 92 deletions

View File

@ -6,11 +6,12 @@
package org.dolphinemu.dolphinemu; package org.dolphinemu.dolphinemu;
import android.util.Log;
import android.view.Surface; import android.view.Surface;
import android.widget.Toast; import android.widget.Toast;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.utils.Log;
/** /**
* Class which contains methods that interact * Class which contains methods that interact
@ -393,7 +394,7 @@ public final class NativeLibrary
} }
catch (UnsatisfiedLinkError ex) catch (UnsatisfiedLinkError ex)
{ {
Log.e("NativeLibrary", ex.toString()); Log.error("[NativeLibrary] " + ex.toString());
} }
CacheClassesAndMethods(); CacheClassesAndMethods();
@ -401,7 +402,7 @@ public final class NativeLibrary
public static void displayAlertMsg(final String alert) public static void displayAlertMsg(final String alert)
{ {
Log.e("DolphinEmu", "Alert: " + alert); Log.error("[NativeLibrary] Alert: " + alert);
mEmulationActivity.runOnUiThread(new Runnable() mEmulationActivity.runOnUiThread(new Runnable()
{ {
@Override @Override
@ -414,13 +415,13 @@ public final class NativeLibrary
public static void endEmulationActivity() public static void endEmulationActivity()
{ {
Log.v("DolphinEmu", "Ending EmulationActivity."); Log.verbose("[NativeLibrary]Ending EmulationActivity.");
mEmulationActivity.exitWithAnimation(); mEmulationActivity.exitWithAnimation();
} }
public static void setEmulationActivity(EmulationActivity emulationActivity) public static void setEmulationActivity(EmulationActivity emulationActivity)
{ {
Log.v("DolphinEmu", "Registering EmulationActivity."); Log.verbose("[NativeLibrary]Registering EmulationActivity.");
mEmulationActivity = emulationActivity; mEmulationActivity = emulationActivity;
} }
} }

View File

@ -8,7 +8,6 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.InputDevice; import android.view.InputDevice;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
@ -33,6 +32,7 @@ import org.dolphinemu.dolphinemu.fragments.LoadStateFragment;
import org.dolphinemu.dolphinemu.fragments.MenuFragment; import org.dolphinemu.dolphinemu.fragments.MenuFragment;
import org.dolphinemu.dolphinemu.fragments.SaveStateFragment; import org.dolphinemu.dolphinemu.fragments.SaveStateFragment;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter; import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.utils.Log;
import java.util.List; import java.util.List;
@ -211,7 +211,7 @@ public final class EmulationActivity extends AppCompatActivity
protected void onStart() protected void onStart()
{ {
super.onStart(); super.onStart();
Log.d("DolphinEmu", "EmulationActivity starting."); Log.debug("[EmulationActivity] EmulationActivity starting.");
NativeLibrary.setEmulationActivity(this); NativeLibrary.setEmulationActivity(this);
} }
@ -219,7 +219,7 @@ public final class EmulationActivity extends AppCompatActivity
protected void onStop() protected void onStop()
{ {
super.onStop(); super.onStop();
Log.d("DolphinEmu", "EmulationActivity stopping."); Log.debug("[EmulationActivity] EmulationActivity stopping.");
NativeLibrary.setEmulationActivity(null); NativeLibrary.setEmulationActivity(null);
} }
@ -650,14 +650,14 @@ public final class EmulationActivity extends AppCompatActivity
} }
else else
{ {
Log.e("DolphinEmu", "[EmulationActivity] Fragment not found, can't remove."); Log.error("[EmulationActivity] Fragment not found, can't remove.");
} }
mSubmenuFragmentTag = null; mSubmenuFragmentTag = null;
} }
else else
{ {
Log.e("DolphinEmu", "[EmulationActivity] Fragment Tag empty."); Log.error("[EmulationActivity] Fragment Tag empty.");
} }
} }

View File

@ -5,10 +5,10 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import org.dolphinemu.dolphinemu.fragments.SettingsFragment; import org.dolphinemu.dolphinemu.fragments.SettingsFragment;
import org.dolphinemu.dolphinemu.services.SettingsSaveService; import org.dolphinemu.dolphinemu.services.SettingsSaveService;
import org.dolphinemu.dolphinemu.utils.Log;
public final class SettingsActivity extends AppCompatActivity public final class SettingsActivity extends AppCompatActivity
{ {
@ -33,7 +33,7 @@ public final class SettingsActivity extends AppCompatActivity
{ {
super.onStop(); super.onStop();
Log.d("DolphinEmulator", "Settings activity stopping. Saving settings to INI..."); Log.debug("[SettingsActivity] Settings activity stopping. Saving settings to INI...");
// Copy assets into appropriate locations. // Copy assets into appropriate locations.
Intent settingsSaver = new Intent(this, SettingsSaveService.class); Intent settingsSaver = new Intent(this, SettingsSaveService.class);

View File

@ -6,7 +6,6 @@ import android.database.DataSetObserver;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Rect; import android.graphics.Rect;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -17,6 +16,7 @@ import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.dialogs.GameDetailsDialog; import org.dolphinemu.dolphinemu.dialogs.GameDetailsDialog;
import org.dolphinemu.dolphinemu.model.GameDatabase; import org.dolphinemu.dolphinemu.model.GameDatabase;
import org.dolphinemu.dolphinemu.utils.Log;
import org.dolphinemu.dolphinemu.viewholders.GameViewHolder; import org.dolphinemu.dolphinemu.viewholders.GameViewHolder;
/** /**
@ -106,12 +106,12 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
} }
else else
{ {
Log.e("DolphinEmu", "Can't bind view; Cursor is not valid."); Log.error("[GameAdapter] Can't bind view; Cursor is not valid.");
} }
} }
else else
{ {
Log.e("DolphinEmu", "Can't bind view; dataset is not valid."); Log.error("[GameAdapter] Can't bind view; dataset is not valid.");
} }
} }
@ -127,7 +127,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
{ {
return mCursor.getCount(); return mCursor.getCount();
} }
Log.e("DolphinEmu", "Dataset is not valid."); Log.error("[GameAdapter] Dataset is not valid.");
return 0; return 0;
} }
@ -148,7 +148,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
} }
} }
Log.e("DolphinEmu", "Dataset is not valid."); Log.error("[GameAdapter] Dataset is not valid.");
return 0; return 0;
} }

View File

@ -5,12 +5,12 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.view.InputDevice; import android.view.InputDevice;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.utils.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -43,7 +43,7 @@ public final class MotionAlertDialog extends AlertDialog
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) public boolean onKeyDown(int keyCode, KeyEvent event)
{ {
Log.d("InputConfigFragment", "Received key event: " + event.getAction()); Log.debug("[MotionAlertDialog] Received key event: " + event.getAction());
switch (event.getAction()) switch (event.getAction())
{ {
case KeyEvent.ACTION_DOWN: case KeyEvent.ACTION_DOWN:
@ -67,7 +67,7 @@ public final class MotionAlertDialog extends AlertDialog
if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0)
return false; return false;
Log.d("InputConfigFragment", "Received motion event: " + event.getAction()); Log.debug("[MotionAlertDialog] Received motion event: " + event.getAction());
InputDevice input = event.getDevice(); InputDevice input = event.getDevice();
List<InputDevice.MotionRange> motions = input.getMotionRanges(); List<InputDevice.MotionRange> motions = input.getMotionRanges();
@ -160,7 +160,7 @@ public final class MotionAlertDialog extends AlertDialog
} }
else else
{ {
Log.e("DolphinEmu", "Failed to save input to INI."); Log.error("[MotionAlertDialog] Failed to save input to INI.");
} }
@ -176,7 +176,7 @@ public final class MotionAlertDialog extends AlertDialog
} }
else else
{ {
Log.e("DolphinEmu", "Failed to save input to preference."); Log.error("[MotionAlertDialog] Failed to save input to preference.");
} }
dismiss(); dismiss();

View File

@ -4,7 +4,6 @@ import android.app.Fragment;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Surface; import android.view.Surface;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
@ -16,6 +15,7 @@ import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.overlay.InputOverlay; import org.dolphinemu.dolphinemu.overlay.InputOverlay;
import org.dolphinemu.dolphinemu.utils.Log;
public final class EmulationFragment extends Fragment implements SurfaceHolder.Callback public final class EmulationFragment extends Fragment implements SurfaceHolder.Callback
@ -151,13 +151,13 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
@Override @Override
public void surfaceCreated(SurfaceHolder holder) public void surfaceCreated(SurfaceHolder holder)
{ {
Log.d("DolphinEmu", "Surface created."); Log.debug("[EmulationFragment] Surface created.");
} }
@Override @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
{ {
Log.d("DolphinEmu", "Surface changed. Resolution: " + width + "x" + height); Log.debug("[EmulationFragment] Surface changed. Resolution: " + width + "x" + height);
mSurface = holder.getSurface(); mSurface = holder.getSurface();
NativeLibrary.SurfaceChanged(mSurface); NativeLibrary.SurfaceChanged(mSurface);
} }
@ -165,7 +165,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
@Override @Override
public void surfaceDestroyed(SurfaceHolder holder) public void surfaceDestroyed(SurfaceHolder holder)
{ {
Log.d("DolphinEmu", "Surface destroyed."); Log.debug("[EmulationFragment] Surface destroyed.");
NativeLibrary.SurfaceDestroyed(); NativeLibrary.SurfaceDestroyed();
if (mEmulationRunning) if (mEmulationRunning)
@ -178,13 +178,13 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
{ {
if (!mEmulationStarted) if (!mEmulationStarted)
{ {
Log.d("DolphinEmu", "Starting emulation thread."); Log.debug("[EmulationFragment] Starting emulation thread.");
mEmulationThread.start(); mEmulationThread.start();
} }
else else
{ {
Log.d("DolphinEmu", "Resuming emulation."); Log.debug("[EmulationFragment] Resuming emulation.");
NativeLibrary.UnPauseEmulation(); NativeLibrary.UnPauseEmulation();
} }
@ -193,7 +193,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
private void pauseEmulation() private void pauseEmulation()
{ {
Log.d("DolphinEmu", "Pausing emulation."); Log.debug("[EmulationFragment] Pausing emulation.");
NativeLibrary.PauseEmulation(); NativeLibrary.PauseEmulation();
mEmulationRunning = false; mEmulationRunning = false;
@ -221,7 +221,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
if (!mEmulationRunning) if (!mEmulationRunning)
return; return;
Log.i("DolphinEmu", "Starting emulation: " + mSurface); Log.info("[EmulationFragment] Starting emulation: " + mSurface);
// Start emulation using the provided Surface. // Start emulation using the provided Surface.
NativeLibrary.Run(); NativeLibrary.Run();

View File

@ -5,9 +5,9 @@ import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.utils.Log;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
@ -88,27 +88,27 @@ public final class GameDatabase extends SQLiteOpenHelper
@Override @Override
public void onCreate(SQLiteDatabase database) public void onCreate(SQLiteDatabase database)
{ {
Log.d("DolphinEmu", "GameDatabase - Creating database..."); Log.debug("[GameDatabase] GameDatabase - Creating database...");
Log.v("DolphinEmu", "Executing SQL: " + SQL_CREATE_GAMES); Log.verbose("[GameDatabase] Executing SQL: " + SQL_CREATE_GAMES);
database.execSQL(SQL_CREATE_GAMES); database.execSQL(SQL_CREATE_GAMES);
Log.v("DolphinEmu", "Executing SQL: " + SQL_CREATE_FOLDERS); Log.verbose("[GameDatabase] Executing SQL: " + SQL_CREATE_FOLDERS);
database.execSQL(SQL_CREATE_FOLDERS); database.execSQL(SQL_CREATE_FOLDERS);
} }
@Override @Override
public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion)
{ {
Log.i("DolphinEmu", "Upgrading database from schema version " + oldVersion + " to " + newVersion); Log.info("[GameDatabase] Upgrading database from schema version " + oldVersion + " to " + newVersion);
Log.v("DolphinEmu", "Executing SQL: " + SQL_DELETE_GAMES); Log.verbose("[GameDatabase] Executing SQL: " + SQL_DELETE_GAMES);
database.execSQL(SQL_DELETE_GAMES); database.execSQL(SQL_DELETE_GAMES);
Log.v("DolphinEmu", "Executing SQL: " + SQL_CREATE_GAMES); Log.verbose("[GameDatabase] Executing SQL: " + SQL_CREATE_GAMES);
database.execSQL(SQL_CREATE_GAMES); database.execSQL(SQL_CREATE_GAMES);
Log.v("DolphinEmu", "Re-scanning library with new schema."); Log.verbose("[GameDatabase] Re-scanning library with new schema.");
scanLibrary(database); scanLibrary(database);
} }
@ -133,7 +133,7 @@ public final class GameDatabase extends SQLiteOpenHelper
if (!game.exists()) if (!game.exists())
{ {
Log.e("DolphinEmu", "Game file no longer exists. Removing from the library: " + gamePath); Log.error("[GameDatabase] Game file no longer exists. Removing from the library: " + gamePath);
database.delete(TABLE_NAME_GAMES, database.delete(TABLE_NAME_GAMES,
KEY_DB_ID + " = ?", KEY_DB_ID + " = ?",
new String[]{Long.toString(fileCursor.getLong(COLUMN_DB_ID))}); new String[]{Long.toString(fileCursor.getLong(COLUMN_DB_ID))});
@ -162,7 +162,7 @@ public final class GameDatabase extends SQLiteOpenHelper
String folderPath = folderCursor.getString(FOLDER_COLUMN_PATH); String folderPath = folderCursor.getString(FOLDER_COLUMN_PATH);
File folder = new File(folderPath); File folder = new File(folderPath);
Log.i("DolphinEmu", "Reading files from library folder: " + folderPath); Log.info("[GameDatabase] Reading files from library folder: " + folderPath);
// Iterate through every file in the folder. // Iterate through every file in the folder.
File[] children = folder.listFiles(); File[] children = folder.listFiles();
@ -225,12 +225,12 @@ public final class GameDatabase extends SQLiteOpenHelper
// If update fails, insert a new game instead. // If update fails, insert a new game instead.
if (rowsMatched == 0) if (rowsMatched == 0)
{ {
Log.v("DolphinEmu", "Adding game: " + game.getAsString(KEY_GAME_TITLE)); Log.verbose("[GameDatabase] Adding game: " + game.getAsString(KEY_GAME_TITLE));
database.insert(TABLE_NAME_GAMES, null, game); database.insert(TABLE_NAME_GAMES, null, game);
} }
else else
{ {
Log.v("DolphinEmu", "Updated game: " + game.getAsString(KEY_GAME_TITLE)); Log.verbose("[GameDatabase] Updated game: " + game.getAsString(KEY_GAME_TITLE));
} }
} }
} }
@ -240,14 +240,14 @@ public final class GameDatabase extends SQLiteOpenHelper
// If the folder is empty because it no longer exists, remove it from the library. // If the folder is empty because it no longer exists, remove it from the library.
else if (!folder.exists()) else if (!folder.exists())
{ {
Log.e("DolphinEmu", "Folder no longer exists. Removing from the library: " + folderPath); Log.error("[GameDatabase] Folder no longer exists. Removing from the library: " + folderPath);
database.delete(TABLE_NAME_FOLDERS, database.delete(TABLE_NAME_FOLDERS,
KEY_DB_ID + " = ?", KEY_DB_ID + " = ?",
new String[]{Long.toString(folderCursor.getLong(COLUMN_DB_ID))}); new String[]{Long.toString(folderCursor.getLong(COLUMN_DB_ID))});
} }
else else
{ {
Log.e("DolphinEmu", "Folder contains no games: " + folderPath); Log.error("[GameDatabase] Folder contains no games: " + folderPath);
} }
} }
@ -263,7 +263,7 @@ public final class GameDatabase extends SQLiteOpenHelper
@Override @Override
public void call(Subscriber<? super Cursor> subscriber) public void call(Subscriber<? super Cursor> subscriber)
{ {
Log.i("DolphinEmu", "[GameDatabase] Reading games list..."); Log.info("[GameDatabase] [GameDatabase] Reading games list...");
String whereClause = null; String whereClause = null;
String[] whereArgs = null; String[] whereArgs = null;

View File

@ -5,9 +5,9 @@ import android.content.ContentValues;
import android.database.Cursor; import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.net.Uri; import android.net.Uri;
import android.util.Log;
import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.utils.Log;
/** /**
* Provides an interface allowing Activities to interact with the SQLite database. * Provides an interface allowing Activities to interact with the SQLite database.
@ -31,7 +31,7 @@ public final class GameProvider extends ContentProvider
@Override @Override
public boolean onCreate() public boolean onCreate()
{ {
Log.i("DolphinEmu", "Creating Content Provider..."); Log.info("[GameProvider] Creating Content Provider...");
mDbHelper = new GameDatabase(getContext()); mDbHelper = new GameDatabase(getContext());
@ -41,7 +41,7 @@ public final class GameProvider extends ContentProvider
@Override @Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
{ {
Log.i("DolphinEmu", "Querying URI: " + uri); Log.info("[GameProvider] Querying URI: " + uri);
SQLiteDatabase db = mDbHelper.getReadableDatabase(); SQLiteDatabase db = mDbHelper.getReadableDatabase();
@ -49,7 +49,7 @@ public final class GameProvider extends ContentProvider
if (table == null) if (table == null)
{ {
Log.e("DolphinEmu", "Badly formatted URI: " + uri); Log.error("[GameProvider] Badly formatted URI: " + uri);
return null; return null;
} }
@ -62,12 +62,12 @@ public final class GameProvider extends ContentProvider
@Override @Override
public String getType(Uri uri) public String getType(Uri uri)
{ {
Log.v("DolphinEmu", "Getting MIME type for URI: " + uri); Log.verbose("[GameProvider] Getting MIME type for URI: " + uri);
String lastSegment = uri.getLastPathSegment(); String lastSegment = uri.getLastPathSegment();
if (lastSegment == null) if (lastSegment == null)
{ {
Log.e("DolphinEmu", "Badly formatted URI: " + uri); Log.error("[GameProvider] Badly formatted URI: " + uri);
return null; return null;
} }
@ -80,14 +80,14 @@ public final class GameProvider extends ContentProvider
return MIME_TYPE_GAME; return MIME_TYPE_GAME;
} }
Log.e("DolphinEmu", "Unknown MIME type for URI: " + uri); Log.error("[GameProvider] Unknown MIME type for URI: " + uri);
return null; return null;
} }
@Override @Override
public Uri insert(Uri uri, ContentValues values) public Uri insert(Uri uri, ContentValues values)
{ {
Log.i("DolphinEmu", "Inserting row at URI: " + uri); Log.info("[GameProvider] Inserting row at URI: " + uri);
SQLiteDatabase database = mDbHelper.getWritableDatabase(); SQLiteDatabase database = mDbHelper.getWritableDatabase();
String table = uri.getLastPathSegment(); String table = uri.getLastPathSegment();
@ -98,7 +98,7 @@ public final class GameProvider extends ContentProvider
{ {
if (table.equals(REFRESH_LIBRARY)) if (table.equals(REFRESH_LIBRARY))
{ {
Log.i("DolphinEmu", "URI specified table REFRESH_LIBRARY. No insertion necessary; refreshing library contents..."); Log.info("[GameProvider] URI specified table REFRESH_LIBRARY. No insertion necessary; refreshing library contents...");
mDbHelper.scanLibrary(database); mDbHelper.scanLibrary(database);
return uri; return uri;
} }
@ -120,12 +120,12 @@ public final class GameProvider extends ContentProvider
} }
else else
{ {
Log.e("DolphinEmu", "Row already exists: " + uri + " id: " + id); Log.error("[GameProvider] Row already exists: " + uri + " id: " + id);
} }
} }
else else
{ {
Log.e("DolphinEmu", "Badly formatted URI: " + uri); Log.error("[GameProvider] Badly formatted URI: " + uri);
} }
database.close(); database.close();
@ -136,14 +136,14 @@ public final class GameProvider extends ContentProvider
@Override @Override
public int delete(Uri uri, String selection, String[] selectionArgs) public int delete(Uri uri, String selection, String[] selectionArgs)
{ {
Log.e("DolphinEmu", "Delete operations unsupported. URI: " + uri); Log.error("[GameProvider] Delete operations unsupported. URI: " + uri);
return 0; return 0;
} }
@Override @Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs)
{ {
Log.e("DolphinEmu", "Update operations unsupported. URI: " + uri); Log.error("[GameProvider] Update operations unsupported. URI: " + uri);
return 0; return 0;
} }
} }

View File

@ -10,9 +10,9 @@ import android.app.IntentService;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.utils.Log;
import org.dolphinemu.dolphinemu.utils.UserPreferences; import org.dolphinemu.dolphinemu.utils.UserPreferences;
import java.io.File; import java.io.File;
@ -27,8 +27,6 @@ import java.io.OutputStream;
*/ */
public final class AssetCopyService extends IntentService public final class AssetCopyService extends IntentService
{ {
private static final String TAG = "DolphinEmulator";
public AssetCopyService() public AssetCopyService()
{ {
// Superclass constructor is called to name the thread on which this service executes. // Superclass constructor is called to name the thread on which this service executes.
@ -55,7 +53,7 @@ public final class AssetCopyService extends IntentService
} }
else else
{ {
Log.v(TAG, "Skipping asset copy operation."); Log.verbose("[AssetCopyService] Skipping asset copy operation.");
} }
// Always copy over the GCPad config in case of change or corruption. // Always copy over the GCPad config in case of change or corruption.
@ -77,7 +75,7 @@ public final class AssetCopyService extends IntentService
private void copyAsset(String asset, String output) private void copyAsset(String asset, String output)
{ {
Log.v(TAG, "Copying " + asset + " to " + output); Log.verbose("[AssetCopyService] Copying " + asset + " to " + output);
InputStream in = null; InputStream in = null;
OutputStream out = null; OutputStream out = null;
@ -91,13 +89,13 @@ public final class AssetCopyService extends IntentService
} }
catch (IOException e) catch (IOException e)
{ {
Log.e(TAG, "Failed to copy asset file: " + asset, e); Log.error("[AssetCopyService] Failed to copy asset file: " + asset + e.getMessage());
} }
} }
private void copyAssetFolder(String assetFolder, String outputFolder) private void copyAssetFolder(String assetFolder, String outputFolder)
{ {
Log.v(TAG, "Copying " + assetFolder + " to " + outputFolder); Log.verbose("[AssetCopyService] Copying " + assetFolder + " to " + outputFolder);
try try
{ {
@ -108,7 +106,7 @@ public final class AssetCopyService extends IntentService
} }
catch (IOException e) catch (IOException e)
{ {
Log.e(TAG, "Failed to copy asset folder: " + assetFolder, e); Log.error("[AssetCopyService] Failed to copy asset folder: " + assetFolder + e.getMessage());
} }
} }

View File

@ -2,8 +2,8 @@ package org.dolphinemu.dolphinemu.services;
import android.app.IntentService; import android.app.IntentService;
import android.content.Intent; import android.content.Intent;
import android.util.Log;
import org.dolphinemu.dolphinemu.utils.Log;
import org.dolphinemu.dolphinemu.utils.UserPreferences; import org.dolphinemu.dolphinemu.utils.UserPreferences;
/** /**
@ -13,8 +13,6 @@ import org.dolphinemu.dolphinemu.utils.UserPreferences;
*/ */
public final class SettingsSaveService extends IntentService public final class SettingsSaveService extends IntentService
{ {
private static final String TAG = "DolphinEmulator";
public SettingsSaveService() public SettingsSaveService()
{ {
super("SettingsSaveService"); super("SettingsSaveService");
@ -23,8 +21,8 @@ public final class SettingsSaveService extends IntentService
@Override @Override
protected void onHandleIntent(Intent intent) protected void onHandleIntent(Intent intent)
{ {
Log.v(TAG, "Saving settings to INI files..."); Log.verbose("[SettingsSaveService] Saving settings to INI files...");
UserPreferences.SavePrefsToIni(this); UserPreferences.SavePrefsToIni(this);
Log.v(TAG, "Save successful."); Log.verbose("[SettingsSaveService] Save successful.");
} }
} }

View File

@ -2,10 +2,10 @@ package org.dolphinemu.dolphinemu.ui.platform;
import android.database.Cursor; import android.database.Cursor;
import android.util.Log;
import org.dolphinemu.dolphinemu.DolphinApplication; import org.dolphinemu.dolphinemu.DolphinApplication;
import org.dolphinemu.dolphinemu.model.GameDatabase; import org.dolphinemu.dolphinemu.model.GameDatabase;
import org.dolphinemu.dolphinemu.utils.Log;
import rx.android.schedulers.AndroidSchedulers; import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1; import rx.functions.Action1;
@ -34,13 +34,13 @@ public final class PlatformGamesPresenter
public void refresh() public void refresh()
{ {
Log.d("DolphinEmu", "[PlatformGamesPresenter] " + mPlatform + ": Refreshing..."); Log.debug("[PlatformGamesPresenter] " + mPlatform + ": Refreshing...");
loadGames(); loadGames();
} }
private void loadGames() private void loadGames()
{ {
Log.d("DolphinEmu", "[PlatformGamesPresenter] " + mPlatform + ": Loading games..."); Log.debug("[PlatformGamesPresenter] " + mPlatform + ": Loading games...");
GameDatabase databaseHelper = DolphinApplication.databaseHelper; GameDatabase databaseHelper = DolphinApplication.databaseHelper;
@ -52,7 +52,7 @@ public final class PlatformGamesPresenter
@Override @Override
public void call(Cursor games) public void call(Cursor games)
{ {
Log.d("DolphinEmu", "[PlatformGamesPresenter] " + mPlatform + ": Load finished, swapping cursor..."); Log.debug("[PlatformGamesPresenter] " + mPlatform + ": Load finished, swapping cursor...");
mView.showGames(games); mView.showGames(games);
} }

View File

@ -1,15 +1,15 @@
package org.dolphinemu.dolphinemu.utils; package org.dolphinemu.dolphinemu.utils;
import android.content.Context;
import android.os.Build;
import org.dolphinemu.dolphinemu.R;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import org.dolphinemu.dolphinemu.R;
import android.content.Context;
import android.os.Build;
import android.util.Log;
/** /**
* Utility class for retrieving information * Utility class for retrieving information
@ -60,12 +60,12 @@ public final class CPUHelper
} }
else else
{ {
Log.e("CPUHelper", "CPU architecture not supported yet."); Log.error("[CPUHelper] CPU architecture not supported yet.");
} }
} }
catch (IOException ioe) catch (IOException ioe)
{ {
Log.e("CPUHelper", ioe.getMessage()); Log.error("[CPUHelper] " + ioe.getMessage());
} }
} }

View File

@ -6,6 +6,10 @@
package org.dolphinemu.dolphinemu.utils; package org.dolphinemu.dolphinemu.utils;
import android.opengl.GLES30;
import org.dolphinemu.dolphinemu.NativeLibrary;
import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLContext;
@ -13,11 +17,6 @@ import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface; import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL10; import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLES30;
import android.util.Log;
import org.dolphinemu.dolphinemu.NativeLibrary;
/** /**
* Utility class that abstracts all the stuff about * Utility class that abstracts all the stuff about
* EGL initialization out of the way if all that is * EGL initialization out of the way if all that is
@ -90,12 +89,12 @@ public final class EGLHelper
} }
else else
{ {
Log.e("EGLHelper", "Error initializing EGL."); Log.error("[EGLHelper] Error initializing EGL.");
} }
} }
else else
{ {
Log.e("EGLHelper", "Error initializing EGL display."); Log.error("[EGLHelper] Error initializing EGL display.");
} }
} }
@ -232,7 +231,7 @@ public final class EGLHelper
int[] numConfigs = new int[1]; int[] numConfigs = new int[1];
if (!mEGL.eglGetConfigs(mDisplay, null, 0, numConfigs)) if (!mEGL.eglGetConfigs(mDisplay, null, 0, numConfigs))
{ {
Log.e("EGLHelper", "Error retrieving number of EGL configs available."); Log.error("[EGLHelper] Error retrieving number of EGL configs available.");
return false; return false;
} }
@ -240,7 +239,7 @@ public final class EGLHelper
mEGLConfigs = new EGLConfig[numConfigs[0]]; mEGLConfigs = new EGLConfig[numConfigs[0]];
if (!mEGL.eglGetConfigs(mDisplay, mEGLConfigs, mEGLConfigs.length, numConfigs)) if (!mEGL.eglGetConfigs(mDisplay, mEGLConfigs, mEGLConfigs.length, numConfigs))
{ {
Log.e("EGLHelper", "Error retrieving all EGL configs."); Log.error("[EGLHelper] Error retrieving all EGL configs.");
return false; return false;
} }

View File

@ -0,0 +1,54 @@
package org.dolphinemu.dolphinemu.utils;
import org.dolphinemu.dolphinemu.BuildConfig;
/**
* Contains methods that call through to {@link android.util.Log}, but
* with the same TAG automatically provided. Also no-ops VERBOSE and DEBUG log
* levels in release builds.
*/
public final class Log
{
private static final String TAG = "Dolphin";
private Log()
{
}
public static void verbose(String message)
{
if (BuildConfig.DEBUG)
{
android.util.Log.v(TAG, message);
}
}
public static void debug(String message)
{
if (BuildConfig.DEBUG)
{
android.util.Log.d(TAG, message);
}
}
public static void info(String message)
{
android.util.Log.i(TAG, message);
}
public static void warning(String message)
{
android.util.Log.w(TAG, message);
}
public static void error(String message)
{
android.util.Log.e(TAG, message);
}
public static void wtf(String message)
{
android.util.Log.wtf(TAG, message);
}
}

View File

@ -6,7 +6,6 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;