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;
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;
}
}

View File

@ -61,6 +61,7 @@ public class ZimHostActivity extends AppCompatActivity implements
private Task<LocationSettingsResponse> 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;
}

View File

@ -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();

View File

@ -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");
}
}