ANDROID: Unify log prefix

adb logcat ScummVM:\* \*:S
This commit is contained in:
dhewg 2011-02-06 19:37:17 +01:00
parent 8de5edde95
commit bf237c8d2c
6 changed files with 35 additions and 38 deletions

View file

@ -1276,17 +1276,15 @@ void OSystem_Android::addSysArchivesToSearchSet(Common::SearchSet &s,
void OSystem_Android::logMessage(LogMessageType::Type type, const char *message) { void OSystem_Android::logMessage(LogMessageType::Type type, const char *message) {
switch (type) { switch (type) {
case LogMessageType::kDebug: case LogMessageType::kDebug:
BaseBackend::logMessage(type, message); __android_log_write(ANDROID_LOG_DEBUG, LOG_TAG, message);
break; break;
case LogMessageType::kWarning: case LogMessageType::kWarning:
__android_log_write(ANDROID_LOG_WARN, "ScummVM", message); __android_log_write(ANDROID_LOG_WARN, LOG_TAG, message);
break; break;
case LogMessageType::kError: case LogMessageType::kError:
// FIXME: From the name it looks like this will also quit the program. __android_log_write(ANDROID_LOG_ERROR, LOG_TAG, message);
// This shouldn't do that though.
__android_log_assert("Fatal error", "ScummVM", "%s", message);
break; break;
} }
} }

View file

@ -13,6 +13,8 @@ import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
public class PluginProvider extends BroadcastReceiver { public class PluginProvider extends BroadcastReceiver {
private final static String LOG_TAG = "ScummVM";
public final static String META_UNPACK_LIB = public final static String META_UNPACK_LIB =
"org.inodes.gus.scummvm.meta.UNPACK_LIB"; "org.inodes.gus.scummvm.meta.UNPACK_LIB";
@ -28,7 +30,7 @@ public class PluginProvider extends BroadcastReceiver {
.getReceiverInfo(new ComponentName(context, this.getClass()), .getReceiverInfo(new ComponentName(context, this.getClass()),
PackageManager.GET_META_DATA); PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Log.e(this.toString(), "Error finding my own info?", e); Log.e(LOG_TAG, "Error finding my own info?", e);
return; return;
} }

View file

@ -33,7 +33,7 @@ import java.util.LinkedHashMap;
// use the Java versions of most EGL functions :( // use the Java versions of most EGL functions :(
public class ScummVM implements SurfaceHolder.Callback { public class ScummVM implements SurfaceHolder.Callback {
private final static String LOG_TAG = "ScummVM.java"; protected final static String LOG_TAG = "ScummVM";
private final int AUDIO_FRAME_SIZE = 2 * 2; // bytes. 16bit audio * stereo private final int AUDIO_FRAME_SIZE = 2 * 2; // bytes. 16bit audio * stereo
public static class AudioSetupException extends Exception {} public static class AudioSetupException extends Exception {}
@ -106,8 +106,7 @@ public class ScummVM implements SurfaceHolder.Callback {
try { try {
surfaceLock.acquire(); surfaceLock.acquire();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e(this.toString(), Log.e(LOG_TAG, "Interrupted while waiting for surface lock", e);
"Interrupted while waiting for surface lock", e);
} }
} }
@ -151,8 +150,7 @@ public class ScummVM implements SurfaceHolder.Callback {
if (value[0] == EGL10.EGL_NONE) if (value[0] == EGL10.EGL_NONE)
Log.d(LOG_TAG, entry.getKey() + ": NONE"); Log.d(LOG_TAG, entry.getKey() + ": NONE");
else else
Log.d(LOG_TAG, String.format("%s: %d", Log.d(LOG_TAG, String.format("%s: %d", entry.getKey(), value[0]));
entry.getKey(), value[0]));
} }
} }
@ -174,8 +172,7 @@ public class ScummVM implements SurfaceHolder.Callback {
num_config); num_config);
if (false) { if (false) {
Log.d(LOG_TAG, Log.d(LOG_TAG, String.format("Found %d EGL configurations.", numConfigs));
String.format("Found %d EGL configurations.", numConfigs));
for (EGLConfig config : configs) for (EGLConfig config : configs)
dumpEglConfig(config); dumpEglConfig(config);
} }
@ -184,8 +181,7 @@ public class ScummVM implements SurfaceHolder.Callback {
// devices so we have to filter/rank the configs again ourselves. // devices so we have to filter/rank the configs again ourselves.
eglConfig = chooseEglConfig(configs); eglConfig = chooseEglConfig(configs);
if (false) { if (false) {
Log.d(LOG_TAG, Log.d(LOG_TAG, String.format("Chose EGL config from %d possibilities.", numConfigs));
String.format("Chose EGL config from %d possibilities.", numConfigs));
dumpEglConfig(eglConfig); dumpEglConfig(eglConfig);
} }
@ -199,6 +195,7 @@ public class ScummVM implements SurfaceHolder.Callback {
int best = 0; int best = 0;
int bestScore = -1; int bestScore = -1;
int[] value = new int[1]; int[] value = new int[1];
for (int i = 0; i < configs.length; i++) { for (int i = 0; i < configs.length; i++) {
EGLConfig config = configs[i]; EGLConfig config = configs[i];
int score = 10000; int score = 10000;
@ -255,7 +252,7 @@ public class ScummVM implements SurfaceHolder.Callback {
eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig,
nativeSurface, null); nativeSurface, null);
if (eglSurface == EGL10.EGL_NO_SURFACE) if (eglSurface == EGL10.EGL_NO_SURFACE)
Log.e(LOG_TAG, "CreateWindowSurface failed!"); Log.e(LOG_TAG, "CreateWindowSurface failed!");
egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext); egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
GL10 gl = (GL10)eglContext.getGL(); GL10 gl = (GL10)eglContext.getGL();
@ -396,7 +393,7 @@ public class ScummVM implements SurfaceHolder.Callback {
offset += ret; offset += ret;
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e(this.toString(), "Audio thread interrupted", e); Log.e(LOG_TAG, "Audio thread interrupted", e);
} }
} }
} }

View file

@ -73,7 +73,7 @@ public class ScummVMActivity extends Activity {
@Override @Override
protected void displayMessageOnOSD(String msg) { protected void displayMessageOnOSD(String msg) {
Log.i(this.toString(), "OSD: " + msg); Log.i(LOG_TAG, "OSD: " + msg);
Toast.makeText(ScummVMActivity.this, msg, Toast.LENGTH_LONG).show(); Toast.makeText(ScummVMActivity.this, msg, Toast.LENGTH_LONG).show();
} }
@ -137,6 +137,7 @@ public class ScummVMActivity extends Activity {
} }
SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface); SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface);
main_surface.setOnTouchListener(new View.OnTouchListener() { main_surface.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
return onTouchEvent(event); return onTouchEvent(event);
@ -156,7 +157,7 @@ public class ScummVMActivity extends Activity {
try { try {
runScummVM(); runScummVM();
} catch (Exception e) { } catch (Exception e) {
Log.e("ScummVM", "Fatal error in ScummVM thread", e); Log.e(ScummVM.LOG_TAG, "Fatal error in ScummVM thread", e);
new AlertDialog.Builder(ScummVMActivity.this) new AlertDialog.Builder(ScummVMActivity.this)
.setTitle("Error") .setTitle("Error")
.setMessage(e.toString()) .setMessage(e.toString())
@ -174,8 +175,7 @@ public class ScummVMActivity extends Activity {
try { try {
scummvm.waitUntilRunning(); scummvm.waitUntilRunning();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e(this.toString(), Log.e(ScummVM.LOG_TAG, "Interrupted while waiting for ScummVM.initBackend", e);
"Interrupted while waiting for ScummVM.initBackend", e);
finish(); finish();
} }
@ -190,7 +190,7 @@ public class ScummVMActivity extends Activity {
"--config=" + getFileStreamPath("scummvmrc").getPath(), "--config=" + getFileStreamPath("scummvmrc").getPath(),
"--path=" + Environment.getExternalStorageDirectory().getPath(), "--path=" + Environment.getExternalStorageDirectory().getPath(),
"--gui-theme=scummmodern", "--gui-theme=scummmodern",
"--savepath=" + getDir("saves", 0).getPath(), "--savepath=" + getDir("saves", 0).getPath()
}; };
int ret = scummvm.scummVMMain(args); int ret = scummvm.scummVMMain(args);
@ -226,8 +226,7 @@ public class ScummVMActivity extends Activity {
try { try {
scummvm_thread.join(1000); // 1s timeout scummvm_thread.join(1000); // 1s timeout
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.i(this.toString(), Log.i(ScummVM.LOG_TAG, "Error while joining ScummVM thread", e);
"Error while joining ScummVM thread", e);
} }
} }
super.onStop(); super.onStop();

View file

@ -34,6 +34,7 @@ import java.util.zip.ZipFile;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
public class Unpacker extends Activity { public class Unpacker extends Activity {
protected final static String LOG_TAG = "ScummVM";
// TODO don't hardcode this // TODO don't hardcode this
private final static boolean PLUGINS_ENABLED = false; private final static boolean PLUGINS_ENABLED = false;
private final static String META_NEXT_ACTIVITY = private final static String META_NEXT_ACTIVITY =
@ -89,11 +90,11 @@ public class Unpacker extends Activity {
origIntent.getType()); origIntent.getType());
//intent.fillIn(getIntent(), 0); //intent.fillIn(getIntent(), 0);
intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
Log.i(this.toString(), Log.i(LOG_TAG,
"Starting next activity with intent " + intent); "Starting next activity with intent " + intent);
startActivity(intent); startActivity(intent);
} else { } else {
Log.w(this.toString(), Log.w(LOG_TAG,
"Unable to extract a component name from " + nextActivity); "Unable to extract a component name from " + nextActivity);
} }
} }
@ -129,12 +130,12 @@ public class Unpacker extends Activity {
new ZipFile(context.getPackageResourcePath()); new ZipFile(context.getPackageResourcePath());
job = new UnpackJob(zipfile, new HashSet<String>(1)); job = new UnpackJob(zipfile, new HashSet<String>(1));
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Log.e(this.toString(), "Package " + pkg + Log.e(LOG_TAG, "Package " + pkg +
" not found", e); " not found", e);
continue; continue;
} catch (IOException e) { } catch (IOException e) {
// FIXME: show some sort of GUI error dialog // FIXME: show some sort of GUI error dialog
Log.e(this.toString(), Log.e(LOG_TAG,
"Error opening ZIP for package " + pkg, e); "Error opening ZIP for package " + pkg, e);
continue; continue;
} }
@ -146,7 +147,7 @@ public class Unpacker extends Activity {
// Delete stale filenames from mUnpackDest // Delete stale filenames from mUnpackDest
for (File file: mUnpackDest.listFiles()) { for (File file: mUnpackDest.listFiles()) {
if (!all_files.contains(file.getName())) { if (!all_files.contains(file.getName())) {
Log.i(this.toString(), Log.i(LOG_TAG,
"Deleting stale cached file " + file); "Deleting stale cached file " + file);
file.delete(); file.delete();
} }
@ -178,14 +179,14 @@ public class Unpacker extends Activity {
progress += zipentry.getSize(); progress += zipentry.getSize();
} else { } else {
if (dest.exists()) if (dest.exists())
Log.d(this.toString(), Log.d(LOG_TAG,
"Replacing " + dest.getPath() + "Replacing " + dest.getPath() +
" old.mtime=" + dest.lastModified() + " old.mtime=" + dest.lastModified() +
" new.mtime=" + zipentry.getTime() + " new.mtime=" + zipentry.getTime() +
" old.size=" + dest.length() + " old.size=" + dest.length() +
" new.size=" + zipentry.getSize()); " new.size=" + zipentry.getSize());
else else
Log.i(this.toString(), Log.i(LOG_TAG,
"Extracting " + zipentry.getName() + "Extracting " + zipentry.getName() +
" from " + zipfile.getName() + " from " + zipfile.getName() +
" to " + dest.getPath()); " to " + dest.getPath());
@ -216,12 +217,12 @@ public class Unpacker extends Activity {
zipfile.close(); zipfile.close();
} catch (IOException e) { } catch (IOException e) {
// FIXME: show some sort of GUI error dialog // FIXME: show some sort of GUI error dialog
Log.e(this.toString(), "Error unpacking plugin", e); Log.e(LOG_TAG, "Error unpacking plugin", e);
} }
} }
if (progress != total_size) if (progress != total_size)
Log.d(this.toString(), "Ended with progress " + progress + Log.d(LOG_TAG, "Ended with progress " + progress +
" != total size " + total_size); " != total size " + total_size);
setResult(RESULT_OK); setResult(RESULT_OK);
@ -235,7 +236,7 @@ public class Unpacker extends Activity {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (!intent.getAction() if (!intent.getAction()
.equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) { .equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) {
Log.e(this.toString(), Log.e(LOG_TAG,
"Received unexpected action " + intent.getAction()); "Received unexpected action " + intent.getAction());
return; return;
} }
@ -324,7 +325,7 @@ public class Unpacker extends Activity {
startActivityForResult(market_intent, startActivityForResult(market_intent,
REQUEST_MARKET); REQUEST_MARKET);
} catch (ActivityNotFoundException e) { } catch (ActivityNotFoundException e) {
Log.e(this.toString(), Log.e(LOG_TAG,
"Error starting market", e); "Error starting market", e);
} }
} }
@ -352,7 +353,7 @@ public class Unpacker extends Activity {
switch (requestCode) { switch (requestCode) {
case REQUEST_MARKET: case REQUEST_MARKET:
if (resultCode != RESULT_OK) if (resultCode != RESULT_OK)
Log.w(this.toString(), "Market returned " + resultCode); Log.w(LOG_TAG, "Market returned " + resultCode);
tryUnpack(); tryUnpack();
break; break;
} }
@ -364,7 +365,7 @@ public class Unpacker extends Activity {
.getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); .getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
return ai.metaData; return ai.metaData;
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Log.w(this.toString(), "Unable to find my own meta-data", e); Log.w(LOG_TAG, "Unable to find my own meta-data", e);
return new Bundle(); return new Bundle();
} }
} }

View file

@ -44,7 +44,7 @@
#define TEXSUBIMAGE_IS_EXPENSIVE 0 #define TEXSUBIMAGE_IS_EXPENSIVE 0
#undef LOG_TAG #undef LOG_TAG
#define LOG_TAG "ScummVM-video" #define LOG_TAG "ScummVM"
#if 0 #if 0
#define ENTER(args...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, args) #define ENTER(args...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, args)