Merge pull request #13 from mesacarlos/feature/full-logs
Feature/full logs
This commit is contained in:
commit
39b4ea5592
@ -230,6 +230,10 @@
|
|||||||
<input type="checkbox" class="custom-control-input" id="showDateSettingsSwitch">
|
<input type="checkbox" class="custom-control-input" id="showDateSettingsSwitch">
|
||||||
<label class="custom-control-label" for="showDateSettingsSwitch" id="showDateSettingsSwitchLabel">Show date and time on each console line</label>
|
<label class="custom-control-label" for="showDateSettingsSwitch" id="showDateSettingsSwitchLabel">Show date and time on each console line</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="custom-control custom-switch">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="readLogFileSwitch">
|
||||||
|
<label class="custom-control-label" for="readLogFileSwitch" id="readLogFileSwitchLabel">Retrieve full log file from server after login</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="settingsModalCloseButton">Done</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="settingsModalCloseButton">Done</button>
|
||||||
@ -241,7 +245,7 @@
|
|||||||
<!-- Webpage footer -->
|
<!-- Webpage footer -->
|
||||||
<footer class="footer mt-auto py-3">
|
<footer class="footer mt-auto py-3">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<span class="text-muted">WebConsole v1.4 (rev. 6) - <a href="https://github.com/mesacarlos/WebConsole">GitHub</a></span>
|
<span class="text-muted">WebConsole v1.5 - <a href="https://github.com/mesacarlos/WebConsole">GitHub</a></span>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
@ -251,11 +255,11 @@
|
|||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
<!-- WebConsole JS Scripts -->
|
<!-- WebConsole JS Scripts -->
|
||||||
<script src="scripts/WebConsoleLanguage.js?v=1.4.6"></script>
|
<script src="scripts/WebConsoleLanguage.js?v=1.5.0"></script>
|
||||||
<script src="scripts/WebConsoleConnector.js?v=1.4.6"></script>
|
<script src="scripts/WebConsoleConnector.js?v=1.5.0"></script>
|
||||||
<script src="scripts/WebConsoleManager.js?v=1.4.6"></script>
|
<script src="scripts/WebConsoleManager.js?v=1.5.0"></script>
|
||||||
<script src="scripts/WebConsolePersistenceManager.js?v=1.4.6"></script>
|
<script src="scripts/WebConsolePersistenceManager.js?v=1.5.0"></script>
|
||||||
<script src="scripts/WebConsole.js?v=1.4.6"></script>
|
<script src="scripts/WebConsole.js?v=1.5.0"></script>
|
||||||
<script src="scripts/WebConsoleJqueryHandler.js?v=1.4.6"></script>
|
<script src="scripts/WebConsoleJqueryHandler.js?v=1.5.0"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -57,6 +57,11 @@ function onWebSocketsMessage(message){
|
|||||||
case 200:
|
case 200:
|
||||||
//Processed
|
//Processed
|
||||||
writeToWebConsole(message.message);
|
writeToWebConsole(message.message);
|
||||||
|
if(connectionManager.activeConnection.isLogged === false){
|
||||||
|
connectionManager.activeConnection.isLogged = true;
|
||||||
|
if(persistenceManager.getSetting("retrieveLogFile") === true)
|
||||||
|
connectionManager.askForLogs();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 400:
|
case 400:
|
||||||
//Unknown Command
|
//Unknown Command
|
||||||
@ -155,7 +160,7 @@ function writeToWebConsole(msg){
|
|||||||
|
|
||||||
//Append datetime if enabled
|
//Append datetime if enabled
|
||||||
if(persistenceManager.getSetting("dateTimePrefix"))
|
if(persistenceManager.getSetting("dateTimePrefix"))
|
||||||
msg = "[" + new Date().toLocaleString() + "] " + msg;
|
msg = "[" + new Date().toLocaleTimeString() + "] " + msg;
|
||||||
|
|
||||||
$("#consoleTextArea").append(msg + "<br>");
|
$("#consoleTextArea").append(msg + "<br>");
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ class WebConsoleConnector {
|
|||||||
this.messages = []; //All messages retrieved since connection start
|
this.messages = []; //All messages retrieved since connection start
|
||||||
this.commands = []; //EXEC Commands sent by user to this server
|
this.commands = []; //EXEC Commands sent by user to this server
|
||||||
this.players = []; //Connected users.
|
this.players = []; //Connected users.
|
||||||
|
this.isLogged = false; //Is logged in with valid pasword or not
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,6 +195,7 @@ $("#disconnectionModalWelcomeScreenButton").click(function() {
|
|||||||
$("#settingsLink").click(function() {
|
$("#settingsLink").click(function() {
|
||||||
//Update modal switches and boxes with saved settings
|
//Update modal switches and boxes with saved settings
|
||||||
$("#showDateSettingsSwitch").prop("checked", persistenceManager.getSetting("dateTimePrefix"));
|
$("#showDateSettingsSwitch").prop("checked", persistenceManager.getSetting("dateTimePrefix"));
|
||||||
|
$("#readLogFileSwitch").prop("checked", persistenceManager.getSetting("retrieveLogFile"));
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,3 +205,11 @@ $("#showDateSettingsSwitch").click(function() {
|
|||||||
//Update modal switches and boxes with saved settings
|
//Update modal switches and boxes with saved settings
|
||||||
persistenceManager.setSetting("dateTimePrefix", $("#showDateSettingsSwitch").is(":checked"));
|
persistenceManager.setSetting("dateTimePrefix", $("#showDateSettingsSwitch").is(":checked"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On readLogFileSwitch switched
|
||||||
|
*/
|
||||||
|
$("#readLogFileSwitch").click(function() {
|
||||||
|
//Update modal switches and boxes with saved settings
|
||||||
|
persistenceManager.setSetting("retrieveLogFile", $("#readLogFileSwitch").is(":checked"));
|
||||||
|
});
|
@ -38,6 +38,7 @@ function setLanguage(locale){
|
|||||||
"settingsLink": "Settings",
|
"settingsLink": "Settings",
|
||||||
"settingsModalLongTitle": "WebConsole Settings",
|
"settingsModalLongTitle": "WebConsole Settings",
|
||||||
"showDateSettingsSwitchLabel": "Show date and time on each console line",
|
"showDateSettingsSwitchLabel": "Show date and time on each console line",
|
||||||
|
"readLogFileSwitchLabel": "Retrieve full log file from server after login",
|
||||||
"settingsModalCloseButton": "Done",
|
"settingsModalCloseButton": "Done",
|
||||||
"players_online": "Players Online",
|
"players_online": "Players Online",
|
||||||
"cpu_title": "CPU",
|
"cpu_title": "CPU",
|
||||||
@ -75,6 +76,7 @@ function setLanguage(locale){
|
|||||||
"settingsLink": "Configuración",
|
"settingsLink": "Configuración",
|
||||||
"settingsModalLongTitle": "Configuración de WebConsole",
|
"settingsModalLongTitle": "Configuración de WebConsole",
|
||||||
"showDateSettingsSwitchLabel": "Mostrar fecha y hora en cada linea de consola",
|
"showDateSettingsSwitchLabel": "Mostrar fecha y hora en cada linea de consola",
|
||||||
|
"readLogFileSwitchLabel": "Leer log completo al iniciar sesión",
|
||||||
"settingsModalCloseButton": "Hecho",
|
"settingsModalCloseButton": "Hecho",
|
||||||
"players_online": "Jugadores en línea",
|
"players_online": "Jugadores en línea",
|
||||||
"cpu_title": "CPU",
|
"cpu_title": "CPU",
|
||||||
@ -112,6 +114,7 @@ function setLanguage(locale){
|
|||||||
"settingsLink": "настройки",
|
"settingsLink": "настройки",
|
||||||
"settingsModalLongTitle": "настройки WebConsole",
|
"settingsModalLongTitle": "настройки WebConsole",
|
||||||
"showDateSettingsSwitchLabel": "Показать дату и время в каждой строке консоли",
|
"showDateSettingsSwitchLabel": "Показать дату и время в каждой строке консоли",
|
||||||
|
"readLogFileSwitchLabel": "Получить полный файл журнала с сервера после входа в систему",
|
||||||
"settingsModalCloseButton": "Выполнено",
|
"settingsModalCloseButton": "Выполнено",
|
||||||
"players_online": "Игроки",
|
"players_online": "Игроки",
|
||||||
"cpu_title": "CPU",
|
"cpu_title": "CPU",
|
||||||
@ -149,6 +152,7 @@ function setLanguage(locale){
|
|||||||
"settingsLink": "Configurações",
|
"settingsLink": "Configurações",
|
||||||
"settingsModalLongTitle": "Configurações do WebConsole",
|
"settingsModalLongTitle": "Configurações do WebConsole",
|
||||||
"showDateSettingsSwitchLabel": "Mostrar data e hora em cada linha do console",
|
"showDateSettingsSwitchLabel": "Mostrar data e hora em cada linha do console",
|
||||||
|
"readLogFileSwitchLabel": "Recuperar arquivo de log completo do servidor após o login",
|
||||||
"settingsModalCloseButton": "Feito",
|
"settingsModalCloseButton": "Feito",
|
||||||
"players_online": "Jogadores online",
|
"players_online": "Jogadores online",
|
||||||
"cpu_title": "Consumo de CPU",
|
"cpu_title": "Consumo de CPU",
|
||||||
@ -186,6 +190,7 @@ function setLanguage(locale){
|
|||||||
"settingsLink": "设定值",
|
"settingsLink": "设定值",
|
||||||
"settingsModalLongTitle": "WebConsole 设定值",
|
"settingsModalLongTitle": "WebConsole 设定值",
|
||||||
"showDateSettingsSwitchLabel": "在每个控制台行上显示日期和时间",
|
"showDateSettingsSwitchLabel": "在每个控制台行上显示日期和时间",
|
||||||
|
"readLogFileSwitchLabel": "登录后从服务器检索完整的日志文件",
|
||||||
"settingsModalCloseButton": "完成",
|
"settingsModalCloseButton": "完成",
|
||||||
"players_online": "在线人数",
|
"players_online": "在线人数",
|
||||||
"cpu_title": "CPU",
|
"cpu_title": "CPU",
|
||||||
@ -223,6 +228,7 @@ function setLanguage(locale){
|
|||||||
"settingsLink": "Réglages",
|
"settingsLink": "Réglages",
|
||||||
"settingsModalLongTitle": "Réglages de WebConsole",
|
"settingsModalLongTitle": "Réglages de WebConsole",
|
||||||
"showDateSettingsSwitchLabel": "Afficher la date et l'heure sur chaque ligne de console",
|
"showDateSettingsSwitchLabel": "Afficher la date et l'heure sur chaque ligne de console",
|
||||||
|
"readLogFileSwitchLabel": "Récupérer le fichier journal complet du serveur après la connexion",
|
||||||
"settingsModalCloseButton": "Terminé",
|
"settingsModalCloseButton": "Terminé",
|
||||||
"players_online": "Joueurs en ligne",
|
"players_online": "Joueurs en ligne",
|
||||||
"cpu_title": "Utilisation de la CPU",
|
"cpu_title": "Utilisation de la CPU",
|
||||||
@ -260,6 +266,7 @@ function setLanguage(locale){
|
|||||||
"settingsLink": "Nastavení",
|
"settingsLink": "Nastavení",
|
||||||
"settingsModalLongTitle": "Nastavení WebConsole",
|
"settingsModalLongTitle": "Nastavení WebConsole",
|
||||||
"showDateSettingsSwitchLabel": "Zobrazit datum a čas na každé řádce konzoly",
|
"showDateSettingsSwitchLabel": "Zobrazit datum a čas na každé řádce konzoly",
|
||||||
|
"readLogFileSwitchLabel": "Po přihlášení načtěte úplný soubor protokolu ze serveru",
|
||||||
"settingsModalCloseButton": "Hotovo",
|
"settingsModalCloseButton": "Hotovo",
|
||||||
"players_online": "Počet hráčů online",
|
"players_online": "Počet hráčů online",
|
||||||
"cpu_title": "CPU",
|
"cpu_title": "CPU",
|
||||||
@ -281,31 +288,4 @@ function setLanguage(locale){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// document.getElementById("navbarHomeLink").textContent = lang.navbarHomeLink;
|
|
||||||
// document.getElementById("home_header").textContent = lang.home_header;
|
|
||||||
// document.getElementById("home_description").textContent = lang.home_description;
|
|
||||||
// document.getElementById("serversDropdown").textContent = lang.serversDropdown;
|
|
||||||
// document.getElementById("add_server").textContent = lang.add_server;
|
|
||||||
// document.getElementById("lang_dropdown").textContent = lang.lang_dropdown;
|
|
||||||
// document.getElementById("addServerModalLongTitle").textContent = lang.addServerModalLongTitle;
|
|
||||||
// document.getElementById("addServerModalSvName").textContent = lang.addServerModalSvName;
|
|
||||||
// document.getElementById("addServerModalSvIp").textContent = lang.addServerModalSvIp;
|
|
||||||
// document.getElementById("addServerModalSvPort").textContent = lang.addServerModalSvPort;
|
|
||||||
// document.getElementById("addServerModalSvSsl").textContent = lang.addServerModalSvSsl;
|
|
||||||
// document.getElementById("addServerModalSslAdvice").textContent = lang.addServerModalSslAdvice;
|
|
||||||
// document.getElementById("addServerModalClose").textContent = lang.addServerModalClose;
|
|
||||||
// document.getElementById("saveAndConnectServerButton").textContent = lang.saveAndConnectServerButton;
|
|
||||||
// document.getElementById("passwordModalLongTitle").textContent = lang.passwordModalLongTitle;
|
|
||||||
// document.getElementById("passwordModalLabel").textContent = lang.passwordModalLabel;
|
|
||||||
// document.getElementById("passwordModalRememberLabel").textContent = lang.passwordModalRememberLabel;
|
|
||||||
// document.getElementById("passwordModalCloseButton").textContent = lang.passwordModalCloseButton;
|
|
||||||
// document.getElementById("passwordSendButton").textContent = lang.passwordSendButton;
|
|
||||||
// document.getElementById("disconnectionModalLongTitle").textContent = lang.disconnectionModalLongTitle;
|
|
||||||
// document.getElementById("disconnectionModalDescription").textContent = lang.disconnectionModalDescription;
|
|
||||||
// document.getElementById("disconnectionModalCloseButton").textContent = lang.disconnectionModalCloseButton;
|
|
||||||
// document.getElementById("players_online").textContent = lang.players_online;
|
|
||||||
// document.getElementById("cpu_title").textContent = lang.cpu_title;
|
|
||||||
// document.getElementById("ram_title").textContent = lang.ram_title;
|
|
||||||
// document.getElementById("deleteServerButton").textContent = lang.deleteServerButton;
|
|
||||||
// document.getElementById("sendCommandButton").textContent = lang.sendCommandButton;
|
|
||||||
}
|
}
|
@ -80,4 +80,11 @@ class WebConsoleManager {
|
|||||||
this.activeConnection.sendToServer("RAMUSAGE");
|
this.activeConnection.sendToServer("RAMUSAGE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asks server for full latest.log
|
||||||
|
*/
|
||||||
|
askForLogs(){
|
||||||
|
this.activeConnection.sendToServer("READLOGFILE");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -135,8 +135,10 @@ class WebConsolePersistenceManager{
|
|||||||
currentSettings = new Object();
|
currentSettings = new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Setting array initialization. If you need to add more settings, add them here. Any object is valid as a value (not only bool)
|
||||||
var settings = {
|
var settings = {
|
||||||
dateTimePrefix : new Setting("dateTimePrefix", true)
|
dateTimePrefix : new Setting("dateTimePrefix", true),
|
||||||
|
retrieveLogFile : new Setting("retrieveLogFile", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set settings
|
//Set settings
|
||||||
|
@ -36,3 +36,6 @@ ram-usage-message = {0} free, {1} used, {2} maximum memory
|
|||||||
webconsole-version = WebConsole version {0}.
|
webconsole-version = WebConsole version {0}.
|
||||||
webconsole-no-connections = There are no logged in WebConsole connections now.
|
webconsole-no-connections = There are no logged in WebConsole connections now.
|
||||||
webconsole-active-connections = Connected to WebConsole from:
|
webconsole-active-connections = Connected to WebConsole from:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Error trying to read latest.log file
|
@ -36,3 +36,6 @@ ram-usage-message = {0} volné, {1} použité, {2} maximální paměti
|
|||||||
webconsole-version = WebConsole verze {0}.
|
webconsole-version = WebConsole verze {0}.
|
||||||
webconsole-no-connections = Nejsou žádné WebConsole připojení.
|
webconsole-no-connections = Nejsou žádné WebConsole připojení.
|
||||||
webconsole-active-connections = Připojeno k WebConsole z:
|
webconsole-active-connections = Připojeno k WebConsole z:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Chyba při čtení souboru latest.log
|
@ -36,3 +36,6 @@ ram-usage-message = {0} free, {1} used, {2} maximum memory
|
|||||||
webconsole-version = WebConsole version {0}.
|
webconsole-version = WebConsole version {0}.
|
||||||
webconsole-no-connections = There are no logged in WebConsole connections now.
|
webconsole-no-connections = There are no logged in WebConsole connections now.
|
||||||
webconsole-active-connections = Connected to WebConsole from:
|
webconsole-active-connections = Connected to WebConsole from:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Error trying to read latest.log file
|
@ -36,3 +36,6 @@ ram-usage-message = Memoria: {0} libre, {1} usada, {2} maxima
|
|||||||
webconsole-version = WebConsole version {0}.
|
webconsole-version = WebConsole version {0}.
|
||||||
webconsole-no-connections = No hay ninguna conexión activa a WebConsole en este momento.
|
webconsole-no-connections = No hay ninguna conexión activa a WebConsole en este momento.
|
||||||
webconsole-active-connections = Conectado a WebConsole desde:
|
webconsole-active-connections = Conectado a WebConsole desde:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Error leyendo el fichero latest.log
|
@ -36,3 +36,6 @@ ram-usage-message = {0} gratuit, {1} utilisé, {2} mémoire maximale
|
|||||||
webconsole-version = version WebConsole {0}.
|
webconsole-version = version WebConsole {0}.
|
||||||
webconsole-no-connections = Aucune connexion WebConsole n'est connectée maintenant.
|
webconsole-no-connections = Aucune connexion WebConsole n'est connectée maintenant.
|
||||||
webconsole-active-connections = Connecté à WebConsole depuis:
|
webconsole-active-connections = Connecté à WebConsole depuis:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Erreur lors de la lecture du fichier latest.log
|
@ -36,3 +36,6 @@ ram-usage-message = Disponível: {0}, Consumo de RAM: {1} / {2}
|
|||||||
webconsole-version = WebConsole versão {0}.
|
webconsole-version = WebConsole versão {0}.
|
||||||
webconsole-no-connections = Atualmente não tem nenhum usuário conectado.
|
webconsole-no-connections = Atualmente não tem nenhum usuário conectado.
|
||||||
webconsole-active-connections = Atualmente temos:
|
webconsole-active-connections = Atualmente temos:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Erro ao ler o arquivo latest.log
|
@ -36,3 +36,6 @@ ram-usage-message = {0} свободно, {1} используется, {2} ма
|
|||||||
webconsole-version = Версия WebConsole {0}.
|
webconsole-version = Версия WebConsole {0}.
|
||||||
webconsole-no-connections = В настоящее время нет подключений к WebConsole.
|
webconsole-no-connections = В настоящее время нет подключений к WebConsole.
|
||||||
webconsole-active-connections = Подключен к веб-консоли из :
|
webconsole-active-connections = Подключен к веб-консоли из :
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = ошибка чтения последнего latest.log
|
@ -36,3 +36,6 @@ ram-usage-message = 空閒{0} , 已使用{1} , 最大內存{2}
|
|||||||
webconsole-version = 網站控制台版本 {0}.
|
webconsole-version = 網站控制台版本 {0}.
|
||||||
webconsole-no-connections = 現在沒有連接登錄網站控制台。
|
webconsole-no-connections = 現在沒有連接登錄網站控制台。
|
||||||
webconsole-active-connections = 從以下位置連接到網站控制台:
|
webconsole-active-connections = 從以下位置連接到網站控制台:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = 读取Latest.log文件时出错
|
@ -1,7 +1,7 @@
|
|||||||
name: WebConsole
|
name: WebConsole
|
||||||
main: com.mesacarlos.webconsole.WebConsole
|
main: com.mesacarlos.webconsole.WebConsole
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
version: 1.4
|
version: 1.5
|
||||||
description: WebSockets-based web console
|
description: WebSockets-based web console
|
||||||
author: Carlos Mesa
|
author: Carlos Mesa
|
||||||
commands:
|
commands:
|
||||||
|
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>WebConsole</groupId>
|
<groupId>WebConsole</groupId>
|
||||||
<artifactId>WebConsole</artifactId>
|
<artifactId>WebConsole</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.5</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -11,6 +11,7 @@ public class CommandFactory {
|
|||||||
commands.put("PLAYERS", new PlayersCommand());
|
commands.put("PLAYERS", new PlayersCommand());
|
||||||
commands.put("CPUUSAGE", new CpuUsageCommand());
|
commands.put("CPUUSAGE", new CpuUsageCommand());
|
||||||
commands.put("RAMUSAGE", new RamUsageCommand());
|
commands.put("RAMUSAGE", new RamUsageCommand());
|
||||||
|
commands.put("READLOGFILE", new ReadLogFileCommand());
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.mesacarlos.webconsole.websocket.command;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.java_websocket.WebSocket;
|
||||||
|
|
||||||
|
import com.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
import com.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
import com.mesacarlos.webconsole.websocket.response.ConsoleOutput;
|
||||||
|
|
||||||
|
public class ReadLogFileCommand implements WSCommand{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(WSServer wsServer, WebSocket conn, String params) {
|
||||||
|
List<String> lines = null;
|
||||||
|
try {
|
||||||
|
lines = Files.readAllLines(Paths.get("logs/latest.log"), StandardCharsets.UTF_8);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lines == null) {
|
||||||
|
Bukkit.getLogger().info(Internationalization.getPhrase("log-read-error"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String line : lines)
|
||||||
|
wsServer.sendToClient(conn, new ConsoleOutput(line));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user