- Android debug logging organization

This commit is contained in:
Rolzad73
2016-08-04 13:15:49 -04:00
parent b601a549d0
commit 77dfd51b28
2 changed files with 56 additions and 57 deletions

View File

@@ -14,6 +14,7 @@ import android.util.Log;
public class StorageOptions public class StorageOptions
{ {
private static final String TAG = StorageOptions.class.getCanonicalName();
private static ArrayList<String> mMounts = new ArrayList<String>(); private static ArrayList<String> mMounts = new ArrayList<String>();
private static ArrayList<String> mVold = new ArrayList<String>(); private static ArrayList<String> mVold = new ArrayList<String>();
@@ -77,11 +78,11 @@ public class StorageOptions
} catch (FileNotFoundException fnfex) } catch (FileNotFoundException fnfex)
{ {
// if proc/mount doesn't exist we just use // if proc/mount doesn't exist we just use
Log.i(StorageOptions.class.getCanonicalName(), fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point"); Log.i(TAG, fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point");
mMounts.add(defaultMountPoint); mMounts.add(defaultMountPoint);
} catch (Exception e) } catch (Exception e)
{ {
Log.e(StorageOptions.class.getCanonicalName(), e.getMessage() + ": unknown exception while reading mounts file"); Log.e(TAG, e.getMessage() + ": unknown exception while reading mounts file");
mMounts.add(defaultMountPoint); mMounts.add(defaultMountPoint);
} }
} }
@@ -111,11 +112,11 @@ public class StorageOptions
} catch (FileNotFoundException fnfex) } catch (FileNotFoundException fnfex)
{ {
// if proc/mount doesn't exist we just use // if proc/mount doesn't exist we just use
Log.i(StorageOptions.class.getCanonicalName(), fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point"); Log.i(TAG, fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point");
mMounts.add(defaultMountPoint); mMounts.add(defaultMountPoint);
} catch (Exception e) } catch (Exception e)
{ {
Log.e(StorageOptions.class.getCanonicalName(), e.getMessage() + ": unknown exception while reading mounts file"); Log.e(TAG, e.getMessage() + ": unknown exception while reading mounts file");
mMounts.add(defaultMountPoint); mMounts.add(defaultMountPoint);
} }
} }
@@ -144,11 +145,11 @@ public class StorageOptions
} catch (FileNotFoundException fnfex) } catch (FileNotFoundException fnfex)
{ {
// if vold.fstab doesn't exist we use the value gathered from the Environment // if vold.fstab doesn't exist we use the value gathered from the Environment
Log.i(StorageOptions.class.getCanonicalName(), fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point"); Log.i(TAG, fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point");
mMounts.add(defaultMountPoint); mMounts.add(defaultMountPoint);
} catch (Exception e) } catch (Exception e)
{ {
Log.e(StorageOptions.class.getCanonicalName(), e.getMessage() + ": unknown exception while reading mounts file"); Log.e(TAG, e.getMessage() + ": unknown exception while reading mounts file");
mMounts.add(defaultMountPoint); mMounts.add(defaultMountPoint);
} }
} }

View File

@@ -66,12 +66,11 @@ import android.widget.FrameLayout.LayoutParams;
*/ */
public class SDLActivity extends Activity implements OnKeyListener public class SDLActivity extends Activity implements OnKeyListener
{ {
private static final String TAG = SDLActivity.class.getCanonicalName();
//import deck globals //import deck globals
public ArrayList<String> myresult = new ArrayList<String>(); public ArrayList<String> myresult = new ArrayList<String>();
public String myclickedItem = ""; public String myclickedItem = "";
// TAG used for debugging in DDMS
public static String TAG = Activity.class.getCanonicalName();
// Main components // Main components
private static SDLActivity mSingleton; private static SDLActivity mSingleton;
@@ -350,7 +349,7 @@ public class SDLActivity extends Activity implements OnKeyListener
updateStorageLocations(); updateStorageLocations();
} catch (Exception ioex) } catch (Exception ioex)
{ {
Log.e("SDL", "An error occurred in setting up the storage locations."); Log.e(TAG, "An error occurred in setting up the storage locations.");
} }
} }
@@ -495,7 +494,7 @@ public class SDLActivity extends Activity implements OnKeyListener
@Override @Override
protected void onCreate(Bundle savedInstanceState) protected void onCreate(Bundle savedInstanceState)
{ {
// Log.v("SDL", "onCreate()"); //Log.d(TAG, "onCreate()");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// So we can call stuff from static callbacks // So we can call stuff from static callbacks
@@ -530,7 +529,7 @@ public class SDLActivity extends Activity implements OnKeyListener
@Override @Override
protected void onPause() protected void onPause()
{ {
// Log.v("SDL", "onPause()"); // Log.d(TAG, "onPause()");
super.onPause(); super.onPause();
SDLActivity.nativePause(); SDLActivity.nativePause();
} }
@@ -538,7 +537,7 @@ public class SDLActivity extends Activity implements OnKeyListener
@Override @Override
protected void onResume() protected void onResume()
{ {
// Log.v("SDL", "onResume()"); // Log.d(TAG, "onResume()");
super.onResume(); super.onResume();
SDLActivity.nativeResume(); SDLActivity.nativeResume();
} }
@@ -546,8 +545,7 @@ public class SDLActivity extends Activity implements OnKeyListener
@Override @Override
public void onDestroy() public void onDestroy()
{ {
// Log.v("SDL", "onDestroy()"); // Log.d(TAG, "onDestroy()");
super.onDestroy(); super.onDestroy();
mSurface.onDestroy(); mSurface.onDestroy();
} }
@@ -658,7 +656,7 @@ public class SDLActivity extends Activity implements OnKeyListener
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT; int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1); int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
// Log.v("SDL", "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + ((float)sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer"); // Log.d(TAG, "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + ((float)sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");
// Let the user pick a larger buffer if they really want -- but ye // Let the user pick a larger buffer if they really want -- but ye
// gods they probably shouldn't, the minimums are horrifyingly high // gods they probably shouldn't, the minimums are horrifyingly high
@@ -669,7 +667,7 @@ public class SDLActivity extends Activity implements OnKeyListener
audioStartThread(); audioStartThread();
// Log.v("SDL", "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + ((float)mAudioTrack.getSampleRate() / 1000f) + // Log.d(TAG, "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + ((float)mAudioTrack.getSampleRate() / 1000f) +
// "kHz, " + desiredFrames + " frames buffer"); // "kHz, " + desiredFrames + " frames buffer");
if (is16Bit) if (is16Bit)
@@ -717,7 +715,7 @@ public class SDLActivity extends Activity implements OnKeyListener
} }
} else } else
{ {
Log.w("SDL", "SDL audio: error return from write(short)"); Log.w(TAG, "SDL audio: error return from write(short)");
return; return;
} }
} }
@@ -742,7 +740,7 @@ public class SDLActivity extends Activity implements OnKeyListener
} }
} else } else
{ {
Log.w("SDL", "SDL audio: error return from write(short)"); Log.w(TAG, "SDL audio: error return from write(short)");
return; return;
} }
} }
@@ -757,11 +755,11 @@ public class SDLActivity extends Activity implements OnKeyListener
mAudioThread.join(); mAudioThread.join();
} catch (Exception e) } catch (Exception e)
{ {
Log.v("SDL", "Problem stopping audio thread: " + e); Log.e(TAG, "Problem stopping audio thread: " + e);
} }
mAudioThread = null; mAudioThread = null;
// Log.v("SDL", "Finished waiting for audio thread"); // Log.d(TAG, "Finished waiting for audio thread");
} }
if (mAudioTrack != null) if (mAudioTrack != null)
@@ -773,7 +771,7 @@ public class SDLActivity extends Activity implements OnKeyListener
class DownloadFileAsync extends AsyncTask<String, Integer, Long> class DownloadFileAsync extends AsyncTask<String, Integer, Long>
{ {
final String TAG1 = DownloadFileAsync.class.getCanonicalName(); private final String TAG = DownloadFileAsync.class.getCanonicalName();
@Override @Override
protected void onPreExecute() protected void onPreExecute()
@@ -792,7 +790,6 @@ public class SDLActivity extends Activity implements OnKeyListener
try try
{ {
// //
// Prepare the sdcard folders in order to download the resource file // Prepare the sdcard folders in order to download the resource file
// //
@@ -813,7 +810,7 @@ public class SDLActivity extends Activity implements OnKeyListener
conexion.connect(); conexion.connect();
int lengthOfFile = conexion.getContentLength(); int lengthOfFile = conexion.getContentLength();
// Log.d("Wagic - " + TAG1, " Length of file: " + lengthOfFile); // Log.d(TAG, " Length of file: " + lengthOfFile);
input = new BufferedInputStream(url.openStream()); input = new BufferedInputStream(url.openStream());
// create a File object for the output file // create a File object for the output file
@@ -836,8 +833,8 @@ public class SDLActivity extends Activity implements OnKeyListener
{ {
String errorMessage = "An error happened while downloading the resources. It could be that our server is temporarily down, that your device is not connected to a network, or that we cannot write to " + mSingleton.getSystemStorageLocation() + ". Please check your phone settings and try again. For more help please go to http://wagic.net"; String errorMessage = "An error happened while downloading the resources. It could be that our server is temporarily down, that your device is not connected to a network, or that we cannot write to " + mSingleton.getSystemStorageLocation() + ". Please check your phone settings and try again. For more help please go to http://wagic.net";
mSingleton.downloadError(errorMessage); mSingleton.downloadError(errorMessage);
Log.e(TAG1, errorMessage); Log.e(TAG, errorMessage);
Log.e(TAG1, e.getMessage()); Log.e(TAG, e.getMessage());
} }
return Long.valueOf(totalBytes); return Long.valueOf(totalBytes);
@@ -847,7 +844,7 @@ public class SDLActivity extends Activity implements OnKeyListener
{ {
if (progress[0] != mProgressDialog.getProgress()) if (progress[0] != mProgressDialog.getProgress())
{ {
// Log.d("Wagic - " + TAG1, "current progress : " + progress[0]); // Log.d(TAG, "current progress : " + progress[0]);
mProgressDialog.setProgress(progress[0]); mProgressDialog.setProgress(progress[0]);
} }
} }
@@ -920,6 +917,7 @@ public class SDLActivity extends Activity implements OnKeyListener
*/ */
class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnKeyListener, View.OnTouchListener, SensorEventListener class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnKeyListener, View.OnTouchListener, SensorEventListener
{ {
private static final String TAG = SDLSurface.class.getCanonicalName();
// This is what SDL runs in. It invokes SDL_main(), eventually // This is what SDL runs in. It invokes SDL_main(), eventually
private Thread mSDLThread; private Thread mSDLThread;
@@ -959,7 +957,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
SDLActivity.nativeQuit(); SDLActivity.nativeQuit();
Log.v("SDL", "SDL thread terminated"); Log.d(TAG, "SDL thread terminated");
// On exit, tear everything down for a fresh restart next time. // On exit, tear everything down for a fresh restart next time.
System.exit(0); System.exit(0);
@@ -986,7 +984,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
// Called when we have a valid drawing surface // Called when we have a valid drawing surface
public void surfaceCreated(SurfaceHolder holder) public void surfaceCreated(SurfaceHolder holder)
{ {
Log.v("SDL", "surfaceCreated()"); //Log.d(TAG, "surfaceCreated()");
enableSensor(Sensor.TYPE_ACCELEROMETER, true); enableSensor(Sensor.TYPE_ACCELEROMETER, true);
} }
@@ -1006,18 +1004,18 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
mSDLThread.join(); mSDLThread.join();
} catch (Exception e) } catch (Exception e)
{ {
Log.v("SDL", "Problem stopping thread: " + e); Log.e(TAG, "Problem stopping thread: " + e);
} }
mSDLThread = null; mSDLThread = null;
// Log.v("SDL", "Finished waiting for SDL thread"); // Log.d(TAG, "Finished waiting for SDL thread");
} }
} }
// Called when we lose the surface // Called when we lose the surface
public void surfaceDestroyed(SurfaceHolder holder) public void surfaceDestroyed(SurfaceHolder holder)
{ {
Log.v("SDL", "surfaceDestroyed()"); Log.d(TAG, "surfaceDestroyed()");
synchronized (mSemSurface) synchronized (mSemSurface)
{ {
mSurfaceValid = false; mSurfaceValid = false;
@@ -1029,51 +1027,51 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
// Called when the surface is resized // Called when the surface is resized
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
{ {
Log.d("SDL", "surfaceChanged()"); Log.d(TAG, "surfaceChanged()");
int sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 by default int sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 by default
switch (format) switch (format)
{ {
case PixelFormat.A_8: case PixelFormat.A_8:
Log.d("SDL", "pixel format A_8"); Log.d("TAG", "pixel format A_8");
break; break;
case PixelFormat.LA_88: case PixelFormat.LA_88:
Log.d("SDL", "pixel format LA_88"); Log.d("TAG", "pixel format LA_88");
break; break;
case PixelFormat.L_8: case PixelFormat.L_8:
Log.d("SDL", "pixel format L_8"); Log.d("TAG", "pixel format L_8");
break; break;
case PixelFormat.RGBA_4444: case PixelFormat.RGBA_4444:
Log.d("SDL", "pixel format RGBA_4444"); Log.d("TAG", "pixel format RGBA_4444");
sdlFormat = 0x85421002; // SDL_PIXELFORMAT_RGBA4444 sdlFormat = 0x85421002; // SDL_PIXELFORMAT_RGBA4444
break; break;
case PixelFormat.RGBA_5551: case PixelFormat.RGBA_5551:
Log.d("SDL", "pixel format RGBA_5551"); Log.d(TAG, "pixel format RGBA_5551");
sdlFormat = 0x85441002; // SDL_PIXELFORMAT_RGBA5551 sdlFormat = 0x85441002; // SDL_PIXELFORMAT_RGBA5551
break; break;
case PixelFormat.RGBA_8888: case PixelFormat.RGBA_8888:
Log.d("SDL", "pixel format RGBA_8888"); Log.d(TAG, "pixel format RGBA_8888");
sdlFormat = 0x86462004; // SDL_PIXELFORMAT_RGBA8888 sdlFormat = 0x86462004; // SDL_PIXELFORMAT_RGBA8888
break; break;
case PixelFormat.RGBX_8888: case PixelFormat.RGBX_8888:
Log.d("SDL", "pixel format RGBX_8888"); Log.d(TAG, "pixel format RGBX_8888");
sdlFormat = 0x86262004; // SDL_PIXELFORMAT_RGBX8888 sdlFormat = 0x86262004; // SDL_PIXELFORMAT_RGBX8888
break; break;
case PixelFormat.RGB_332: case PixelFormat.RGB_332:
Log.d("SDL", "pixel format RGB_332"); Log.d(TAG, "pixel format RGB_332");
sdlFormat = 0x84110801; // SDL_PIXELFORMAT_RGB332 sdlFormat = 0x84110801; // SDL_PIXELFORMAT_RGB332
break; break;
case PixelFormat.RGB_565: case PixelFormat.RGB_565:
Log.d("SDL", "pixel format RGB_565"); Log.d(TAG, "pixel format RGB_565");
sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565
break; break;
case PixelFormat.RGB_888: case PixelFormat.RGB_888:
Log.d("SDL", "pixel format RGB_888"); Log.d(TAG, "pixel format RGB_888");
// Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead? // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead?
sdlFormat = 0x86161804; // SDL_PIXELFORMAT_RGB888 sdlFormat = 0x86161804; // SDL_PIXELFORMAT_RGB888
break; break;
default: default:
Log.d("SDL", "pixel format unknown " + format); Log.d(TAG, "pixel format unknown " + format);
break; break;
} }
SDLActivity.onNativeResize(width, height, sdlFormat); SDLActivity.onNativeResize(width, height, sdlFormat);
@@ -1090,7 +1088,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
// EGL functions // EGL functions
public boolean initEGL(int majorVersion, int minorVersion) public boolean initEGL(int majorVersion, int minorVersion)
{ {
Log.d("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion); Log.d(TAG, "Starting up OpenGL ES " + majorVersion + "." + minorVersion);
try try
{ {
@@ -1119,7 +1117,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
int[] num_config = new int[1]; int[] num_config = new int[1];
if (!egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config) || num_config[0] == 0) if (!egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config) || num_config[0] == 0)
{ {
Log.e("SDL", "No EGL config available"); Log.e(TAG, "No EGL config available");
return false; return false;
} }
mEGLConfig = configs[0]; mEGLConfig = configs[0];
@@ -1127,7 +1125,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
EGLContext ctx = egl.eglCreateContext(dpy, mEGLConfig, EGL10.EGL_NO_CONTEXT, null); EGLContext ctx = egl.eglCreateContext(dpy, mEGLConfig, EGL10.EGL_NO_CONTEXT, null);
if (ctx == EGL10.EGL_NO_CONTEXT) if (ctx == EGL10.EGL_NO_CONTEXT)
{ {
Log.e("SDL", "Couldn't create context"); Log.e(TAG, "Couldn't create context");
return false; return false;
} }
@@ -1141,10 +1139,10 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
} catch (Exception e) } catch (Exception e)
{ {
Log.e("SDL", e + ""); Log.e(TAG, e + "");
for (StackTraceElement s : e.getStackTrace()) for (StackTraceElement s : e.getStackTrace())
{ {
Log.e("SDL", s.toString()); Log.e(TAG, s.toString());
} }
} }
@@ -1172,7 +1170,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
mEGLSurface = egl.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, holder, null); mEGLSurface = egl.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, holder, null);
if (mEGLSurface == EGL10.EGL_NO_SURFACE) if (mEGLSurface == EGL10.EGL_NO_SURFACE)
{ {
Log.e("SDL", "Couldn't create surface"); Log.e(TAG, "Couldn't create surface");
return false; return false;
} }
@@ -1181,7 +1179,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
*/ */
if (!egl.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext)) if (!egl.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext))
{ {
Log.e("SDL", "Couldn't make context current"); Log.e(TAG, "Couldn't make context current");
return false; return false;
} }
@@ -1212,10 +1210,10 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
} catch (Exception e) } catch (Exception e)
{ {
Log.e("SDL", "flipEGL(): " + e); Log.e(TAG, "flipEGL(): " + e);
for (StackTraceElement s : e.getStackTrace()) for (StackTraceElement s : e.getStackTrace())
{ {
Log.e("SDL", s.toString()); Log.e(TAG, s.toString());
} }
} }
} }
@@ -1231,12 +1229,12 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK
if (event.getAction() == KeyEvent.ACTION_DOWN) if (event.getAction() == KeyEvent.ACTION_DOWN)
{ {
// Log.d("SDL", "key down: " + keyCode); // Log.d(TAG, "key down: " + keyCode);
SDLActivity.onNativeKeyDown(keyCode); SDLActivity.onNativeKeyDown(keyCode);
return true; return true;
} else if (event.getAction() == KeyEvent.ACTION_UP) } else if (event.getAction() == KeyEvent.ACTION_UP)
{ {
// Log.d("SDL", "key up: " + keyCode); // Log.d(TAG, "key up: " + keyCode);
SDLActivity.onNativeKeyUp(keyCode); SDLActivity.onNativeKeyUp(keyCode);
return true; return true;
} }