Refactor Logs

Add TAG to every LOG
This commit is contained in:
Adeel Zafar 2019-08-07 05:23:06 +05:00
parent 0cc72f56c4
commit d25fb5e5df
4 changed files with 12 additions and 8 deletions

View File

@ -24,6 +24,7 @@ public class WebServerHelper {
int port; int port;
private CoordinatorLayout coordinatorLayout; private CoordinatorLayout coordinatorLayout;
ServerStateListener listener; ServerStateListener listener;
String TAG = WebServerHelper.this.getClass().getSimpleName();
public WebServerHelper(Context context) { public WebServerHelper(Context context) {
this.context = context; this.context = context;
@ -94,7 +95,7 @@ public class WebServerHelper {
ip += "Something Wrong! " + e.toString() + "\n"; ip += "Something Wrong! " + e.toString() + "\n";
} }
Log.v("DANG", "Returning : " + "http://" + ip); Log.v("TAG", "Returning : " + "http://" + ip);
return "http://" + ip; return "http://" + ip;
} }
} }

View File

@ -61,6 +61,7 @@ public class ZimHostActivity extends AppCompatActivity implements
private Task<LocationSettingsResponse> task; private Task<LocationSettingsResponse> task;
boolean flag = false; boolean flag = false;
String ip; String ip;
String TAG = ZimHostActivity.this.getClass().getSimpleName();
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -140,7 +141,7 @@ public class ZimHostActivity extends AppCompatActivity implements
method.setAccessible(true); method.setAccessible(true);
enabled = (Boolean) method.invoke(cm); enabled = (Boolean) method.invoke(cm);
} catch (Exception e) { } catch (Exception e) {
Log.e("DANG", e.toString()); Log.e("TAG", e.toString());
} }
return enabled; return enabled;
} }

View File

@ -37,6 +37,7 @@ public class HotspotService extends Service {
private NotificationManager notificationManager; private NotificationManager notificationManager;
private NotificationCompat.Builder builder; private NotificationCompat.Builder builder;
ServerStateListener serverStateListener; ServerStateListener serverStateListener;
String TAG = HotspotService.this.getClass().getSimpleName();
@Override public void onCreate() { @Override public void onCreate() {
super.onCreate(); super.onCreate();
@ -83,7 +84,7 @@ public class HotspotService extends Service {
} }
private Notification buildForegroundNotification(String status, boolean showStopButton) { 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 = new NotificationCompat.Builder(this);
builder.setContentTitle("Kiwix Hotspot").setContentText(status); builder.setContentTitle("Kiwix Hotspot").setContentText(status);
Intent targetIntent = new Intent(this, MainActivity.class); Intent targetIntent = new Intent(this, MainActivity.class);
@ -142,7 +143,7 @@ public class HotspotService extends Service {
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
public static boolean checkHotspotState(Context context) { public static boolean checkHotspotState(Context context) {
if (hotspotManager == null) { if (hotspotManager == null) {
Log.v("DANG", "hotspotManager initialized"); Log.v("TAG", "hotspotManager initialized");
hotspotManager = new WifiHotspotManager(context); hotspotManager = new WifiHotspotManager(context);
} }
return hotspotManager.checkHotspotState(); return hotspotManager.checkHotspotState();

View File

@ -27,6 +27,7 @@ public class WifiHotspotManager {
boolean oreoenabled = false; boolean oreoenabled = false;
WifiConfiguration currentConfig; WifiConfiguration currentConfig;
ServerStateListener serverStateListener; ServerStateListener serverStateListener;
String TAG = WifiHotspotManager.this.getClass().getSimpleName();
public WifiHotspotManager(Context context) { public WifiHotspotManager(Context context) {
this.context = context; this.context = context;
@ -45,7 +46,7 @@ public class WifiHotspotManager {
hotspotReservation = reservation; hotspotReservation = reservation;
currentConfig = hotspotReservation.getWifiConfiguration(); currentConfig = hotspotReservation.getWifiConfiguration();
Log.v("DANG", "THE PASSWORD IS: " Log.v(TAG, "THE PASSWORD IS: "
+ currentConfig.preSharedKey + currentConfig.preSharedKey
+ " \n SSID is : " + " \n SSID is : "
+ currentConfig.SSID); + currentConfig.SSID);
@ -58,7 +59,7 @@ public class WifiHotspotManager {
@Override @Override
public void onStopped() { public void onStopped() {
super.onStopped(); super.onStopped();
Log.v("DANG", "Local Hotspot Stopped"); Log.v(TAG, "Local Hotspot Stopped");
serverStateListener = (ServerStateListener) context; serverStateListener = (ServerStateListener) context;
serverStateListener.serverStopped(); serverStateListener.serverStopped();
} }
@ -66,7 +67,7 @@ public class WifiHotspotManager {
@Override @Override
public void onFailed(int reason) { public void onFailed(int reason) {
super.onFailed(reason); super.onFailed(reason);
Log.v("DANG", "Local Hotspot failed to start"); Log.v(TAG, "Local Hotspot failed to start");
} }
}, new Handler()); }, new Handler());
} }
@ -79,7 +80,7 @@ public class WifiHotspotManager {
hotspotReservation.close(); hotspotReservation.close();
hotspotReservation = null; hotspotReservation = null;
oreoenabled = false; oreoenabled = false;
Log.v("DANG", "Turned off hotspot"); Log.v(TAG, "Turned off hotspot");
} }
} }