From d70f8ac01d51cf358fe7e4fcd6348376c29fdbb6 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Thu, 6 Mar 2014 12:42:58 -0500 Subject: [PATCH] Clean up debug logging --- .../io/appium/android/bootstrap/handler/TouchDown.java | 5 ++--- .../appium/android/bootstrap/handler/TouchEvent.java | 10 ++++++++++ .../android/bootstrap/handler/TouchLongClick.java | 3 +-- .../io/appium/android/bootstrap/handler/TouchMove.java | 5 ++--- .../io/appium/android/bootstrap/handler/TouchUp.java | 5 ++--- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchDown.java b/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchDown.java index ee794e765..65cc61b5f 100644 --- a/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchDown.java +++ b/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchDown.java @@ -15,14 +15,13 @@ public class TouchDown extends TouchEvent { @Override protected boolean executeTouchEvent() throws UiObjectNotFoundException { - Logger.debug("Performing touchDown using element? " + isElement + " x: " - + clickX + ", y: " + clickY); + printEventDebugLine("TouchDown"); try { final Object controller = getController(); final Method touchDown = getMethod("touchDown", controller); return (Boolean) touchDown.invoke(controller, clickX, clickY); } catch (final Exception e) { - Logger.debug("Problem invoking correct touchDown: " + e); + Logger.debug("Problem invoking touchDown: " + e); return false; } } diff --git a/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchEvent.java b/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchEvent.java index be19e11d7..9f7fba863 100644 --- a/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchEvent.java +++ b/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchEvent.java @@ -136,4 +136,14 @@ public abstract class TouchEvent extends CommandHandler { method.setAccessible(true); return method; } + + protected void printEventDebugLine(final String methodName, + final Integer... duration) { + String extra = ""; + if (duration.length > 0) { + extra = ", duration: " + duration[0]; + } + Logger.debug("Performing " + methodName + " using element? " + isElement + + " x: " + clickX + ", y: " + clickY + extra); + } } diff --git a/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchLongClick.java b/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchLongClick.java index 491679dbe..1ecd4cf4c 100644 --- a/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchLongClick.java +++ b/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchLongClick.java @@ -50,8 +50,7 @@ public class TouchLongClick extends TouchEvent { duration = Integer.parseInt(paramDuration.toString()); } - Logger.debug("Performing longClick using element? " + isElement + " x: " - + clickX + ", y: " + clickY + " with duration: " + duration); + printEventDebugLine("TouchLongClick", duration); if (correctLongClick(clickX, clickY, duration)) { return true; } diff --git a/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchMove.java b/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchMove.java index 8012c37ba..2f3e101c1 100644 --- a/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchMove.java +++ b/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchMove.java @@ -15,14 +15,13 @@ public class TouchMove extends TouchEvent { @Override protected boolean executeTouchEvent() throws UiObjectNotFoundException { - Logger.debug("Performing touchMove using element? " + isElement + " x: " - + clickX + ", y: " + clickY); + printEventDebugLine("TouchMove"); try { final Object controller = getController(); final Method touchMove = getMethod("touchMove", controller); return (Boolean) touchMove.invoke(controller, clickX, clickY); } catch (final Exception e) { - Logger.debug("Problem invoking correct touchMove: " + e); + Logger.debug("Problem invoking touchMove: " + e); return false; } } diff --git a/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchUp.java b/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchUp.java index 3431e008c..f043302e8 100644 --- a/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchUp.java +++ b/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/handler/TouchUp.java @@ -15,14 +15,13 @@ public class TouchUp extends TouchEvent { @Override protected boolean executeTouchEvent() throws UiObjectNotFoundException { - Logger.debug("Performing touchUp using element? " + isElement + " x: " - + clickX + ", y: " + clickY); + printEventDebugLine("TouchUp"); try { final Object controller = getController(); final Method touchUp = getMethod("touchUp", controller); return (Boolean) touchUp.invoke(controller, clickX, clickY); } catch (final Exception e) { - Logger.debug("Problem invoking correct touchUp: " + e); + Logger.debug("Problem invoking touchUp: " + e); return false; } }