diff --git a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/LogListenerCommand.java b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/LogListenerCommand.java
index d2a2533f..385c6cf3 100644
--- a/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/LogListenerCommand.java
+++ b/LaunchServerConsole/src/main/java/ru/gravit/launchserver/console/LogListenerCommand.java
@@ -1,5 +1,6 @@
package ru.gravit.launchserver.console;
+import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.request.LogEvent;
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
import ru.gravit.launcher.request.websockets.RequestInterface;
@@ -9,6 +10,13 @@
public class LogListenerCommand extends Command {
public class LogListenerRequest implements RequestInterface
{
+ @LauncherNetworkAPI
+ public LogHelper.OutputTypes outputType;
+
+ public LogListenerRequest(LogHelper.OutputTypes outputType) {
+ this.outputType = outputType;
+ }
+
@Override
public String getType() {
return "addLogListener";
@@ -27,7 +35,7 @@ public String getUsageDescription() {
@Override
public void invoke(String... args) throws Exception {
LogHelper.info("Send log listener request");
- LegacyRequestBridge.service.sendObject(new LogListenerRequest());
+ LegacyRequestBridge.service.sendObject(new LogListenerRequest(LogHelper.JANSI ? LogHelper.OutputTypes.JANSI : LogHelper.OutputTypes.PLAIN));
LogHelper.info("Add log handler");
LegacyRequestBridge.service.registerHandler((result) -> {
if(result instanceof LogEvent)
diff --git a/libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java b/libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java
index 8d82539e..fd7752c0 100644
--- a/libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java
+++ b/libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java
@@ -26,7 +26,7 @@ private static void printCommand(String name, Command command) {
ansi.a(command.getUsageDescription());
ansi.reset();
return ansi.toString();
- });
+ }, () -> LogHelper.htmlFormatLog(LogHelper.Level.INFO, LogHelper.getDataTime(), String.format("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription()), true));
}
private static void printCategory(String name, String description)
diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java
index 53c86d62..01baaeb3 100644
--- a/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java
+++ b/libLauncher/src/main/java/ru/gravit/utils/helper/LogHelper.java
@@ -168,7 +168,7 @@ public static String getDataTime()
@LauncherAPI
public static void log(Level level, String message, boolean sub) {
String dateTime = DATE_TIME_FORMATTER.format(LocalDateTime.now());
- String jansiString = null, plainString = null;
+ String jansiString = null, plainString = null, htmlString = null;
for (OutputEnity output : OUTPUTS) {
if (output.type == OutputTypes.JANSI && JANSI) {
if (jansiString != null) {
@@ -178,6 +178,14 @@ public static void log(Level level, String message, boolean sub) {
jansiString = ansiFormatLog(level, dateTime, message, sub);
output.output.println(jansiString);
+ } else if (output.type == OutputTypes.HTML) {
+ if (htmlString != null) {
+ output.output.println(htmlString);
+ continue;
+ }
+
+ htmlString = htmlFormatLog(level, dateTime, message, sub);
+ output.output.println(htmlString);
} else {
if (plainString != null) {
output.output.println(plainString);
@@ -192,7 +200,12 @@ public static void log(Level level, String message, boolean sub) {
@LauncherAPI
public static void rawLog(Supplier plainStr, Supplier jansiStr)
{
- String jansiString = null, plainString = null;
+ rawLog(plainStr, jansiStr, null);
+ }
+ @LauncherAPI
+ public static void rawLog(Supplier plainStr, Supplier jansiStr, Supplier htmlStr)
+ {
+ String jansiString = null, plainString = null, htmlString = null;
for (OutputEnity output : OUTPUTS) {
if (output.type == OutputTypes.JANSI && JANSI) {
if (jansiString != null) {
@@ -202,6 +215,14 @@ public static void rawLog(Supplier plainStr, Supplier jansiStr)
jansiString = jansiStr.get();
output.output.println(jansiString);
+ } else if (output.type == OutputTypes.HTML) {
+ if (htmlString != null) {
+ output.output.println(htmlString);
+ continue;
+ }
+
+ htmlString = htmlStr.get();
+ output.output.println(htmlString);
} else {
if (plainString != null) {
output.output.println(plainString);
@@ -377,6 +398,23 @@ public static Ansi rawAnsiFormat(Level level, String dateTime, boolean sub)
return ansi;
}
+ public static String htmlFormatLog(Level level, String dateTime, String message, boolean sub)
+ {
+ String levelColor;
+ switch (level) {
+ case WARNING:
+ levelColor = "yellow";
+ break;
+ case ERROR:
+ levelColor = "red";
+ break;
+ default: // INFO, DEBUG, Unknown
+ levelColor = "white";
+ break;
+ }
+ return String.format("%s [%s] %s", dateTime, levelColor, level.toString(), sub ? ' ' + message : message);
+ }
+
private static String ansiFormatVersion(String product) {
return new Ansi().bold(). // Setup
fgBright(Color.MAGENTA).a("GravitLauncher "). // sashok724's