mirror of
https://github.com/ME1312/SubServers-2.git
synced 2025-01-25 09:01:23 +01:00
Remove logger history
This commit is contained in:
parent
069ecc1948
commit
c05f5131b5
@ -1,6 +1,6 @@
|
|||||||
# ![https://s3.postimg.cc/dikyxlz5v/Sub_Banner.png](https://s3.postimg.cc/dikyxlz5v/Sub_Banner.png)
|
# ![https://s3.postimg.cc/dikyxlz5v/Sub_Banner.png](https://s3.postimg.cc/dikyxlz5v/Sub_Banner.png)
|
||||||
[![Build Status](https://src.me1312.net/jenkins/job/SubServers%20Platform/badge/icon)](https://src.me1312.net/jenkins/job/SubServers%20Platform/)
|
[![Build Status](https://src.me1312.net/jenkins/job/SubServers%20Platform/badge/icon)](https://src.me1312.net/jenkins/job/SubServers%20Platform/)
|
||||||
[![Release Verison](https://img.shields.io/github/release/ME1312/SubServers-2/all.svg)](https://github.com/ME1312/SubServers-2/releases) [![Snapshot Verison](https://img.shields.io/badge/dynamic/xml.svg?label=snapshot&url=https%3A%2F%2Fsrc.me1312.net%2Fmaven%2Fnet%2FME1312%2FSubServers%2FSubServers.Bungee%2Fmaven-metadata.xml&query=%2F%2Fversioning%2Frelease&colorB=blue)](https://src.me1312.net/jenkins/job/SubServers%20Platform/)<br><br>
|
[![Release Verison](https://img.shields.io/github/release/ME1312/SubServers-2/all.svg)](https://github.com/ME1312/SubServers-2/releases) [![Snapshot Verison](https://img.shields.io/badge/dynamic/xml.svg?label=snapshot&url=https%3A%2F%2Fsrc.me1312.net%2Fmaven%2Fnet%2FME1312%2FSubServers%2FSubServers.Bungee%2Fmaven-metadata.xml&query=%2F%2Fversioning%2Frelease&colorB=blue)](https://src.me1312.net/jenkins/job/SubServers%20Platform/) [![Discord](https://img.shields.io/discord/526520424880930867.svg)](https://discord.gg/VZ8YJqz)<br><br>
|
||||||
SubServers 2 is a rewrite of SubServers, the Server Management Platform.<br>
|
SubServers 2 is a rewrite of SubServers, the Server Management Platform.<br>
|
||||||
> [https://www.spigotmc.org/resources/subservers-bungee.11264/](https://www.spigotmc.org/resources/subservers-bungee.11264/)<br>
|
> [https://www.spigotmc.org/resources/subservers-bungee.11264/](https://www.spigotmc.org/resources/subservers-bungee.11264/)<br>
|
||||||
> [https://www.spigotmc.org/resources/subservers-host.38833/](https://www.spigotmc.org/resources/subservers-host.38833/)<br>
|
> [https://www.spigotmc.org/resources/subservers-host.38833/](https://www.spigotmc.org/resources/subservers-host.38833/)<br>
|
||||||
|
@ -30,7 +30,6 @@ public class ExternalSubLogger extends SubLogger {
|
|||||||
protected String name;
|
protected String name;
|
||||||
protected Container<Boolean> log;
|
protected Container<Boolean> log;
|
||||||
private List<SubLogFilter> filters = new ArrayList<SubLogFilter>();
|
private List<SubLogFilter> filters = new ArrayList<SubLogFilter>();
|
||||||
private List<LogMessage> messages = new LinkedList<LogMessage>();
|
|
||||||
protected File file;
|
protected File file;
|
||||||
private PrintWriter writer = null;
|
private PrintWriter writer = null;
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
@ -130,9 +129,6 @@ public class ExternalSubLogger extends SubLogger {
|
|||||||
// Log to CONSOLE
|
// Log to CONSOLE
|
||||||
if (allow) ProxyServer.getInstance().getLogger().log(level, name + " > " + msg);
|
if (allow) ProxyServer.getInstance().getLogger().log(level, name + " > " + msg);
|
||||||
|
|
||||||
// Log to MEMORY
|
|
||||||
messages.add(new LogMessage(level, msg));
|
|
||||||
|
|
||||||
// Log to FILE
|
// Log to FILE
|
||||||
if (writer != null) {
|
if (writer != null) {
|
||||||
writer.println(line);
|
writer.println(line);
|
||||||
@ -166,7 +162,6 @@ public class ExternalSubLogger extends SubLogger {
|
|||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace();
|
new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace();
|
||||||
}
|
}
|
||||||
messages.clear();
|
|
||||||
if (writer != null) {
|
if (writer != null) {
|
||||||
PrintWriter writer = this.writer;
|
PrintWriter writer = this.writer;
|
||||||
this.writer = null;
|
this.writer = null;
|
||||||
@ -193,9 +188,4 @@ public class ExternalSubLogger extends SubLogger {
|
|||||||
public boolean isLogging() {
|
public boolean isLogging() {
|
||||||
return log.get();
|
return log.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LogMessage> getMessageHistory() {
|
|
||||||
return new LinkedList<LogMessage>(messages);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class InternalSubCreator extends SubCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (template.getBuildOptions().contains("Shell-Location")) {
|
if (template.getBuildOptions().contains("Shell-Location")) {
|
||||||
String gitBash = InternalSubCreator.this.gitBash + ((InternalSubCreator.this.gitBash.endsWith(File.separator)) ? "" : File.separator) + "bin" + File.separatorChar + "bash.exe";
|
String gitBash = InternalSubCreator.this.gitBash + ((InternalSubCreator.this.gitBash.endsWith(File.separator)) ? "" : File.separator) + "bin" + File.separatorChar + "sh.exe";
|
||||||
File cache;
|
File cache;
|
||||||
if (template.getBuildOptions().getBoolean("Use-Cache", true)) {
|
if (template.getBuildOptions().getBoolean("Use-Cache", true)) {
|
||||||
cache = new UniversalFile(host.plugin.dir, "SubServers:Cache:Templates:" + template.getName());
|
cache = new UniversalFile(host.plugin.dir, "SubServers:Cache:Templates:" + template.getName());
|
||||||
|
@ -26,7 +26,6 @@ public class InternalSubLogger extends SubLogger {
|
|||||||
protected String name;
|
protected String name;
|
||||||
protected Container<Boolean> log;
|
protected Container<Boolean> log;
|
||||||
private List<SubLogFilter> filters = new ArrayList<SubLogFilter>();
|
private List<SubLogFilter> filters = new ArrayList<SubLogFilter>();
|
||||||
private List<LogMessage> messages = new LinkedList<LogMessage>();
|
|
||||||
protected File file;
|
protected File file;
|
||||||
private PrintWriter writer = null;
|
private PrintWriter writer = null;
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
@ -121,9 +120,6 @@ public class InternalSubLogger extends SubLogger {
|
|||||||
// Log to CONSOLE
|
// Log to CONSOLE
|
||||||
if (allow) ProxyServer.getInstance().getLogger().log(level, name + " > " + msg);
|
if (allow) ProxyServer.getInstance().getLogger().log(level, name + " > " + msg);
|
||||||
|
|
||||||
// Log to MEMORY
|
|
||||||
messages.add(new LogMessage(level, msg));
|
|
||||||
|
|
||||||
// Log to FILE
|
// Log to FILE
|
||||||
if (writer != null) {
|
if (writer != null) {
|
||||||
writer.println(line);
|
writer.println(line);
|
||||||
@ -171,7 +167,6 @@ public class InternalSubLogger extends SubLogger {
|
|||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace();
|
new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace();
|
||||||
}
|
}
|
||||||
messages.clear();
|
|
||||||
if (writer != null) {
|
if (writer != null) {
|
||||||
PrintWriter writer = this.writer;
|
PrintWriter writer = this.writer;
|
||||||
this.writer = null;
|
this.writer = null;
|
||||||
@ -198,9 +193,4 @@ public class InternalSubLogger extends SubLogger {
|
|||||||
public boolean isLogging() {
|
public boolean isLogging() {
|
||||||
return log.get();
|
return log.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LogMessage> getMessageHistory() {
|
|
||||||
return new LinkedList<LogMessage>(messages);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,81 +11,6 @@ import java.util.logging.Level;
|
|||||||
* SubLogger Layout Class
|
* SubLogger Layout Class
|
||||||
*/
|
*/
|
||||||
public abstract class SubLogger {
|
public abstract class SubLogger {
|
||||||
/**
|
|
||||||
* Log Message Storage Class
|
|
||||||
*/
|
|
||||||
public static class LogMessage {
|
|
||||||
private Date date;
|
|
||||||
private Level level;
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a Message
|
|
||||||
*
|
|
||||||
* @param message Message
|
|
||||||
*/
|
|
||||||
public LogMessage(String message) {
|
|
||||||
if (Util.isNull(message)) throw new NullPointerException();
|
|
||||||
this.date = Calendar.getInstance().getTime();
|
|
||||||
this.level = Level.INFO;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a Message
|
|
||||||
*
|
|
||||||
* @param level Log Level
|
|
||||||
* @param message Message
|
|
||||||
*/
|
|
||||||
public LogMessage(Level level, String message) {
|
|
||||||
if (Util.isNull(level, message)) throw new NullPointerException();
|
|
||||||
this.date = Calendar.getInstance().getTime();
|
|
||||||
this.level = level;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a Message
|
|
||||||
*
|
|
||||||
* @param date Date
|
|
||||||
* @param level Log Level
|
|
||||||
* @param message Message
|
|
||||||
*/
|
|
||||||
public LogMessage(Date date, Level level, String message) {
|
|
||||||
if (Util.isNull(date, level, message)) throw new NullPointerException();
|
|
||||||
this.date = date;
|
|
||||||
this.level = level;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the date this message was logged
|
|
||||||
*
|
|
||||||
* @return Date
|
|
||||||
*/
|
|
||||||
public Date getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the level this message was logged on
|
|
||||||
*
|
|
||||||
* @return Log Level
|
|
||||||
*/
|
|
||||||
public Level getLevel() {
|
|
||||||
return level;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the message
|
|
||||||
*
|
|
||||||
* @return Message
|
|
||||||
*/
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Name of the task logging
|
* Gets the Name of the task logging
|
||||||
@ -118,13 +43,6 @@ public abstract class SubLogger {
|
|||||||
*/
|
*/
|
||||||
public abstract boolean isLogging();
|
public abstract boolean isLogging();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of all the messages logged by this logger
|
|
||||||
*
|
|
||||||
* @return Log Messages (named by log level)
|
|
||||||
*/
|
|
||||||
public abstract List<LogMessage> getMessageHistory();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register Filter
|
* Register Filter
|
||||||
*
|
*
|
||||||
|
@ -135,7 +135,6 @@ public final class ConsoleWindow implements SubLogFilter {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
log.setText(RESET_VALUE);
|
log.setText(RESET_VALUE);
|
||||||
ConsoleWindow.this.loadContent();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
@ -249,7 +248,6 @@ public final class ConsoleWindow implements SubLogFilter {
|
|||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
ansi = ((AbstractButton) event.getSource()).getModel().isSelected();
|
ansi = ((AbstractButton) event.getSource()).getModel().isSelected();
|
||||||
log.setText(RESET_VALUE);
|
log.setText(RESET_VALUE);
|
||||||
ConsoleWindow.this.loadContent();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
@ -517,7 +515,6 @@ public final class ConsoleWindow implements SubLogFilter {
|
|||||||
|
|
||||||
logger.registerFilter(this);
|
logger.registerFilter(this);
|
||||||
log.setText(RESET_VALUE);
|
log.setText(RESET_VALUE);
|
||||||
loadContent();
|
|
||||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keys);
|
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keys);
|
||||||
if (logger.isLogging() && !open) open();
|
if (logger.isLogging() && !open) open();
|
||||||
}
|
}
|
||||||
@ -528,32 +525,6 @@ public final class ConsoleWindow implements SubLogFilter {
|
|||||||
hScroll.setVisible(input.isVisible() && hScroll.getVisibleAmount() < hScroll.getMaximum());
|
hScroll.setVisible(input.isVisible() && hScroll.getVisibleAmount() < hScroll.getMaximum());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadContent() {
|
|
||||||
LinkedList<Object> list = new LinkedList<Object>();
|
|
||||||
list.addAll(logger.getMessageHistory());
|
|
||||||
if (logger.getHandler() instanceof SubServer) list.addAll(((SubServer) logger.getHandler()).getCommandHistory());
|
|
||||||
|
|
||||||
Collections.sort(list, new Comparator<Object>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Object A, Object B) {
|
|
||||||
Date a = null, b = null;
|
|
||||||
|
|
||||||
if (A instanceof SubLogger.LogMessage) a = ((SubLogger.LogMessage) A).getDate();
|
|
||||||
if (A instanceof SubServer.LoggedCommand) a = ((SubServer.LoggedCommand) A).getDate();
|
|
||||||
|
|
||||||
if (B instanceof SubLogger.LogMessage) b = ((SubLogger.LogMessage) B).getDate();
|
|
||||||
if (B instanceof SubServer.LoggedCommand) b = ((SubServer.LoggedCommand) B).getDate();
|
|
||||||
|
|
||||||
return (a == null || b == null) ? 0 : a.compareTo(b);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
for (Object obj : list) {
|
|
||||||
if (obj instanceof SubLogger.LogMessage) log(((SubLogger.LogMessage) obj).getDate(), ((SubLogger.LogMessage) obj).getLevel(), ((SubLogger.LogMessage) obj).getMessage());
|
|
||||||
if (obj instanceof SubServer.LoggedCommand) log(((SubServer.LoggedCommand) obj).getDate(), '<' + ((((SubServer.LoggedCommand) obj).getSender() == null)?"CONSOLE":((ProxyServer.getInstance().getPlayer(((SubServer.LoggedCommand) obj).getSender()) == null)?((SubServer.LoggedCommand) obj).getSender().toString():ProxyServer.getInstance().getPlayer(((SubServer.LoggedCommand) obj).getSender()).getName())) + "> /" + ((SubServer.LoggedCommand) obj).getCommand());
|
|
||||||
}
|
|
||||||
hScroll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubLogger getLogger() {
|
public SubLogger getLogger() {
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ public class SubCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (template.getBuildOptions().contains("Shell-Location")) {
|
if (template.getBuildOptions().contains("Shell-Location")) {
|
||||||
String gitBash = host.host.getRawString("Git-Bash") + ((host.host.getRawString("Git-Bash").endsWith(File.separator)) ? "" : File.separator) + "bin" + File.separatorChar + "bash.exe";
|
String gitBash = host.host.getRawString("Git-Bash") + ((host.host.getRawString("Git-Bash").endsWith(File.separator)) ? "" : File.separator) + "bin" + File.separatorChar + "sh.exe";
|
||||||
File cache;
|
File cache;
|
||||||
if (template.getBuildOptions().getBoolean("Use-Cache", true)) {
|
if (template.getBuildOptions().getBoolean("Use-Cache", true)) {
|
||||||
cache = new UniversalFile(GalaxiEngine.getInstance().getRuntimeDirectory(), "Cache:Templates:" + template.getName());
|
cache = new UniversalFile(GalaxiEngine.getInstance().getRuntimeDirectory(), "Cache:Templates:" + template.getName());
|
||||||
|
Loading…
Reference in New Issue
Block a user