From d3a094b83d3f298bf1a20f6252ce299cb3c40a16 Mon Sep 17 00:00:00 2001 From: aj Date: Wed, 22 May 2019 13:29:21 +0100 Subject: [PATCH] removed boolean for std out console, objectified --- .../fx/controller/RootController.java | 3 +-- src/main/java/sarsoo/fmframework/log/Log.java | 18 ++++++------------ .../fmframework/log/console/STDOutConsole.java | 10 ++++++++++ 3 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 src/main/java/sarsoo/fmframework/log/console/STDOutConsole.java diff --git a/src/main/java/sarsoo/fmframework/fx/controller/RootController.java b/src/main/java/sarsoo/fmframework/fx/controller/RootController.java index bf984ea..3310268 100644 --- a/src/main/java/sarsoo/fmframework/fx/controller/RootController.java +++ b/src/main/java/sarsoo/fmframework/fx/controller/RootController.java @@ -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(); diff --git a/src/main/java/sarsoo/fmframework/log/Log.java b/src/main/java/sarsoo/fmframework/log/Log.java index 502a60e..53e86da 100644 --- a/src/main/java/sarsoo/fmframework/log/Log.java +++ b/src/main/java/sarsoo/fmframework/log/Log.java @@ -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 consoles = new ArrayList(); - private Boolean writeToSTDOut; - private ArrayList logList = new ArrayList(); private ArrayList infoList = new ArrayList(); private ArrayList errorList = new ArrayList(); @@ -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() { diff --git a/src/main/java/sarsoo/fmframework/log/console/STDOutConsole.java b/src/main/java/sarsoo/fmframework/log/console/STDOutConsole.java new file mode 100644 index 0000000..817c5a1 --- /dev/null +++ b/src/main/java/sarsoo/fmframework/log/console/STDOutConsole.java @@ -0,0 +1,10 @@ +package sarsoo.fmframework.log.console; + +public class STDOutConsole implements Console { + + @Override + public void write(String string) { + System.out.println(string); + } + +}