Added Log4J for logging to a file
This commit is contained in:
parent
e5ca4aea34
commit
fa69c367e5
18 changed files with 127 additions and 26 deletions
9
.idea/libraries/android_logging_log4j_1_0_3.xml
generated
Executable file
9
.idea/libraries/android_logging_log4j_1_0_3.xml
generated
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="android-logging-log4j-1.0.3">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/libs/android-logging-log4j-1.0.3.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
9
.idea/libraries/log4j_1_2_17.xml
generated
Executable file
9
.idea/libraries/log4j_1_2_17.xml
generated
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="log4j-1.2.17">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/app/libs/log4j-1.2.17.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
|
|
@ -62,7 +62,9 @@
|
||||||
<orderEntry type="jdk" jdkName="Android API 15 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 15 Platform" jdkType="Android SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" exported="" name="GraphView-3.1.2" level="project" />
|
<orderEntry type="library" exported="" name="GraphView-3.1.2" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="android-logging-log4j-1.0.3" level="project" />
|
||||||
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
|
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="log4j-1.2.17" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,4 @@ dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
// You must install or update the Support Repository through the SDK manager to use this dependency.
|
// You must install or update the Support Repository through the SDK manager to use this dependency.
|
||||||
compile 'com.android.support:support-v4:19.1.+'
|
compile 'com.android.support:support-v4:19.1.+'
|
||||||
compile files('libs/GraphView-3.1.2.jar')
|
|
||||||
}
|
}
|
||||||
BIN
app/libs/android-logging-log4j-1.0.3.jar
Normal file
BIN
app/libs/android-logging-log4j-1.0.3.jar
Normal file
Binary file not shown.
BIN
app/libs/log4j-1.2.17.jar
Normal file
BIN
app/libs/log4j-1.2.17.jar
Normal file
Binary file not shown.
|
|
@ -10,6 +10,8 @@
|
||||||
<li>SweetiePlus Icons (<a href="http://sublink.ca/">http://sublink.ca/</a>)</li>
|
<li>SweetiePlus Icons (<a href="http://sublink.ca/">http://sublink.ca/</a>)</li>
|
||||||
<li>DynamicListView (<a href="https://android.googlesource.com">https://android.googlesource.com</a>)</li>
|
<li>DynamicListView (<a href="https://android.googlesource.com">https://android.googlesource.com</a>)</li>
|
||||||
<li>App icon by <a href="http://icons8.com/android-icons">Icons8.com</a></li>
|
<li>App icon by <a href="http://icons8.com/android-icons">Icons8.com</a></li>
|
||||||
|
<li>Android-logging-log4j (<a href="https://code.google.com/p/android-logging-log4j/">https://code.google.com/p/android-logging-log4j/</a>)</li>
|
||||||
|
<li>Log4j (<a href="http://logging.apache.org/log4j">http://logging.apache.org/log4j</a>)</li>
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
package com.ericsson.uecontrol.core;
|
package com.ericsson.uecontrol.core;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Ue behaviours that can be used by the executor
|
* Base class for Ue behaviours that can be used by the executor
|
||||||
*
|
*
|
||||||
* Created by ezivkoc on 2014-07-15.
|
* Created by ezivkoc on 2014-07-15.
|
||||||
*/
|
*/
|
||||||
public abstract class UeBehaviour {
|
public abstract class UeBehaviour {
|
||||||
|
private static final Logger log = Logger.getLogger(UeBehaviour.class);
|
||||||
|
|
||||||
private boolean running;
|
private boolean running;
|
||||||
private BehaviourExecutionListener execListener;
|
private BehaviourExecutionListener execListener;
|
||||||
private DataHandledListener datahandledListener;
|
private DataHandledListener datahandledListener;
|
||||||
|
|
@ -22,7 +26,7 @@ public abstract class UeBehaviour {
|
||||||
execute();
|
execute();
|
||||||
} catch(Exception e){
|
} catch(Exception e){
|
||||||
if(execListener != null) execListener.exception(e);
|
if(execListener != null) execListener.exception(e);
|
||||||
e.printStackTrace();
|
log.warn(null, e);
|
||||||
}
|
}
|
||||||
if(execListener != null) execListener.executionStopped();
|
if(execListener != null) execListener.executionStopped();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package com.ericsson.uecontrol.core;
|
package com.ericsson.uecontrol.core;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.ericsson.uecontrol.core.util.ThroughputCalculator;
|
import com.ericsson.uecontrol.core.util.ThroughputCalculator;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||||
* Created by ezivkoc on 2014-07-15.
|
* Created by ezivkoc on 2014-07-15.
|
||||||
*/
|
*/
|
||||||
public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListener {
|
public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListener {
|
||||||
private static final String TAG = "UeControlExecutor";
|
private static final Logger log = Logger.getLogger(UeControlExecutor.class);
|
||||||
|
|
||||||
private List<UeBehaviour> behaviours;
|
private List<UeBehaviour> behaviours;
|
||||||
private UeBehaviour currentlyActive;
|
private UeBehaviour currentlyActive;
|
||||||
|
|
@ -64,7 +64,7 @@ public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListe
|
||||||
else if (currentlyActive == null)
|
else if (currentlyActive == null)
|
||||||
currentlyActive = behaviours.get(0);
|
currentlyActive = behaviours.get(0);
|
||||||
|
|
||||||
Log.v(TAG, "Running behaviour: " + currentlyActive.getName());
|
log.info("Running behaviour: " + currentlyActive.getName());
|
||||||
currentlyActive.run();
|
currentlyActive.run();
|
||||||
|
|
||||||
int index = behaviours.indexOf(currentlyActive) +1;
|
int index = behaviours.indexOf(currentlyActive) +1;
|
||||||
|
|
@ -73,7 +73,7 @@ public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListe
|
||||||
else
|
else
|
||||||
currentlyActive = null;
|
currentlyActive = null;
|
||||||
}
|
}
|
||||||
Log.v(TAG, "Execution completed");
|
log.info("Execution completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import android.util.Log;
|
||||||
import com.ericsson.uecontrol.core.UeBehaviour;
|
import com.ericsson.uecontrol.core.UeBehaviour;
|
||||||
import com.ericsson.uecontrol.gui.util.Configurator.Configurable;
|
import com.ericsson.uecontrol.gui.util.Configurator.Configurable;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
@ -16,6 +18,7 @@ import java.net.URLConnection;
|
||||||
* Created by ezivkoc on 2014-07-15.
|
* Created by ezivkoc on 2014-07-15.
|
||||||
*/
|
*/
|
||||||
public class UeBehaviourFtp extends UeBehaviour {
|
public class UeBehaviourFtp extends UeBehaviour {
|
||||||
|
private static final Logger log = Logger.getLogger(UeBehaviourFtp.class);
|
||||||
|
|
||||||
@Configurable("Host")
|
@Configurable("Host")
|
||||||
private String host;
|
private String host;
|
||||||
|
|
@ -30,7 +33,7 @@ public class UeBehaviourFtp extends UeBehaviour {
|
||||||
@Override
|
@Override
|
||||||
protected void execute() throws IOException {
|
protected void execute() throws IOException {
|
||||||
URL url = new URL(getFtpUrl());
|
URL url = new URL(getFtpUrl());
|
||||||
Log.v(getClass().getSimpleName(), "Downloading from FTP: " + url);
|
log.debug("Downloading from FTP: " + url);
|
||||||
|
|
||||||
byte[] data = new byte[100];
|
byte[] data = new byte[100];
|
||||||
URLConnection connection = url.openConnection();
|
URLConnection connection = url.openConnection();
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import android.util.Log;
|
||||||
import com.ericsson.uecontrol.core.UeBehaviour;
|
import com.ericsson.uecontrol.core.UeBehaviour;
|
||||||
import com.ericsson.uecontrol.gui.util.Configurator.Configurable;
|
import com.ericsson.uecontrol.gui.util.Configurator.Configurable;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
|
@ -23,6 +25,7 @@ import java.util.regex.Pattern;
|
||||||
* Created by ezivkoc on 2014-07-15.
|
* Created by ezivkoc on 2014-07-15.
|
||||||
*/
|
*/
|
||||||
public class UeBehaviourSurfing extends UeBehaviour {
|
public class UeBehaviourSurfing extends UeBehaviour {
|
||||||
|
private static final Logger log = Logger.getLogger(UeBehaviourSurfing.class);
|
||||||
|
|
||||||
@Configurable("Web Address")
|
@Configurable("Web Address")
|
||||||
private String rootUrl;
|
private String rootUrl;
|
||||||
|
|
@ -50,7 +53,7 @@ public class UeBehaviourSurfing extends UeBehaviour {
|
||||||
for(int i=0; i<urlList.size(); i++) {
|
for(int i=0; i<urlList.size(); i++) {
|
||||||
try {
|
try {
|
||||||
URL url = urlList.get(i);
|
URL url = urlList.get(i);
|
||||||
Log.v(getClass().getSimpleName(), "Downloading: " + url);
|
log.debug("Downloading: " + url);
|
||||||
|
|
||||||
URLConnection connection = url.openConnection();
|
URLConnection connection = url.openConnection();
|
||||||
connection.setUseCaches(false);
|
connection.setUseCaches(false);
|
||||||
|
|
@ -72,7 +75,7 @@ public class UeBehaviourSurfing extends UeBehaviour {
|
||||||
}
|
}
|
||||||
getAdditionalContent(url, content.toString(), urlList);
|
getAdditionalContent(url, content.toString(), urlList);
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
e.printStackTrace();
|
log.warn(null, e);
|
||||||
if(retException == null) retException = e;
|
if(retException == null) retException = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -100,11 +103,12 @@ public class UeBehaviourSurfing extends UeBehaviour {
|
||||||
while(m.find()){
|
while(m.find()){
|
||||||
try {
|
try {
|
||||||
String strUrl = m.group(1);
|
String strUrl = m.group(1);
|
||||||
|
log.debug("Parsing(Regex: "+pattern.pattern()+"): " + strUrl);
|
||||||
URL url = new URL(baseUrl, strUrl);
|
URL url = new URL(baseUrl, strUrl);
|
||||||
if(!urlList.contains(url))
|
if(!urlList.contains(url))
|
||||||
urlList.add(url);
|
urlList.add(url);
|
||||||
}catch(MalformedURLException e){
|
}catch(MalformedURLException e){
|
||||||
e.printStackTrace();
|
log.warn(null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,14 @@ import com.ericsson.uecontrol.gui.util.BehaviourListAdapter;
|
||||||
import com.ericsson.uecontrol.gui.util.Configurator;
|
import com.ericsson.uecontrol.gui.util.Configurator;
|
||||||
import com.ericsson.uecontrol.gui.util.DynamicListView;
|
import com.ericsson.uecontrol.gui.util.DynamicListView;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EditActivity extends ListActivity implements AdapterView.OnItemClickListener {
|
public class EditActivity extends ListActivity implements AdapterView.OnItemClickListener {
|
||||||
|
private static final Logger log = Logger.getLogger(EditActivity.class);
|
||||||
|
|
||||||
private UeControlExecutor executor;
|
private UeControlExecutor executor;
|
||||||
private BehaviourListAdapter adapter;
|
private BehaviourListAdapter adapter;
|
||||||
|
|
||||||
|
|
@ -66,7 +70,7 @@ public class EditActivity extends ListActivity implements AdapterView.OnItemClic
|
||||||
adapter.generateIds();
|
adapter.generateIds();
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.warn(null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
package com.ericsson.uecontrol.gui;
|
package com.ericsson.uecontrol.gui;
|
||||||
|
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
@ -20,8 +24,16 @@ import com.ericsson.uecontrol.gui.fragments.NavigationDrawerFragment;
|
||||||
import com.ericsson.uecontrol.gui.fragments.StatusFragment;
|
import com.ericsson.uecontrol.gui.fragments.StatusFragment;
|
||||||
import com.ericsson.uecontrol.gui.util.CSVWriter;
|
import com.ericsson.uecontrol.gui.util.CSVWriter;
|
||||||
|
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public class MainActivity extends FragmentActivity {
|
import java.io.File;
|
||||||
|
|
||||||
|
import de.mindpipe.android.logging.log4j.LogConfigurator;
|
||||||
|
|
||||||
|
|
||||||
|
public class MainActivity extends FragmentActivity implements OnSharedPreferenceChangeListener{
|
||||||
|
private static final Logger log = Logger.getLogger(MainActivity.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment managing the behaviors, interactions and presentation of the navigation drawer.
|
* Fragment managing the behaviors, interactions and presentation of the navigation drawer.
|
||||||
|
|
@ -31,14 +43,18 @@ public class MainActivity extends FragmentActivity {
|
||||||
private boolean backButtonPressed = false;
|
private boolean backButtonPressed = false;
|
||||||
|
|
||||||
private static UeControlExecutor currentExecutor;
|
private static UeControlExecutor currentExecutor;
|
||||||
private static CSVWriter logger;
|
private static CSVWriter csvLogger;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
|
|
||||||
|
// Setup Debugging
|
||||||
|
setupDebugLogging();
|
||||||
|
|
||||||
|
// Setup Main GUI
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
//navigationDrawerFragment = (NavigationDrawerFragment)
|
//navigationDrawerFragment = (NavigationDrawerFragment)
|
||||||
// getFragmentManager().findFragmentById(R.id.navigation_drawer);
|
// getFragmentManager().findFragmentById(R.id.navigation_drawer);
|
||||||
statusFragment = (StatusFragment)
|
statusFragment = (StatusFragment)
|
||||||
|
|
@ -58,6 +74,37 @@ public class MainActivity extends FragmentActivity {
|
||||||
currentExecutor.setThroughputListener(statusFragment.getThroughputListener());
|
currentExecutor.setThroughputListener(statusFragment.getThroughputListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setupDebugLogging(){
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
String path = prefs.getString("logging_path", "/sdcard/uecontrol/");
|
||||||
|
if(!path.endsWith("/")) path += File.separator;
|
||||||
|
|
||||||
|
LogConfigurator logConfigurator = new LogConfigurator();
|
||||||
|
logConfigurator.setFileName(path + "uecontrol.log");
|
||||||
|
if(prefs.getBoolean("debug", false))
|
||||||
|
logConfigurator.setRootLevel(Level.DEBUG);
|
||||||
|
else
|
||||||
|
logConfigurator.setRootLevel(Level.WARN);
|
||||||
|
// Set log level of a specific logger
|
||||||
|
logConfigurator.setLevel("org.apache", Level.ERROR);
|
||||||
|
logConfigurator.configure();
|
||||||
|
|
||||||
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
|
log.debug("Preference changed: "+key);
|
||||||
|
if(key.equals("debug")) {
|
||||||
|
if (sharedPreferences.getBoolean("debug", false)) {
|
||||||
|
Logger.getRootLogger().setLevel(Level.DEBUG);
|
||||||
|
log.info("Enabling debug logging.");
|
||||||
|
} else {
|
||||||
|
log.info("Disabling debug logging.");
|
||||||
|
Logger.getRootLogger().setLevel(Level.WARN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
|
@ -87,14 +134,14 @@ public class MainActivity extends FragmentActivity {
|
||||||
if(currentExecutor.isRunning()){
|
if(currentExecutor.isRunning()){
|
||||||
currentExecutor.terminate();
|
currentExecutor.terminate();
|
||||||
item.setTitle(R.string.action_run);
|
item.setTitle(R.string.action_run);
|
||||||
logger = null;
|
csvLogger = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
if(prefs.getBoolean("logging", false))
|
if(prefs.getBoolean("logging", false))
|
||||||
logger = new CSVWriter(this);
|
csvLogger = new CSVWriter(this);
|
||||||
else
|
else
|
||||||
logger = null;
|
csvLogger = null;
|
||||||
currentExecutor.execute();
|
currentExecutor.execute();
|
||||||
item.setTitle(R.string.action_stop);
|
item.setTitle(R.string.action_stop);
|
||||||
}
|
}
|
||||||
|
|
@ -117,12 +164,13 @@ public class MainActivity extends FragmentActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logThroughput(double downThroughput, double upThroughput) {
|
public static void logThroughput(double downThroughput, double upThroughput) {
|
||||||
if(logger == null || currentExecutor == null || currentExecutor.getRunningBehaviour() == null)
|
if(csvLogger == null || currentExecutor == null || currentExecutor.getRunningBehaviour() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
logger.write(currentExecutor.getRunningBehaviour().getName(), downThroughput, upThroughput);
|
csvLogger.write(currentExecutor.getRunningBehaviour().getName(), downThroughput, upThroughput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (backButtonPressed) {
|
if (backButtonPressed) {
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,13 @@ import android.os.Bundle;
|
||||||
import com.ericsson.uecontrol.R;
|
import com.ericsson.uecontrol.R;
|
||||||
import com.ericsson.uecontrol.core.UeBehaviour;
|
import com.ericsson.uecontrol.core.UeBehaviour;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class SelectBehaviourDialog extends DialogFragment {
|
public class SelectBehaviourDialog extends DialogFragment {
|
||||||
|
private static final Logger log = Logger.getLogger(SelectBehaviourDialog.class);
|
||||||
public static String[] behaviourClasses;
|
public static String[] behaviourClasses;
|
||||||
public static String[] behaviourNames;
|
public static String[] behaviourNames;
|
||||||
|
|
||||||
|
|
@ -31,7 +34,7 @@ public class SelectBehaviourDialog extends DialogFragment {
|
||||||
UeBehaviour obj = (UeBehaviour) Class.forName(behaviourClasses[i]).newInstance();
|
UeBehaviour obj = (UeBehaviour) Class.forName(behaviourClasses[i]).newInstance();
|
||||||
behaviourNames[i] = obj.getName();
|
behaviourNames[i] = obj.getName();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
log.warn(null, e);
|
||||||
behaviourNames[i] = behaviourClasses[i];
|
behaviourNames[i] = behaviourClasses[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +51,7 @@ public class SelectBehaviourDialog extends DialogFragment {
|
||||||
callback.behaviourSelected(behaviourNames[which], objClass);
|
callback.behaviourSelected(behaviourNames[which], objClass);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.warn(null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import android.net.wifi.WifiManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -19,6 +21,7 @@ import java.text.SimpleDateFormat;
|
||||||
* Created by ezivkoc on 2014-07-30.
|
* Created by ezivkoc on 2014-07-30.
|
||||||
*/
|
*/
|
||||||
public class CSVWriter {
|
public class CSVWriter {
|
||||||
|
private static final Logger log = Logger.getLogger(CSVWriter.class);
|
||||||
public static final String[] HEADINGS = new String[]{
|
public static final String[] HEADINGS = new String[]{
|
||||||
"Timestamp", "Behaviour", "RX Throughput(b/s)", "TX Throughput(b/s)", "RAT"
|
"Timestamp", "Behaviour", "RX Throughput(b/s)", "TX Throughput(b/s)", "RAT"
|
||||||
};
|
};
|
||||||
|
|
@ -36,7 +39,7 @@ public class CSVWriter {
|
||||||
public CSVWriter(Context context){
|
public CSVWriter(Context context){
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
String path = prefs.getString("logging_path", "/sdcard/uecontrol/");
|
String path = prefs.getString("logging_path", "/sdcard/uecontrol/");
|
||||||
if(!path.endsWith("/")) path += "/";
|
if(!path.endsWith(File.separator)) path += File.separator;
|
||||||
file = new File(
|
file = new File(
|
||||||
path,
|
path,
|
||||||
"log_"+fileDateFormater.format(System.currentTimeMillis())+".log");
|
"log_"+fileDateFormater.format(System.currentTimeMillis())+".log");
|
||||||
|
|
@ -77,7 +80,7 @@ public class CSVWriter {
|
||||||
out.println(line);
|
out.println(line);
|
||||||
out.close();
|
out.close();
|
||||||
} catch(IOException e){
|
} catch(IOException e){
|
||||||
e.printStackTrace();
|
log.warn(null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ericsson.uecontrol.gui.util;
|
package com.ericsson.uecontrol.gui.util;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
@ -12,6 +14,7 @@ import java.util.ArrayList;
|
||||||
* Created by ezivkoc on 2014-07-24.
|
* Created by ezivkoc on 2014-07-24.
|
||||||
*/
|
*/
|
||||||
public class Configurator {
|
public class Configurator {
|
||||||
|
private static final Logger log = Logger.getLogger(Configurator.class);
|
||||||
/**
|
/**
|
||||||
* Sets a field in a class as externally configurable.
|
* Sets a field in a class as externally configurable.
|
||||||
*/
|
*/
|
||||||
|
|
@ -48,7 +51,7 @@ public class Configurator {
|
||||||
try {
|
try {
|
||||||
conf.add(new ConfigurationParam(f));
|
conf.add(new ConfigurationParam(f));
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
log.warn(null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +64,7 @@ public class Configurator {
|
||||||
try {
|
try {
|
||||||
param.set();
|
param.set();
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
log.warn(null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,5 +26,7 @@
|
||||||
<string name="pref_logging_path">Log Path</string>
|
<string name="pref_logging_path">Log Path</string>
|
||||||
<string name="pref_logging_path_summ">Folder where log file will be stored</string>
|
<string name="pref_logging_path_summ">Folder where log file will be stored</string>
|
||||||
<string name="title_activity_about">About</string>
|
<string name="title_activity_about">About</string>
|
||||||
|
<string name="pref_debug">Debug Logging</string>
|
||||||
|
<string name="pref_debug_summ">Enable application debug logging</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,12 @@
|
||||||
android:title="@string/pref_other_title"
|
android:title="@string/pref_other_title"
|
||||||
android:key="pref_key_storage_settings">
|
android:key="pref_key_storage_settings">
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="debug"
|
||||||
|
android:title="@string/pref_debug"
|
||||||
|
android:summary="@string/pref_debug_summ"
|
||||||
|
android:defaultValue="false">
|
||||||
|
</CheckBoxPreference>
|
||||||
<Preference
|
<Preference
|
||||||
android:key="about"
|
android:key="about"
|
||||||
android:title="@string/pref_about"
|
android:title="@string/pref_about"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue