|
@@ -52,8 +52,14 @@ import org.apache.commons.cli.OptionBuilder;
|
|
|
import org.apache.commons.cli.OptionGroup;
|
|
|
import org.apache.commons.cli.Options;
|
|
|
import org.apache.commons.cli.ParseException;
|
|
|
+import org.apache.logging.log4j.Level;
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
+import org.apache.logging.log4j.Logger;
|
|
|
+import org.apache.logging.log4j.core.LoggerContext;
|
|
|
+import org.apache.logging.log4j.core.config.LoggerConfig;
|
|
|
+import org.apache.logging.log4j.io.IoBuilder;
|
|
|
+import org.apache.logging.log4j.io.LoggerOutputStream;
|
|
|
import org.yaml.snakeyaml.Yaml;
|
|
|
-import uk.co.caprica.vlcj.logger.Logger;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -62,6 +68,10 @@ import uk.co.caprica.vlcj.logger.Logger;
|
|
|
@SuppressWarnings("CallToPrintStackTrace")
|
|
|
public class Main extends javax.swing.JFrame
|
|
|
{
|
|
|
+ private static final Logger l = LogManager.getLogger(Main.class.getName());
|
|
|
+
|
|
|
+ private static boolean verboseMode=false;
|
|
|
+
|
|
|
|
|
|
public static final String CONFIGPATH = IZPLApi.APPDIR + File.separator + "config" + File.separator + "config.yml";
|
|
|
public static final Yaml y = new Yaml();
|
|
@@ -71,7 +81,7 @@ public class Main extends javax.swing.JFrame
|
|
|
|
|
|
// public static LogStream stdout;
|
|
|
private static final List<PlaybackPlugin> registeredPlayBackAdapters = new ArrayList<>();
|
|
|
- private static final List<FeaturePlugin> registeredFeatures = new ArrayList<>();
|
|
|
+ private static final List<FeaturePlugin> registeredFeatures = new ArrayList<>();
|
|
|
private static final List<UIPlugin> registeredUIs = new ArrayList<>();
|
|
|
private static final List<String> detectedSkins = new ArrayList<>();
|
|
|
private static boolean loadedVLC = false;
|
|
@@ -167,7 +177,7 @@ public class Main extends javax.swing.JFrame
|
|
|
{
|
|
|
|
|
|
processCommandLine(args);
|
|
|
- setupLogging();
|
|
|
+ //setupLogging(); //NOP-ed for test
|
|
|
|
|
|
try
|
|
|
{
|
|
@@ -175,11 +185,12 @@ public class Main extends javax.swing.JFrame
|
|
|
}
|
|
|
catch (IOException ex)
|
|
|
{
|
|
|
- System.out.println("Failed to load Icon");
|
|
|
+ l.warn("Failed to load Icon");
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
String time = new Date(System.currentTimeMillis()).toString();
|
|
|
- System.out.println("IZPL-Loader:Bootstrapped at:" + time);
|
|
|
+ l.log(Level.INFO, "IZPL-Loader:Bootstrapped at:{}", time);
|
|
|
+ Runtime.getRuntime().addShutdownHook(new Shitdown());
|
|
|
/* Set the Nimbus look and feel */
|
|
|
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
|
|
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
|
@@ -198,7 +209,8 @@ public class Main extends javax.swing.JFrame
|
|
|
}
|
|
|
catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex)
|
|
|
{
|
|
|
- java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
|
+ l.catching(Level.ERROR, ex);
|
|
|
+
|
|
|
}
|
|
|
//</editor-fold>
|
|
|
if(firstrunmode)
|
|
@@ -211,16 +223,16 @@ public class Main extends javax.swing.JFrame
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- System.out.println("Loading the configs now");
|
|
|
+ l.info("Loading the configs now");
|
|
|
loadConfigs();
|
|
|
if(CONFIG.isStandaloneMode())
|
|
|
{
|
|
|
useGUI=true;
|
|
|
}
|
|
|
detectSkins();
|
|
|
- System.out.println("Initializing the plugins now. This may take a while");
|
|
|
+ l.info("Initializing the plugins now. This may take a while");
|
|
|
initializePlugins();
|
|
|
- System.out.println("Plugins initialized");
|
|
|
+ l.info("Plugins initialized");
|
|
|
//TODO: GUI-Editor zum Erzeugen von iZpl-S
|
|
|
|
|
|
|
|
@@ -235,11 +247,13 @@ public class Main extends javax.swing.JFrame
|
|
|
b.setIconImage(playListIcon);
|
|
|
b.setVisible(true);
|
|
|
|
|
|
- new Thread(() ->
|
|
|
+ Thread t1 = new Thread(() ->
|
|
|
{
|
|
|
startup();
|
|
|
- }).start();
|
|
|
- new Thread(() ->
|
|
|
+ });
|
|
|
+ t1.setName("IZPL-Backend");
|
|
|
+ t1.start();
|
|
|
+ Thread t2 = new Thread(() ->
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -255,7 +269,9 @@ public class Main extends javax.swing.JFrame
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
b.setVisible(false);
|
|
|
- }).start();
|
|
|
+ });
|
|
|
+ t2.setName("LoadCloser");
|
|
|
+ t2.start();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -275,7 +291,7 @@ public class Main extends javax.swing.JFrame
|
|
|
}
|
|
|
catch (ParseException ex)
|
|
|
{
|
|
|
- System.err.println(ex.getMessage());
|
|
|
+ l.error(ex.getMessage());
|
|
|
System.exit(0);
|
|
|
}
|
|
|
}
|
|
@@ -386,7 +402,7 @@ public class Main extends javax.swing.JFrame
|
|
|
{
|
|
|
if (filemode)
|
|
|
{
|
|
|
- System.out.println("Error: --file & --resume & --burn can't be specified at the same time");
|
|
|
+ l.error("Error: --file & --resume & --burn can't be specified at the same time");
|
|
|
System.exit(9263);
|
|
|
}
|
|
|
statefile = true;
|
|
@@ -401,7 +417,7 @@ public class Main extends javax.swing.JFrame
|
|
|
{
|
|
|
listmode=false;
|
|
|
featurePluginID=cl.getOptionValue("e");
|
|
|
- System.out.println("Listmode disabled due to e param=\""+featurePluginID+"\"");
|
|
|
+ l.trace("Listmode disabled due to e param=\""+featurePluginID+"\"");
|
|
|
}
|
|
|
//handling für den ListPluginMode
|
|
|
if((filemode||statefile||listmode))
|
|
@@ -411,15 +427,15 @@ public class Main extends javax.swing.JFrame
|
|
|
if(listmode)
|
|
|
{
|
|
|
featurePluginID="";
|
|
|
- System.out.println("\"\"");
|
|
|
+ l.trace("\"\"");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- System.out.println("Error: FeaturePlugins need either a file or a statefile to resume");
|
|
|
+ l.error("Error: FeaturePlugins need either a file or a statefile to resume");
|
|
|
System.exit(9263);
|
|
|
}
|
|
|
- System.out.println("Parameter of e is now:\""+pluginParameter+"\"");
|
|
|
+ l.trace("Parameter of e is now:\""+pluginParameter+"\"");
|
|
|
}
|
|
|
|
|
|
if(cl.hasOption("x"))
|
|
@@ -436,7 +452,7 @@ public class Main extends javax.swing.JFrame
|
|
|
{
|
|
|
if (filemode || statefile)
|
|
|
{
|
|
|
- System.out.println("Error: --file & --resume & --burn can't be specified at the same time");
|
|
|
+ l.error("Error: --file & --resume & --burn can't be specified at the same time");
|
|
|
System.exit(9263);
|
|
|
}
|
|
|
burnDisc = true;
|
|
@@ -454,15 +470,29 @@ public class Main extends javax.swing.JFrame
|
|
|
{
|
|
|
if (!(filemode || statefile))
|
|
|
{
|
|
|
- System.out.println("Error: pregen only works on --file parameters");
|
|
|
+ l.error("Error: pregen only works on --file parameters");
|
|
|
System.exit(9263);
|
|
|
}
|
|
|
forcePregen = true;
|
|
|
}
|
|
|
+
|
|
|
+ LoggerContext cx = (LoggerContext) LogManager.getContext(false);
|
|
|
+ org.apache.logging.log4j.core.config.Configuration config = cx.getConfiguration();
|
|
|
+ LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
|
|
+
|
|
|
+ //TODO HANDLE VERBOSE!
|
|
|
+ uk.co.caprica.vlcj.logger.Logger.setLevel(uk.co.caprica.vlcj.logger.Logger.Level.INFO);
|
|
|
+ uk.co.caprica.vlcj.logger.Logger.outputTo(IoBuilder.forLogger("External").setLevel(Level.TRACE).buildOutputStream());
|
|
|
+
|
|
|
if (cl.hasOption("verbose"))
|
|
|
{
|
|
|
- Logger.setLevel(Logger.Level.INFO);
|
|
|
+ loggerConfig.setLevel(Level.TRACE);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ loggerConfig.setLevel(Level.INFO);
|
|
|
}
|
|
|
+ cx.updateLoggers();
|
|
|
//skinPath=DEFAULT_SKIN_PATH;
|
|
|
if (cl.hasOption("skin"))
|
|
|
{
|
|
@@ -494,28 +524,7 @@ public class Main extends javax.swing.JFrame
|
|
|
{
|
|
|
"BroadCatchBlock", "TooBroadCatch"
|
|
|
})
|
|
|
- private static void setupLogging()
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- if (Boolean.valueOf(Preferences.userRoot().get("izpl.enableFastDebug", "false")))
|
|
|
- {
|
|
|
- System.out.println("lfe");
|
|
|
- LogStream psOut = new LogStream(
|
|
|
- new BufferedOutputStream(new FileOutputStream(
|
|
|
- new File("iZpl.log"))), true, System.out);
|
|
|
- System.setOut(psOut);
|
|
|
- LogStream psOut2 = new LogStream(
|
|
|
- new BufferedOutputStream(new FileOutputStream(
|
|
|
- new File("iZpl-e.log"))), true, System.err);
|
|
|
- System.setErr(psOut2);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception e)//danke du komisher javabug
|
|
|
- {
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
private static void loadConfigs()
|
|
|
{
|
|
|
if (new File(CONFIGPATH).exists())
|
|
@@ -567,7 +576,7 @@ public class Main extends javax.swing.JFrame
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- System.out.println("No MediaPlayer executable set.");
|
|
|
+ l.error("No MediaPlayer executable set.");
|
|
|
quickQuit();
|
|
|
}
|
|
|
}
|
|
@@ -702,9 +711,11 @@ public class Main extends javax.swing.JFrame
|
|
|
//pluginhandling interception: abort load if only enumerating of Features is wanted
|
|
|
if(featurePluginMode && featurePluginID.equals(""))
|
|
|
{
|
|
|
+ //NOLOG
|
|
|
System.out.println("Features available:");
|
|
|
for (FeaturePlugin featurePlugin : registeredFeatures)
|
|
|
{
|
|
|
+ //NOLOG
|
|
|
System.out.println(featurePlugin.getPluginName());
|
|
|
}
|
|
|
quickQuit();
|
|
@@ -764,7 +775,7 @@ public class Main extends javax.swing.JFrame
|
|
|
}
|
|
|
if(featurePluginMode&&selectedFeaturePlugin==null)
|
|
|
{
|
|
|
- System.out.println("NO valid FeaturePlugin given");
|
|
|
+ l.error("NO valid FeaturePlugin given");
|
|
|
quickQuit();
|
|
|
}
|
|
|
if(!firstrunmode&&!updateInit&&!featurePluginMode)
|
|
@@ -786,12 +797,12 @@ public class Main extends javax.swing.JFrame
|
|
|
String time = "";
|
|
|
|
|
|
time = new Date(System.currentTimeMillis()).toString();
|
|
|
- System.out.println("IZPL-Core:initialized at:" + time);
|
|
|
+ l.info("IZPL-Core:initialized at:" + time);
|
|
|
String vlcpath = CONFIG.getMPExecutablePath();
|
|
|
- System.err.println("vlcpath=" + vlcpath);
|
|
|
+ l.info("vlcpath=" + vlcpath);
|
|
|
if(!(useGUI||featurePluginMode)&&vlcpath.equals("")&&!new File(vlcpath).exists())
|
|
|
{
|
|
|
- System.out.println("ungültige MediaPlayer executable");
|
|
|
+ l.error("ungültige MediaPlayer executable");
|
|
|
quickQuit();
|
|
|
}
|
|
|
boolean isShittyPlayer = false;
|
|
@@ -807,11 +818,11 @@ public class Main extends javax.swing.JFrame
|
|
|
try
|
|
|
{
|
|
|
|
|
|
- System.out.println("fpl|" + forcePregen + "|shitmp|" + isShittyPlayer + "|a1|" + file_path + "|vp|" + vlcpath);
|
|
|
+ l.trace("fpl|" + forcePregen + "|shitmp|" + isShittyPlayer + "|a1|" + file_path + "|vp|" + vlcpath);
|
|
|
if ((filemode && !(forcePregen || isShittyPlayer))||featurePluginMode)
|
|
|
{
|
|
|
- System.out.println("usegui=" + useGUI);
|
|
|
- System.out.println("featurePlugin=" + featurePluginMode);
|
|
|
+ l.trace("usegui=" + useGUI);
|
|
|
+ l.trace("featurePlugin=" + featurePluginMode);
|
|
|
|
|
|
ps = new PLServer(/*"D:\\mp3\\iZpl\\rxe.izpl"/*/file_path/**/, !(useGUI||featurePluginMode));//DBG_CD3
|
|
|
if (issueDetected)
|
|
@@ -827,7 +838,7 @@ public class Main extends javax.swing.JFrame
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- System.err.println("TheFUQ");
|
|
|
+ l.trace("TheFUQ");
|
|
|
}
|
|
|
}
|
|
|
//http://localhost:9263/lst.m3u
|
|
@@ -853,14 +864,14 @@ public class Main extends javax.swing.JFrame
|
|
|
{
|
|
|
elemsforPreload *= 3;
|
|
|
}
|
|
|
- System.err.println("elemstogen|" + elemsforPreload);
|
|
|
+ l.trace("elemstogen|" + elemsforPreload);
|
|
|
String wmplist = "";
|
|
|
for (int i = 0; i < elemsforPreload; i++)
|
|
|
{
|
|
|
wmplist = wmplist + "\n" + ppp.getBlock();
|
|
|
}
|
|
|
//ps.ppp.setFailRSP(wmplist);
|
|
|
- System.err.println("Loop'd");
|
|
|
+ l.trace("Loop'd");
|
|
|
FileTK.writeFile("#extm3u+n" + wmplist, "wmpload.m3u");
|
|
|
}
|
|
|
|
|
@@ -891,8 +902,8 @@ public class Main extends javax.swing.JFrame
|
|
|
loadedVLC = true;
|
|
|
do
|
|
|
{
|
|
|
- crashed = Tools.runCmdStreamable(null, System.out, false, vlcpath, "--extraintf=cad",/* qt4"--extraintf=http:logger","--verbose=2","--file-logging","--logfile=vlc-log.txt",*/ "http://localhost:9263/rcvr/lst.m3u");//http://localhost:9263/lst.m3u");
|
|
|
- System.out.println("VLCExit");
|
|
|
+ crashed = Tools.runCmdStreamable(null, IoBuilder.forLogger("External").buildPrintStream(), false, vlcpath, "--extraintf=cad",/* qt4"--extraintf=http:logger","--verbose=2","--file-logging","--logfile=vlc-log.txt",*/ "http://localhost:9263/rcvr/lst.m3u");//http://localhost:9263/lst.m3u");
|
|
|
+ l.trace("VLCExit");
|
|
|
}
|
|
|
while (crashed);
|
|
|
}
|
|
@@ -990,7 +1001,7 @@ public class Main extends javax.swing.JFrame
|
|
|
br.readLine();//SYM
|
|
|
tpath = br.readLine();
|
|
|
sym = true;//näxxter lauf.....
|
|
|
- System.out.println("Symlink>> Dest=" + tpath);
|
|
|
+ l.info("Symlink>> Dest=" + tpath);
|
|
|
}
|
|
|
if (new String(magix).equals("!!de.nplusc.izc.iZpl.PlProcessorV2"))
|
|
|
{
|
|
@@ -1012,15 +1023,15 @@ public class Main extends javax.swing.JFrame
|
|
|
pp.InitializeOnPath(((PlProcessor) u).getPath());
|
|
|
}
|
|
|
plf.close();
|
|
|
- System.out.println("usegui=" + useGUI);
|
|
|
+ l.trace("usegui=" + useGUI);
|
|
|
ps = new PLServer(pp, !useGUI);
|
|
|
}
|
|
|
|
|
|
public static void checkpointedExit(boolean isShittyPlayer)
|
|
|
{
|
|
|
- System.err.println("<<<");
|
|
|
+ l.trace("<<<");
|
|
|
String time = new Date(System.currentTimeMillis()).toString();
|
|
|
- System.out.println("IZPL-Core:Checkpoint erstellen:" + time);
|
|
|
+ l.info("IZPL-Core:Checkpoint erstellen:" + time);
|
|
|
//muss nen StateSaver hier reintoasten....; done...
|
|
|
//statefile immer gleich genannt wie originaldatei; ermöglicht mehrere states...
|
|
|
if (!(forcePregen || isShittyPlayer))
|
|
@@ -1035,9 +1046,6 @@ public class Main extends javax.swing.JFrame
|
|
|
|
|
|
public static void quickQuit()
|
|
|
{
|
|
|
- String time2 = new Date(System.currentTimeMillis()).toString();
|
|
|
- System.err.println("IZPL-Core:SHitdown at:" + time2);
|
|
|
- System.out.println("IZPL-Core:SHitdown at:" + time2);
|
|
|
System.exit(0);
|
|
|
}
|
|
|
|
|
@@ -1097,6 +1105,11 @@ public class Main extends javax.swing.JFrame
|
|
|
return playListIcon;
|
|
|
}
|
|
|
|
|
|
+ public static boolean isVerboseMode()
|
|
|
+ {
|
|
|
+ return verboseMode;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/*
|
|
|
* Changelog:
|