Skip to content

Commit

Permalink
feat: Implement TRACE & WARN log levels from guacamole.
Browse files Browse the repository at this point in the history
  • Loading branch information
crykn committed Oct 29, 2023
1 parent 8cbce7a commit 2a2884a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ allprojects {

freetypeSkinVersion = "0.3.1"
gdxVersion = "1.12.0"
guacamoleVersion = "dbec4e0767" // = 0.3.4
guacamoleVersion = "2b4bd65404" // = 0.3.4
reflectionsVersion = "0.11.5"
screenmanagerVersion = "5f1dd79fef" // = 0.7.0
vfxVersion = "0.6.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ public void create() {
Gdx.app.setApplicationLogger(ReflectionUtils.newInstanceOrNull(
"de.eskalon.commons.log.EskalonDesktopLogger",
ApplicationLogger.class));
if (startArgs.shouldEnableDebugLogging())
LoggerService.showAll();
else
LoggerService.showInfoAndErrors();

LoggerService.setLogLevel(startArgs.getLogLevel());

/*
* CREATE APP CONTEXT
Expand Down
18 changes: 12 additions & 6 deletions core/src/main/java/de/eskalon/commons/core/StartArguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@

package de.eskalon.commons.core;

import de.damios.guacamole.gdx.log.LoggerService.LogLevel;

/**
* This class represents the arguments passed to the application from outside.
*/
public class StartArguments {

private boolean enableDebugLoggingOnStartup;
private LogLevel logLevel = LogLevel.INFO;
private boolean skipSplashScreen;

/* Builder */
Expand All @@ -36,8 +38,13 @@ private StartArgumentsBuilder() {
this.ret = new StartArguments();
}

public StartArgumentsBuilder enableTraceLogging() {
ret.logLevel = LogLevel.TRACE;
return this;
}

public StartArgumentsBuilder enableDebugLogging() {
ret.enableDebugLoggingOnStartup = true;
ret.logLevel = LogLevel.DEBUG;
return this;
}

Expand All @@ -57,8 +64,8 @@ private StartArguments() {
// reduce visibility
}

public boolean shouldEnableDebugLogging() {
return enableDebugLoggingOnStartup;
public LogLevel getLogLevel() {
return logLevel;
}

public boolean shouldSkipSplashScreen() {
Expand All @@ -67,8 +74,7 @@ public boolean shouldSkipSplashScreen() {

@Override
public String toString() {
return "StartArguments{enableDebugLoggingOnStartup="
+ enableDebugLoggingOnStartup + ",skipSplashScreen="
return "StartArguments{logLevel=" + logLevel + ",skipSplashScreen="
+ skipSplashScreen + "}";
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/de/eskalon/commons/event/EventBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ public void post(Object event) {
}
} else {
if (event instanceof ExceptionEvent)
LOG.debug(
LOG.warn(
"An ExceptionEvent was thrown, but no subscriber is registered for it.");
else if (event instanceof DeadEvent)
LOG.debug(
LOG.warn(
"A DeadEvent was thrown, but no subscriber is registered for it.");
else
post(new DeadEvent(event));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public <T> T getInstance(Class<T> type) {
return value;
}
} else {
LOG.debug(
LOG.trace(
"The qualified provider for type '%s' was skipped since no matching qualifier ('@%s') was present on the field.",
type, qualifiedProviderBinding.qualifierClass
.getSimpleName());
Expand All @@ -215,14 +215,14 @@ public <T> T getInstance(Class<T> type) {
// NOTE: don't try to inject the value's members in this case;
// the class would have been registered if it expected field
// injection to happen
LOG.debug("Falling back to constructor reflection for type %s",
LOG.trace("Falling back to constructor reflection for type %s",
type);
return value;
}
}

/* Dependency could not be resolved */
LOG.debug("The dependency '%s' could not be resolved.", type);
LOG.warn("The dependency '%s' could not be resolved.", type);

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static String getSimpleIdentifier() {
s.useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
} catch (IOException e) {
LOG.debug(e.getLocalizedMessage());
LOG.warn(e.getLocalizedMessage());
return null;
}
}
Expand All @@ -92,7 +92,7 @@ public static String getSimpleIdentifier() {
return nwi.getHardwareAddress();

} catch (SocketException | UnknownHostException e) {
LOG.debug(e.getLocalizedMessage());
LOG.warn(e.getLocalizedMessage());
}
return null;
}
Expand Down

0 comments on commit 2a2884a

Please sign in to comment.