aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Kropf <josh@slashdev.ca>2011-05-25 20:44:10 (GMT)
committerJosh Kropf <josh@slashdev.ca>2011-05-25 20:44:10 (GMT)
commit2fd57c65654819aecd5d9aa034ad0f3c1d7b763e (patch)
treeb84e9e31757a2a6e5c8687ce636ec1775d3a04b1
parent972ed761010525f5caf036c31b369a1850c04297 (diff)
downloadlog4bb-2fd57c65654819aecd5d9aa034ad0f3c1d7b763e.zip
log4bb-2fd57c65654819aecd5d9aa034ad0f3c1d7b763e.tar.gz
log4bb-2fd57c65654819aecd5d9aa034ad0f3c1d7b763e.tar.bz2
added testing applicationHEADmaster
-rw-r--r--src/com/jiggak/log/LoggerTestApp.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/com/jiggak/log/LoggerTestApp.java b/src/com/jiggak/log/LoggerTestApp.java
new file mode 100644
index 0000000..fdfa0a4
--- /dev/null
+++ b/src/com/jiggak/log/LoggerTestApp.java
@@ -0,0 +1,86 @@
+/*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <josh@slashdev.ca> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return Josh Kropf
+ * ----------------------------------------------------------------------------
+ */
+package com.jiggak.log;
+
+import net.rim.device.api.ui.Field;
+import net.rim.device.api.ui.FieldChangeListener;
+import net.rim.device.api.ui.UiApplication;
+import net.rim.device.api.ui.component.BasicEditField;
+import net.rim.device.api.ui.component.ButtonField;
+import net.rim.device.api.ui.component.CheckboxField;
+import net.rim.device.api.ui.component.ObjectChoiceField;
+import net.rim.device.api.ui.component.SeparatorField;
+import net.rim.device.api.ui.container.MainScreen;
+import net.rim.device.api.util.Arrays;
+
+public class LoggerTestApp extends UiApplication implements FieldChangeListener {
+ private static final Logger log = Logger.getLogger(LoggerTestApp.class);
+
+ private String[] adapterNames = Logger.listAvailable();
+ private CheckboxField[] adapterCheckboxes = new CheckboxField[adapterNames.length];
+
+ private static final String[] LEVELS = new String[] {
+ "ERROR", "WARN", "INFO", "DEBUG"
+ };
+
+ private ObjectChoiceField logLevel = new ObjectChoiceField("Severity Level", LEVELS);
+ private BasicEditField message = new BasicEditField("", "<type log message here>");
+ private ButtonField logButton = new ButtonField("Log", ButtonField.CONSUME_CLICK);
+
+ public LoggerTestApp() {
+ MainScreen screen = new MainScreen();
+
+ for (int i=0; i<adapterNames.length; i++) {
+ adapterCheckboxes[i] = new CheckboxField(adapterNames[i], false);
+ adapterCheckboxes[i].setChangeListener(this);
+ screen.add(adapterCheckboxes[i]);
+ }
+
+ screen.add(new SeparatorField());
+
+ screen.add(logLevel);
+ screen.add(message);
+ screen.add(logButton);
+
+ logButton.setChangeListener(this);
+
+ pushScreen(screen);
+ }
+
+ public void fieldChanged(Field field, int context) {
+ if (field instanceof CheckboxField) {
+ int i = Arrays.getIndex(adapterCheckboxes, field);
+ if (((CheckboxField)field).getChecked()) {
+ Logger.register(adapterNames[i]);
+ } else {
+ Logger.unregister(adapterNames[i]);
+ }
+ } else if (field == logButton) {
+ String s = message.getText();
+ switch(logLevel.getSelectedIndex()) {
+ case 0:
+ log.error(s);
+ break;
+ case 1:
+ log.warn(s);
+ break;
+ case 2:
+ log.info(s);
+ break;
+ case 3:
+ log.debug(s);
+ break;
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ new LoggerTestApp().enterEventDispatcher();
+ }
+}