mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 00:40:51 +01:00
Added dedicated loggers for each extension if logger flag is set
This commit is contained in:
parent
c603cdbd61
commit
8b8c4fff72
@ -12,7 +12,9 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
@ -110,36 +112,37 @@ public final class NormalExtensionRunner implements ExtensionRunner {
|
||||
final Process process = processBuilder.start();
|
||||
|
||||
maybeLogExtension(path, process);
|
||||
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Failed to run extension at path {} using port {}", path, port, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void maybeLogExtension(String path, Process process) {
|
||||
if (GEarth.hasFlag(ExtensionRunner.SHOW_EXTENSIONS_LOG)) {
|
||||
|
||||
final String separator = "" + System.lineSeparator();
|
||||
LOGGER.info(path + separator + "Launching" + separator + "----------" + separator);
|
||||
final Logger logger = LoggerFactory.getLogger(path);
|
||||
|
||||
logger.info("Launching...");
|
||||
|
||||
final BufferedReader processInputReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
String line;
|
||||
while ((line = processInputReader.readLine()) != null)
|
||||
LOGGER.info(path + separator + "Output" + separator + line + separator + "----------" + separator);
|
||||
logger.info(line);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Failed to read input line from process {}", process, e);
|
||||
}
|
||||
}).start();
|
||||
}, path+"-input").start();
|
||||
|
||||
final BufferedReader processErrorReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
||||
new Thread(() -> {
|
||||
try {
|
||||
String line;
|
||||
while((line = processErrorReader.readLine()) != null) {
|
||||
LOGGER.error(path + separator + "Error" + separator + line + separator + "----------" + separator);
|
||||
}
|
||||
while ((line = processErrorReader.readLine()) != null)
|
||||
logger.error(line);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Failed to read error line from process {}", process, e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user