From 0f9885bbf88826101286045e6c0e082fafc4bc3e Mon Sep 17 00:00:00 2001 From: Willem Date: Thu, 3 Mar 2022 03:20:14 +0100 Subject: [PATCH] Logging fixup --- .../boot/desktop/GDXAppDesktopConfig.java | 16 +++--- .../gdxapp4d/tos4/GDXAppTos4Activator.java | 55 ++++++++++++++++++- .../gdxapp4d/tos4/GDXAppTos4Startup.java | 43 +-------------- .../gdxapp4d/tos4/service/SystemGdxLog.java | 4 ++ 4 files changed, 68 insertions(+), 50 deletions(-) diff --git a/gdxapp4d-boot-desktop/src/main/java/love/distributedrebirth/gdxapp4d/boot/desktop/GDXAppDesktopConfig.java b/gdxapp4d-boot-desktop/src/main/java/love/distributedrebirth/gdxapp4d/boot/desktop/GDXAppDesktopConfig.java index 05f82405..f5aa2142 100644 --- a/gdxapp4d-boot-desktop/src/main/java/love/distributedrebirth/gdxapp4d/boot/desktop/GDXAppDesktopConfig.java +++ b/gdxapp4d-boot-desktop/src/main/java/love/distributedrebirth/gdxapp4d/boot/desktop/GDXAppDesktopConfig.java @@ -1,5 +1,8 @@ package love.distributedrebirth.gdxapp4d.boot.desktop; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; /** @@ -8,6 +11,7 @@ import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") public final class GDXAppDesktopConfig { + private static final Logger LOG = LoggerFactory.getLogger(GDXAppDesktopConfig.class); public static int WINDOW_WIDTH = 1024; public static int WINDOW_HEIGHT = 768; public static String WINDOW_TITLE = "GDXApp⁴ᴰ"; @@ -18,12 +22,10 @@ public final class GDXAppDesktopConfig { }; public static void printBootMessage() { - System.out.println("=========================="); - System.out.println(" @Ω仙⁴ ˧꜏⋇꜊꜔ ⁴ﷲΩ@ "); - System.out.println(" ©Δ∞ 仙上主天 "); - System.out.println("בְּרֵאשִׁית :o: יְסוֺד :o: יִשְׂרָאֵל"); - System.out.println("=========================="); - System.out.println("..Welcome to: Thy Matrix.."); - System.out.println("..Starting GDXApp⁴ᴰ now;.."); + LOG.info("=========================="); + LOG.info(" @Ω仙⁴ ˧꜏⋇꜊꜔ ⁴ﷲΩ@ "); + LOG.info(" ©Δ∞ 仙上主天 "); + LOG.info("בְּרֵאשִׁית :o: יְסוֺד :o: יִשְׂרָאֵל"); + LOG.info("=========================="); } } diff --git a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java index 90cc9833..fa0760ea 100644 --- a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java +++ b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java @@ -14,10 +14,13 @@ import java.util.function.Consumer; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.x4o.xml.io.X4OConnectionException; import org.xml.sax.SAXException; +import com.badlogic.gdx.Application; +import com.badlogic.gdx.ApplicationLogger; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; @@ -43,6 +46,7 @@ import net.spookygames.gdx.nativefilechooser.NativeFileChooser; @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") public class GDXAppTos4Activator implements BundleActivator { + private static final Logger LOG = LoggerFactory.getLogger(GDXAppTos4Activator.class); private List args; private int viewWidth; private int viewHeight; @@ -168,9 +172,13 @@ public class GDXAppTos4Activator implements BundleActivator { context.registerService(SystemWarpBase.class.getName(), new SystemWarpBaseImpl(), new Hashtable()); context.registerService(SystemWarpShip.class.getName(), systemWarpShip, new Hashtable()); - + + SystemGdxLogImpl systemGdxLog = new SystemGdxLogImpl(); + Gdx.app.setLogLevel(Application.LOG_DEBUG); + Gdx.app.setApplicationLogger(systemGdxLog); + context.registerService(SystemGdxFont.class.getName(), new SystemGdxFontImpl(gdxFont), new Hashtable()); - context.registerService(SystemGdxLog.class.getName(), new SystemGdxLogImpl(), new Hashtable()); + context.registerService(SystemGdxLog.class.getName(), systemGdxLog, new Hashtable()); context.registerService(SystemGdxBootArgs.class.getName(), new SystemGdxBootArgsImpl(), new Hashtable()); context.registerService(SystemGdxTerminal.class.getName(), systemGdxTerminal, new Hashtable()); @@ -311,6 +319,7 @@ public class GDXAppTos4Activator implements BundleActivator { } else { waterHome = new File(override); } + LOG.debug("loadWaterOcean key={} home={}",key, waterHome); File waterSea = new File(waterHome, Warpᵐᵉ.WARP_SEA); if (!waterSea.exists()) { logger.accept("ERROR: No warp-sea.xml found."); @@ -347,18 +356,28 @@ public class GDXAppTos4Activator implements BundleActivator { } } - public static class SystemGdxLogImpl implements SystemGdxLog { + public static class SystemGdxLogImpl implements SystemGdxLog, ApplicationLogger { @Override public void infoTag(String tag, String message, Object...args) { LoggerFactory.getLogger(tag).info(message, args); } + @Override + public void infoTag(String tag, String message, Throwable exception) { + LoggerFactory.getLogger(tag).info(message, exception); + } + @Override public void debugTag(String tag, String message, Object...args) { LoggerFactory.getLogger(tag).debug(message, args); } + @Override + public void debugTag(String tag, String message, Throwable exception) { + LoggerFactory.getLogger(tag).debug(message, exception); + } + @Override public void errorTag(String tag, String message, Object...args) { LoggerFactory.getLogger(tag).error(message, args); @@ -368,6 +387,36 @@ public class GDXAppTos4Activator implements BundleActivator { public void errorTag(String tag, String message, Throwable exception) { LoggerFactory.getLogger(tag).error(message, exception); } + + @Override + public void log(String tag, String message) { + infoTag(tag, message); + } + + @Override + public void log(String tag, String message, Throwable exception) { + infoTag(tag, message, exception); + } + + @Override + public void error(String tag, String message) { + errorTag(tag, message); + } + + @Override + public void error(String tag, String message, Throwable exception) { + errorTag(tag, message, exception); + } + + @Override + public void debug(String tag, String message) { + debugTag(tag, message); + } + + @Override + public void debug(String tag, String message, Throwable exception) { + debugTag(tag, message, exception); + } } public static class SystemGdxFontImpl implements SystemGdxFont { diff --git a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Startup.java b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Startup.java index 8973c234..052c4b5d 100644 --- a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Startup.java +++ b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Startup.java @@ -5,8 +5,6 @@ import org.osgi.framework.launch.Framework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.badlogic.gdx.Application; -import com.badlogic.gdx.ApplicationLogger; import com.badlogic.gdx.Gdx; import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; @@ -17,10 +15,7 @@ public class GDXAppTos4Startup { private static final Logger LOG = LoggerFactory.getLogger(GDXAppTos4Startup.class); public static Framework init(GDXAppTos4 tos4, GDXAppTos4Activator systemActivator) { - LOG.info("init framework"); - Gdx.app.setLogLevel(Application.LOG_DEBUG); - Gdx.app.setApplicationLogger(new GDXAppApplicationLogger()); - + LOG.info("Startup framework"); final Framework systemBundle = GDXAppTos4BootFactory.createFramework(); final GDXAppTos4BootScreen bootScreen = new GDXAppTos4BootScreen(); @@ -32,10 +27,11 @@ public class GDXAppTos4Startup { try { systemBundle.init(); systemBundle.start(); + LOG.debug("Startup system-activator"); systemActivator.start(systemBundle.getBundleContext()); Gdx.app.postRunnable(() -> { - LOG.debug("Release boot screen"); + LOG.debug("Release boot-screen"); systemActivator.removeBootListener(bootScreen); tos4.disposeScreen(bootScreen); }); @@ -49,37 +45,4 @@ public class GDXAppTos4Startup { return systemBundle; } - - static class GDXAppApplicationLogger implements ApplicationLogger { - - @Override - public void log(String tag, String message) { - LoggerFactory.getLogger(tag).info(message); - } - - @Override - public void log(String tag, String message, Throwable exception) { - LoggerFactory.getLogger(tag).info(message, exception); - } - - @Override - public void error(String tag, String message) { - LoggerFactory.getLogger(tag).error(message); - } - - @Override - public void error(String tag, String message, Throwable exception) { - LoggerFactory.getLogger(tag).error(message, exception); - } - - @Override - public void debug(String tag, String message) { - LoggerFactory.getLogger(tag).debug(message); - } - - @Override - public void debug(String tag, String message, Throwable exception) { - LoggerFactory.getLogger(tag).debug(message, exception); - } - } } diff --git a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/service/SystemGdxLog.java b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/service/SystemGdxLog.java index 16777657..5f48b7c3 100644 --- a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/service/SystemGdxLog.java +++ b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/service/SystemGdxLog.java @@ -7,8 +7,12 @@ public interface SystemGdxLog { void infoTag(String tag, String message, Object...args); + void infoTag(String tag, String message, Throwable exception); + void debugTag(String tag, String message, Object...args); + void debugTag(String tag, String message, Throwable exception); + void errorTag(String tag, String message, Object...args); void errorTag(String tag, String message, Throwable exception);