From d25fb5e5df574364dbbcfc73d40819873cfd7a44 Mon Sep 17 00:00:00 2001 From: Adeel Zafar Date: Wed, 7 Aug 2019 05:23:06 +0500 Subject: [PATCH] Refactor Logs Add TAG to every LOG --- .../org/kiwix/kiwixmobile/webserver/WebServerHelper.java | 3 ++- .../org/kiwix/kiwixmobile/webserver/ZimHostActivity.java | 3 ++- .../kiwix/kiwixmobile/wifi_hotspot/HotspotService.java | 5 +++-- .../kiwixmobile/wifi_hotspot/WifiHotspotManager.java | 9 +++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java index eccfd8815..29f098f5b 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java @@ -24,6 +24,7 @@ public class WebServerHelper { int port; private CoordinatorLayout coordinatorLayout; ServerStateListener listener; + String TAG = WebServerHelper.this.getClass().getSimpleName(); public WebServerHelper(Context context) { this.context = context; @@ -94,7 +95,7 @@ public class WebServerHelper { ip += "Something Wrong! " + e.toString() + "\n"; } - Log.v("DANG", "Returning : " + "http://" + ip); + Log.v("TAG", "Returning : " + "http://" + ip); return "http://" + ip; } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostActivity.java index ac07c1989..7d36937f2 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostActivity.java @@ -61,6 +61,7 @@ public class ZimHostActivity extends AppCompatActivity implements private Task task; boolean flag = false; String ip; + String TAG = ZimHostActivity.this.getClass().getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) { @@ -140,7 +141,7 @@ public class ZimHostActivity extends AppCompatActivity implements method.setAccessible(true); enabled = (Boolean) method.invoke(cm); } catch (Exception e) { - Log.e("DANG", e.toString()); + Log.e("TAG", e.toString()); } return enabled; } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/HotspotService.java b/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/HotspotService.java index 682c63a01..a0e4c2459 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/HotspotService.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/HotspotService.java @@ -37,6 +37,7 @@ public class HotspotService extends Service { private NotificationManager notificationManager; private NotificationCompat.Builder builder; ServerStateListener serverStateListener; + String TAG = HotspotService.this.getClass().getSimpleName(); @Override public void onCreate() { super.onCreate(); @@ -83,7 +84,7 @@ public class HotspotService extends Service { } private Notification buildForegroundNotification(String status, boolean showStopButton) { - Log.v("DANG", "Building notification " + status); + Log.v(TAG, "Building notification " + status); builder = new NotificationCompat.Builder(this); builder.setContentTitle("Kiwix Hotspot").setContentText(status); Intent targetIntent = new Intent(this, MainActivity.class); @@ -142,7 +143,7 @@ public class HotspotService extends Service { @RequiresApi(api = Build.VERSION_CODES.O) public static boolean checkHotspotState(Context context) { if (hotspotManager == null) { - Log.v("DANG", "hotspotManager initialized"); + Log.v("TAG", "hotspotManager initialized"); hotspotManager = new WifiHotspotManager(context); } return hotspotManager.checkHotspotState(); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/WifiHotspotManager.java b/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/WifiHotspotManager.java index 4a315611c..8b29c4d12 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/WifiHotspotManager.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/WifiHotspotManager.java @@ -27,6 +27,7 @@ public class WifiHotspotManager { boolean oreoenabled = false; WifiConfiguration currentConfig; ServerStateListener serverStateListener; + String TAG = WifiHotspotManager.this.getClass().getSimpleName(); public WifiHotspotManager(Context context) { this.context = context; @@ -45,7 +46,7 @@ public class WifiHotspotManager { hotspotReservation = reservation; currentConfig = hotspotReservation.getWifiConfiguration(); - Log.v("DANG", "THE PASSWORD IS: " + Log.v(TAG, "THE PASSWORD IS: " + currentConfig.preSharedKey + " \n SSID is : " + currentConfig.SSID); @@ -58,7 +59,7 @@ public class WifiHotspotManager { @Override public void onStopped() { super.onStopped(); - Log.v("DANG", "Local Hotspot Stopped"); + Log.v(TAG, "Local Hotspot Stopped"); serverStateListener = (ServerStateListener) context; serverStateListener.serverStopped(); } @@ -66,7 +67,7 @@ public class WifiHotspotManager { @Override public void onFailed(int reason) { super.onFailed(reason); - Log.v("DANG", "Local Hotspot failed to start"); + Log.v(TAG, "Local Hotspot failed to start"); } }, new Handler()); } @@ -79,7 +80,7 @@ public class WifiHotspotManager { hotspotReservation.close(); hotspotReservation = null; oreoenabled = false; - Log.v("DANG", "Turned off hotspot"); + Log.v(TAG, "Turned off hotspot"); } }