diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/util/DateUtils.java b/Ghidra/Framework/Generic/src/main/java/ghidra/util/DateUtils.java
index 80eb07f0a1..942979a615 100644
--- a/Ghidra/Framework/Generic/src/main/java/ghidra/util/DateUtils.java
+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/util/DateUtils.java
@@ -217,9 +217,9 @@ public class DateUtils {
}
/**
- * Formats the given date into a string. This is in contrast to
+ * Formats the given date into a string. This is in contrast to
* {@link #formatDateTimestamp(Date)}, which will also return the time portion of the date.
- *
+ *
* @param date the date to format
* @return the date string
*/
@@ -228,9 +228,9 @@ public class DateUtils {
}
/**
- * Formats the given date into a string that contains the date and time. This is in
+ * Formats the given date into a string that contains the date and time. This is in
* contrast to {@link #formatDate(Date)}, which only returns a date string.
- *
+ *
* @param date the date to format
* @return the date and time string
*/
@@ -239,7 +239,7 @@ public class DateUtils {
}
/**
- * Returns the current local time zone time-of-day as simple time string.
+ * Returns the current local time zone time-of-day as simple time string.
* See {@value #TIME_FORMAT_STRING}.
*
* @return current time-of-day a a string
@@ -248,7 +248,12 @@ public class DateUtils {
return TIME_FORMATTER.format(toLocalDate(new Date()));
}
- private static LocalDateTime toLocalDate(Date d) {
+ /**
+ * Converts the given Data to a LocalDate
+ * @param d the date
+ * @return the local date
+ */
+ public static LocalDateTime toLocalDate(Date d) {
//@formatter:off
return Instant.ofEpochMilli(d.getTime())
.atZone(ZoneId.systemDefault())
@@ -257,7 +262,12 @@ public class DateUtils {
//@formatter:on
}
- private static Date toDate(LocalDate ld) {
+ /**
+ * Converts the given LocalDate to a date
+ * @param ld the local date
+ * @return the date
+ */
+ public static Date toDate(LocalDate ld) {
//@formatter:off
return Date.from(ld.atStartOfDay()
.atZone(ZoneId.systemDefault())
@@ -268,8 +278,8 @@ public class DateUtils {
/**
* Returns a date for the given numeric values
- *
- * @param year the year
+ *
+ * @param year the year
* @param month the month; 0-based
* @param day the day of month; 1-based
* @return the date
@@ -282,7 +292,7 @@ public class DateUtils {
/**
* Returns all days between the two dates. Returns 0 if the same date is passed for both
* parameters. The order of the dates does not matter.
- *
+ *
* @param date1 the first date
* @param date2 the second date
* @return the number of days
@@ -292,9 +302,9 @@ public class DateUtils {
}
/**
- * Returns the business days between the two dates. Returns 0 if the same date is
+ * Returns the business days between the two dates. Returns 0 if the same date is
* passed for both parameters. The order of the dates does not matter.
- *
+ *
* @param date1 the first date
* @param date2 the second date
* @return the number of days
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/mgr/ToolTaskManager.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/mgr/ToolTaskManager.java
index b67d0ab3e1..e9906c9c8e 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/mgr/ToolTaskManager.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/mgr/ToolTaskManager.java
@@ -17,6 +17,8 @@ package ghidra.framework.plugintool.mgr;
import java.awt.Dimension;
import java.rmi.ConnectException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
import java.util.*;
import javax.swing.JComponent;
@@ -25,7 +27,7 @@ import javax.swing.SwingUtilities;
import ghidra.framework.cmd.*;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
-import ghidra.util.Msg;
+import ghidra.util.*;
import ghidra.util.datastruct.PriorityQueue;
import ghidra.util.exception.RollbackException;
import ghidra.util.task.*;
@@ -34,6 +36,11 @@ import ghidra.util.task.*;
* Manages a queue of background tasks that execute commands.
*/
public class ToolTaskManager implements Runnable {
+
+ private static final String TIME_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss";
+ private static final DateTimeFormatter TIME_FORMATTER =
+ DateTimeFormatter.ofPattern(TIME_FORMAT_STRING);
+
private volatile PluginTool tool;
private volatile boolean isExecuting;
@@ -292,17 +299,27 @@ public class ToolTaskManager implements Runnable {
}
}
- /**
- * @see java.lang.Runnable#run()
- */
+ private String time() {
+ if (!SystemUtilities.isInDevelopmentMode()) {
+ // The dev console log appender does not show date info for log messages. This method
+ // allows us to show the time in the dev console, which is useful for debugging. The
+ // application log files always contain a date for each message.
+ return "";
+ }
+
+ LocalDateTime localDate = DateUtils.toLocalDate(new Date());
+ return TIME_FORMATTER.format(localDate) + " ";
+ }
+
@Override
public void run() {
try {
- Msg.debug(this, (new Date()) + " Background processing started...");
+
+ Msg.debug(this, time() + "Background processing started...");
startQueueTime = System.currentTimeMillis();
for (BackgroundCommandTask task = getNextTask(); task != null; task = getNextTask()) {
- Msg.debug(this, (new Date()) + " Exec Task " + task.getTaskTitle());
+ Msg.debug(this, time() + "Exec Task " + task.getTaskTitle());
startTaskTime = System.currentTimeMillis();
synchronized (this) {
@@ -321,8 +338,7 @@ public class ToolTaskManager implements Runnable {
}
double totalTime = (System.currentTimeMillis() - startQueueTime) / 1000.00;
- Msg.debug(this,
- (new Date()) + " Background processing complete (" + totalTime + " secs)");
+ Msg.debug(this, time() + "Background processing complete (" + totalTime + " secs)");
}
finally {
synchronized (this) {
@@ -361,9 +377,9 @@ public class ToolTaskManager implements Runnable {
*/
public void taskCompleted(UndoableDomainObject obj, BackgroundCommandTask task,
TaskMonitor monitor) {
+
double taskTime = (System.currentTimeMillis() - startTaskTime) / 1000.00;
- Msg.debug(this,
- (new Date()) + " " + task.getTaskTitle() + " task finish (" + taskTime + " secs)");
+ Msg.debug(this, time() + task.getTaskTitle() + " task finish (" + taskTime + " secs)");
obj.flushEvents();
try {
while (!monitor.isCancelled()) {
@@ -376,13 +392,13 @@ public class ToolTaskManager implements Runnable {
break;
}
}
- Msg.debug(this, (new Date()) + " Queue - " + cmd.getName());
+ Msg.debug(this, time() + "Queue - " + cmd.getName());
toolTaskMonitor.updateTaskCmd(cmd);
long localStart = System.currentTimeMillis();
cmd.applyTo(obj, monitor);
cmd.taskCompleted();
double totalTime = (System.currentTimeMillis() - localStart) / 1000.00;
- Msg.debug(this, (new Date()) + " (" + totalTime + " secs)");
+ Msg.debug(this, time() + "(" + totalTime + " secs)");
obj.flushEvents();
}
}
@@ -413,12 +429,12 @@ public class ToolTaskManager implements Runnable {
}
task.getCommand().taskCompleted();
double totalTime = (System.currentTimeMillis() - startTaskTime) / 1000.00;
- Msg.debug(this,
- (new Date()) + " " + task.getTaskTitle() + " task complete (" + totalTime + " secs)");
+ Msg.debug(this, time() + task.getTaskTitle() + " task complete (" + totalTime + " secs)");
}
/**
* Clear the queue of scheduled commands.
+ * @param obj domain object
*/
public synchronized void clearQueuedCommands(UndoableDomainObject obj) {
PriorityQueue queue = queuedCommandsMap.get(obj);