package com.fatico.winthing;

import com.fatico.winthing.gui.WindowGui;
import com.fatico.winthing.messaging.Engine;

import com.google.inject.Guice;
import com.google.inject.Injector;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Application {
    private boolean debug = false;
    private static Application app = new Application();
    private static final Logger logger = LoggerFactory.getLogger(Application.class);

    private void parseArgs(String[] args) {
        for (String arg : args) {
            if (arg.equals("-debug")) {
                debug = true;
            }
        }
    }

    public static boolean debug() {
        return app.debug;
    }

    public static void quit() {
        logger.info("Application terminated.");
        System.exit(0);
    }

    public static void main(final String[] args) {
        try {
            app.parseArgs(args);
            WindowGui gui = WindowGui.getInstance();
            gui.tray();

            final Injector injector = Guice.createInjector(new ApplicationModule());
            final Engine engine = injector.getInstance(Engine.class);
            engine.run();

        } catch (final Throwable throwable) {
            logger.error("Critical error.", throwable);
            System.exit(1);
        }
    }
}

@@ -268,43 +268,8 @@
 n %7B%0A
-    private boolean debug = false;%0A
     
@@ -283,16 +283,22 @@
  static 
+final 
 Applicat
@@ -322,24 +322,25 @@
 lication();%0A
+%0A
     private 
@@ -343,79 +343,83 @@
 ate 
-static final Logger logger = LoggerFactory.getLogger(Application.class)
+boolean debug = false;%0A    private WindowGui gui;%0A    private Logger logger
 ;%0A%0A 
@@ -657,32 +657,102 @@
 p.debug;%0A    %7D%0A%0A
+    public static WindowGui getApp() %7B%0A        return app.gui;%0A    %7D%0A%0A
     public stati
@@ -771,24 +771,28 @@
 ) %7B%0A        
+app.
 logger.info(
@@ -944,24 +944,25 @@
 Args(args);%0A
+%0A
             
@@ -965,23 +965,91 @@
     
-WindowGui 
+app.logger = LoggerFactory.getLogger(Application.class);%0A%0A            app.
 gui =
+ new
  Win
@@ -1054,28 +1054,16 @@
 indowGui
-.getInstance
 ();%0A    
@@ -1074,16 +1074,26 @@
     
-gui.tray
+app.gui.initialize
 ();%0A
@@ -1333,16 +1333,20 @@
         
+app.
 logger.e

Change how GUI and logger is created. Initialize logger after we get console parameters and only then initialize logger.