Removed DateFormatter (Swing) for Android compatibility

This commit is contained in:
ChronosX88 2019-05-15 20:56:17 +04:00
parent dfc1a063c8
commit 20b29ec381
3 changed files with 3059 additions and 248 deletions

File diff suppressed because it is too large Load Diff

View File

@ -40,17 +40,15 @@ advised of the possibility of such damage.
*/ */
package rice.environment.logging; package rice.environment.logging;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.swing.text.DateFormatter;
import rice.environment.logging.simple.SimpleLogger;
import rice.environment.params.ParameterChangeListener; import rice.environment.params.ParameterChangeListener;
import rice.environment.params.Parameters; import rice.environment.params.Parameters;
import rice.environment.time.TimeSource; import rice.environment.time.TimeSource;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Hashtable;
import java.util.Iterator;
/** /**
* @author jstewart * @author jstewart
* *
@ -80,7 +78,7 @@ public abstract class AbstractLogManager implements LogManager {
protected boolean enabled; protected boolean enabled;
protected static final PrintStream nullPrintStream = new PrintStream(new NullOutputStream()); protected static final PrintStream nullPrintStream = new PrintStream(new NullOutputStream());
public DateFormatter dateFormatter; public SimpleDateFormat dateFormatt;
public static final String SYSTEM_OUT = "System.out"; public static final String SYSTEM_OUT = "System.out";
public static final String SYSTEM_ERR = "System.err"; public static final String SYSTEM_ERR = "System.err";
@ -112,7 +110,7 @@ public abstract class AbstractLogManager implements LogManager {
this.dateFormat = params.getString("logging_date_format"); this.dateFormat = params.getString("logging_date_format");
} }
if (this.dateFormat != null && !this.dateFormat.equals("")) { if (this.dateFormat != null && !this.dateFormat.equals("")) {
dateFormatter = new DateFormatter(new SimpleDateFormat(this.dateFormat)); this.dateFormatt = new SimpleDateFormat(this.dateFormat);
// System.out.println("DateFormat "+this.dateFormat); // System.out.println("DateFormat "+this.dateFormat);
} }

View File

@ -39,15 +39,11 @@ advised of the possibility of such damage.
*/ */
package rice.environment.logging.simple; package rice.environment.logging.simple;
import java.io.PrintStream; import rice.environment.logging.AbstractLogManager;
import java.text.*; import rice.environment.logging.HeirarchyLogger;
import java.util.Date; import java.util.Date;
import javax.swing.text.DateFormatter;
import rice.environment.logging.*;
import rice.environment.time.TimeSource;
/** /**
* This logger writes its name:time:message to the printstream provided, unless the * This logger writes its name:time:message to the printstream provided, unless the
* priority is lower than the minimumPriority. * priority is lower than the minimumPriority.
@ -70,9 +66,6 @@ public class SimpleLogger extends HeirarchyLogger {
* Constructor. * Constructor.
* *
* @param loggerName the name of this logger. * @param loggerName the name of this logger.
* @param ps the stream to print to.
* @param time the timesource.
* @param minPriority the minimum priority to display.
*/ */
public SimpleLogger(String loggerName, AbstractLogManager alm, int level, boolean useDefault) { public SimpleLogger(String loggerName, AbstractLogManager alm, int level, boolean useDefault) {
this.loggerName = loggerName; this.loggerName = loggerName;
@ -87,13 +80,9 @@ public class SimpleLogger extends HeirarchyLogger {
public void log(String message) { public void log(String message) {
synchronized(alm) { synchronized(alm) {
String dateString = ""+alm.getTimeSource().currentTimeMillis(); String dateString = ""+alm.getTimeSource().currentTimeMillis();
if (alm.dateFormatter != null) { if (alm.dateFormatt != null) {
try { Date date = new Date(alm.getTimeSource().currentTimeMillis());
Date date = new Date(alm.getTimeSource().currentTimeMillis()); dateString = date.toString();
dateString = alm.dateFormatter.valueToString(date);
} catch (ParseException pe) {
pe.printStackTrace();
}
} }
alm.getPrintStream().println(alm.getPrefix()+":"+loggerName+":"+dateString+":"+message); alm.getPrintStream().println(alm.getPrefix()+":"+loggerName+":"+dateString+":"+message);
@ -106,13 +95,9 @@ public class SimpleLogger extends HeirarchyLogger {
public void logException(String message, Throwable exception) { public void logException(String message, Throwable exception) {
synchronized(alm) { synchronized(alm) {
String dateString = ""+alm.getTimeSource().currentTimeMillis(); String dateString = ""+alm.getTimeSource().currentTimeMillis();
if (alm.dateFormatter != null) { if (alm.dateFormatt != null) {
try { Date date = new Date(alm.getTimeSource().currentTimeMillis());
Date date = new Date(alm.getTimeSource().currentTimeMillis()); dateString = date.toString();
dateString = alm.dateFormatter.valueToString(date);
} catch (ParseException pe) {
pe.printStackTrace();
}
} }
alm.getPrintStream().print(alm.getPrefix()+":"+loggerName+":"+dateString+":"+message+" "); alm.getPrintStream().print(alm.getPrefix()+":"+loggerName+":"+dateString+":"+message+" ");