Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change desktop logger to Logback #501

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/gradle/ide.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ext {
</pattern>
</extension>
<option name="MAIN_CLASS_NAME" value="org.destinationsol.desktop.SolDesktop"/>
<option name="VM_PARAMETERS" value="-splash:engine/src/main/resources/assets/textures/mainMenu/mainMenuLogo.png %s -Xms256m -Xmx1024m -Dlog4j.configuration=log4j-debug.properties"/>
<option name="VM_PARAMETERS" value="-splash:engine/src/main/resources/assets/textures/mainMenu/mainMenuLogo.png %s -Xms256m -Xmx1024m/>
<option name="PROGRAM_PARAMETERS" value="-noCrashReport %s"/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
Expand Down
18 changes: 13 additions & 5 deletions desktop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,27 @@ dependencies {
compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion"

compile group: 'org.terasology.crashreporter', name: 'cr-destsol', version: '4.0.0'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.25'

compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
runtime group: 'ch.qos.logback', name: 'logback-core', version: '1.2.3'
runtime group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'

/* Add this to the android distribution!
runtime group: 'com.github.tony19', name: 'logback-android', version: '2.0.0'
runtime group: 'com.github.tony19', name: 'logback-android-classic', version: '1.1.1-6'
*/
}

task run(type: JavaExec) {
dependsOn classes
//TODO: Remove extra args when the splash screen works on Macs again - see https://github.com/MovingBlocks/DestinationSol/issues/414
if (System.properties["os.name"].toLowerCase().contains("mac")) {
jvmArgs = ["-splash:../engine/src/main/resources/assets/textures/mainMenu/mainMenuLogo.png", "-XstartOnFirstThread", "-Dlog4j.configuration=log4j-debug.properties"]
jvmArgs = ["-splash:../engine/src/main/resources/assets/textures/mainMenu/mainMenuLogo.png", "-XstartOnFirstThread"]
String[] runArgs = ["-noSplash"]
args runArgs
}
else {
jvmArgs = ["-splash:../engine/src/main/resources/assets/textures/mainMenu/mainMenuLogo.png", "-Dlog4j.configuration=log4j-debug.properties"]
jvmArgs = ["-splash:../engine/src/main/resources/assets/textures/mainMenu/mainMenuLogo.png"]
}
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
Expand Down Expand Up @@ -148,7 +156,7 @@ eclipse {
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.destinationsol.desktop.SolDesktop"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="DestinationSol-desktop"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-splash:../engine/src/main/resources/assets/textures/mainMenu/mainMenuLogo.png -Dlog4j.configuration=log4j-debug.properties"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-splash:../engine/src/main/resources/assets/textures/mainMenu/mainMenuLogo.png"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:DestinationSol-engine}"/>
</launchConfiguration>
''')
Expand All @@ -174,6 +182,6 @@ task afterEclipseImport(description: "Post processing after project generation",

tasks.withType(JavaExec) {
if (System.getProperty('DEBUG', 'false') == 'true') {
jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9099', '-Dlog4j.configuration=log4j-debug.properties'
jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9099'
}
}
14 changes: 14 additions & 0 deletions desktop/src/main/resources/assets/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<tagEncoder>
<pattern>%logger{12}</pattern>
</tagEncoder>
<encoder>
<pattern>%-5level [%thread] (%F:%L) %message%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
4 changes: 4 additions & 0 deletions engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ dependencies {
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.22'
testCompile group: 'org.jboss.shrinkwrap', name: 'shrinkwrap-depchain-java7', version: '1.1.3'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.9.0'

// Logging
testRuntime group: 'ch.qos.logback', name: 'logback-core', version: '1.2.3'
testRuntime group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
}

task cacheReflections {
Expand Down
5 changes: 0 additions & 5 deletions engine/src/main/resources/log4j-debug.properties

This file was deleted.

6 changes: 0 additions & 6 deletions engine/src/main/resources/log4j.properties

This file was deleted.

14 changes: 14 additions & 0 deletions engine/src/test/resources/assets/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.classic.android.LogcatAppender">
<tagEncoder>
<pattern>%logger{12}</pattern>
</tagEncoder>
<encoder>
<pattern>%-5level [%thread] (%F:%L) %message%n</pattern>
</encoder>
</appender>

<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration>