removed boolean for std out console, objectified

This commit is contained in:
aj 2019-05-22 13:29:21 +01:00
parent b37a16bb89
commit d3a094b83d
3 changed files with 17 additions and 14 deletions

View File

@ -20,7 +20,6 @@ import sarsoo.fmframework.config.VariableEvent;
import sarsoo.fmframework.config.VariableListener;
import sarsoo.fmframework.file.ListPersister;
import sarsoo.fmframework.fm.FmAuthNetwork;
import sarsoo.fmframework.fm.FmNetwork;
import sarsoo.fmframework.fx.TextAreaConsole;
import sarsoo.fmframework.fx.service.GetLastTrackService;
import sarsoo.fmframework.fx.service.GetScrobbleCountService;
@ -55,7 +54,7 @@ public class RootController {
@FXML
public void initialize() {
Logger.setLog(new Log(TextAreaConsole.getInstance(), false));
Logger.setLog(new Log(TextAreaConsole.getInstance()));
Config config = FmFramework.getSessionConfig();

View File

@ -6,6 +6,7 @@ import java.time.LocalDateTime;
import java.util.ArrayList;
import sarsoo.fmframework.log.console.Console;
import sarsoo.fmframework.log.console.STDOutConsole;
import sarsoo.fmframework.log.entry.ErrorEntry;
import sarsoo.fmframework.log.entry.InfoEntry;
import sarsoo.fmframework.log.entry.LogEntry;
@ -14,8 +15,6 @@ public class Log {
private ArrayList<Console> consoles = new ArrayList<Console>();
private Boolean writeToSTDOut;
private ArrayList<LogEntry> logList = new ArrayList<LogEntry>();
private ArrayList<InfoEntry> infoList = new ArrayList<InfoEntry>();
private ArrayList<ErrorEntry> errorList = new ArrayList<ErrorEntry>();
@ -23,20 +22,19 @@ public class Log {
private LocalDateTime createdTime = LocalDateTime.now();
public Log() {
writeToSTDOut = true;
consoles.add(new STDOutConsole());
}
public Log(Console console, Boolean toSTD) {
public Log(Console... consoles) {
consoles.add(console);
writeToSTDOut = toSTD;
for(Console console: consoles) {
this.consoles.add(console);
}
}
public void clearConsoles() {
consoles.clear();
writeToSTDOut = true;
}
public void log(LogEntry entry) {
@ -64,10 +62,6 @@ public class Log {
i.write(logString);
}
}
if (writeToSTDOut == true) {
System.out.println(logString);
}
}
public void dumpLog() {

View File

@ -0,0 +1,10 @@
package sarsoo.fmframework.log.console;
public class STDOutConsole implements Console {
@Override
public void write(String string) {
System.out.println(string);
}
}