Skip to content
Snippets Groups Projects
Commit a94093fc authored by Matyáš Latner's avatar Matyáš Latner
Browse files

#1 Choose debug level by build type

parent 866d1219
No related branches found
No related tags found
No related merge requests found
package cz.nic.tablexia;
import java.util.Locale;
import net.engio.mbassy.listener.Handler;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.badlogic.gdx.utils.reflect.ReflectionException;
import net.engio.mbassy.listener.Handler;
import java.util.Locale;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.bus.ApplicationBus.ApplicationEvent;
import cz.nic.tablexia.loader.ApplicationFontManager;
......@@ -21,7 +21,6 @@ import cz.nic.tablexia.screen.LoaderScreen;
import cz.nic.tablexia.screen.ScreenDefinition;
import cz.nic.tablexia.screen.gamemenu.GameMenuScreen;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.Log.TablexiaLogLevel;
public class Tablexia extends TablexiaApplication {
......@@ -61,8 +60,7 @@ public class Tablexia extends TablexiaApplication {
super.create();
TablexiaSettings.getInstance().loadPreferences();
//TODO set log level for build variant
Log.setLoglevel(TablexiaLogLevel.DEBUG);
Log.setLoglevel(TablexiaSettings.getInstance().getLogLevel());
// init event bus handlers
ApplicationBus.getInstance().subscribe(this);
......
......@@ -11,23 +11,29 @@ public class TablexiaSettings {
public static enum BuildVariant {
RELEASE("release", false),
DEBUG("debug", true);
RELEASE("release", false, Log.TablexiaLogLevel.ERROR),
DEBUG("debug", true, Log.TablexiaLogLevel.DEBUG);
private final static BuildVariant FALLBACK_VARIANT = BuildVariant.DEBUG;
private final String key;
private final boolean isDebug;
private Log.TablexiaLogLevel logLevel;
private BuildVariant(String key, boolean isDebug) {
private BuildVariant(String key, boolean isDebug, Log.TablexiaLogLevel logLevel) {
this.key = key;
this.isDebug = isDebug;
this.logLevel = logLevel;
}
public boolean isDebug() {
return isDebug;
}
public Log.TablexiaLogLevel getLogLevel() {
return logLevel;
}
public static BuildVariant getBuildVariantForKey(String key) {
for(BuildVariant buildVariant: BuildVariant.values()) {
if (buildVariant.key.equals(key)) {
......@@ -141,6 +147,10 @@ public class TablexiaSettings {
return isDebug() && DEBUG_SHOW_BOUNDING_BOXES;
}
public Log.TablexiaLogLevel getLogLevel() {
return BUILD_VARIANT.getLogLevel();
}
public void setLocale(LocaleDefinition localeDefinition) {
selectedLocale = localeDefinition;
preferences.putString(LOCALE_KEY, localeDefinition.getLocaleKey());
......
package cz.nic.tablexia.loader;
import java.util.Locale;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.I18NBundle;
import com.badlogic.gdx.utils.async.AsyncTask;
import java.util.Locale;
import cz.nic.tablexia.game.loader.AbstractDataManager;
import cz.nic.tablexia.loader.IApplicationLoader;
import cz.nic.tablexia.util.Log;
/**
* Texture loader and manager for application context.
......@@ -49,7 +49,8 @@ public class ApplicationTextManager extends AbstractDataManager<I18NBundle> impl
}
public void load(Locale locale) {
setAsyncTask(new RobberyTextLoader(ROBBERY_TEXT, locale));
Log.info(getClass(), "Loading application texts with locale: " + locale);
setAsyncTask(new RobberyTextLoader(ROBBERY_TEXT, locale));
}
@Override
......
......@@ -213,22 +213,22 @@ public abstract class AbstractTablexiaScreen<T> extends ScreenAdapter {
//////////////////////////// TABLEXIA SCREEN LIFECYCLE
private final void performScreenLoaded() {
Log.info(getClass().getName(), "[ ------- Screen Loaded ------- ]");
Log.info(getClass(), "[ ------- Screen Loaded ------- ]");
screenLoaded();
}
public final void performScreenVisible() {
Log.info(getClass().getName(), "[ ------- Screen Visible ------- ]");
Log.info(getClass(), "[ ------- Screen Visible ------- ]");
screenVisible();
}
private final void performScreenResized(int width, int height) {
Log.info(getClass().getName(), "[ ------- Screen Resized ------- ]");
Log.info(getClass(), "[ ------- Screen Resized ------- ]");
screenResized(width, height);
}
private final void performScreenDisposed() {
Log.info(getClass().getName(), "[ ------- Screen Disposed ------- ]");
Log.info(getClass(), "[ ------- Screen Disposed ------- ]");
screenDisposed();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment