IDEMPIERE-4776 - iDempiere Monitor: Sort logs and Schedulers (#671)

* IDEMPIERE-4776 - iDempiere Monitor: Sort logs and Schedulers

* IDEMPIERE-4776 - iDempiere Monitor: Sort logs and Schedulers
* get logs already sorted from LogFileInfo

Co-authored-by: Carlos Ruiz <carg67@gmail.com>
This commit is contained in:
Ricardo Santana 2021-04-29 10:31:11 -03:00 committed by GitHub
parent b5bcc3690e
commit a22b36b744
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -28,6 +28,7 @@ package org.compiere.server;
import java.io.File; import java.io.File;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.compiere.util.CLogFile; import org.compiere.util.CLogFile;
@ -62,6 +63,7 @@ public class LogFileInfo implements Serializable {
if (logDir != null && logDir.isDirectory()) if (logDir != null && logDir.isDirectory())
{ {
File[] logs = logDir.listFiles(); File[] logs = logDir.listFiles();
Arrays.sort(logs);
for (int i = 0; i < logs.length; i++) for (int i = 0; i < logs.length; i++)
{ {
// Skip if is not a file - teo_sarca [ 1726066 ] // Skip if is not a file - teo_sarca [ 1726066 ]

View File

@ -25,6 +25,9 @@ import java.io.PrintWriter;
import java.net.InetAddress; import java.net.InetAddress;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -759,6 +762,14 @@ public class AdempiereMonitor extends HttpServlet
bb.addElement(new hr()); bb.addElement(new hr());
para = new p(); para = new p();
ServerInstance[] servers = getServerManager().getServerInstances(); ServerInstance[] servers = getServerManager().getServerInstances();
Arrays.sort(servers, new Comparator<ServerInstance>() {
public int compare(ServerInstance o1, ServerInstance o2) {
if (o1 == null || o1.getModel() == null || o1.getModel().getName() == null
|| o2 == null || o2.getModel() == null || o2.getModel().getName() == null)
return 0;
return o1.getModel().getName().compareTo(o2.getModel().getName());
}
});
for (int i = 0; i < servers.length; i++) for (int i = 0; i < servers.length; i++)
{ {
if (i > 0) if (i > 0)
@ -1152,6 +1163,7 @@ public class AdempiereMonitor extends HttpServlet
// List Log Files // List Log Files
p p = new p(); p p = new p();
p.addElement(new b("All Log Files: ")); p.addElement(new b("All Log Files: "));
p.addElement(new br());
// All in dir // All in dir
LogFileInfo logFiles[] = systemInfo.getLogFileInfos(); LogFileInfo logFiles[] = systemInfo.getLogFileInfos();
for (LogFileInfo logFile : logFiles) for (LogFileInfo logFile : logFiles)
@ -1159,7 +1171,11 @@ public class AdempiereMonitor extends HttpServlet
if (logFile != logFiles[0]) if (logFile != logFiles[0])
p.addElement(" - "); p.addElement(" - ");
String fileName = logFile.getFileName(); String fileName = logFile.getFileName();
a link = new a ("idempiereMonitor?Trace=" + fileName, fileName); String displayName = fileName;
int index = fileName.lastIndexOf(File.separator);
if (index > 1)
displayName = fileName.substring(index+1);
a link = new a ("idempiereMonitor?Trace=" + fileName, displayName);
p.addElement(link); p.addElement(link);
int size = (int)(logFile.getFileSize()/1024); int size = (int)(logFile.getFileSize()/1024);
if (size < 1024) if (size < 1024)