Logging fixup

This commit is contained in:
Willem Cazander 2022-03-03 03:20:14 +01:00
parent 3e782452aa
commit 0f9885bbf8
4 changed files with 68 additions and 50 deletions

View file

@ -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("==========================");
}
}

View file

@ -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<String> 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<String, String>());
context.registerService(SystemWarpShip.class.getName(), systemWarpShip, new Hashtable<String, String>());
SystemGdxLogImpl systemGdxLog = new SystemGdxLogImpl();
Gdx.app.setLogLevel(Application.LOG_DEBUG);
Gdx.app.setApplicationLogger(systemGdxLog);
context.registerService(SystemGdxFont.class.getName(), new SystemGdxFontImpl(gdxFont), new Hashtable<String, String>());
context.registerService(SystemGdxLog.class.getName(), new SystemGdxLogImpl(), new Hashtable<String, String>());
context.registerService(SystemGdxLog.class.getName(), systemGdxLog, new Hashtable<String, String>());
context.registerService(SystemGdxBootArgs.class.getName(), new SystemGdxBootArgsImpl(), new Hashtable<String, String>());
context.registerService(SystemGdxTerminal.class.getName(), systemGdxTerminal, new Hashtable<String, String>());
@ -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 {

View file

@ -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);
}
}
}

View file

@ -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);